forked from kippnorcal/google_classroom
-
Notifications
You must be signed in to change notification settings - Fork 7
/
tests.py
111 lines (96 loc) · 2.9 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from config import TestConfig, db_generator
from api import (
Announcements,
CourseAliases,
Courses,
OrgUnits,
Guardians,
GuardianInvites,
Invitations,
Topics,
Students,
Teachers,
)
import os
import pandas as pd
from test_responses import (
FakeService,
ALIAS_SOLUTION,
ORG_UNIT_SOLUTION,
GUARDIAN_SOLUTION,
GUARDIAN_INVITE_SOLUTION,
COURSE_SOLUTION,
TOPIC_SOLUTION,
STUDENT_SOLUTION,
TEACHER_SOLUTION,
INVITATION_SOLUTION,
ANNOUNCEMENT_SOLUTION,
)
# TODO: Add tests for Coursework and Submissions.
class TestEndToEnd:
def setup(self):
self.config = TestConfig
self.sql = db_generator(self.config)
self.service = FakeService()
def teardown(self):
if os.path.exists(self.config.DB):
os.remove(self.config.DB)
def test_get_org_units(self):
self.generic_get_test(
OrgUnits(self.service, self.sql, self.config), ORG_UNIT_SOLUTION
)
def test_get_guardians(self):
self.generic_get_test(
Guardians(self.service, self.sql, self.config), GUARDIAN_SOLUTION
)
def test_get_guardian_invites(self):
self.generic_get_test(
GuardianInvites(self.service, self.sql, self.config),
GUARDIAN_INVITE_SOLUTION,
)
def test_get_courses(self):
self.generic_get_test(
Courses(self.service, self.sql, self.config), COURSE_SOLUTION
)
def test_get_topics(self):
self.generic_get_test(
Topics(self.service, self.sql, self.config),
TOPIC_SOLUTION,
course_ids=[0, 1],
)
def test_get_students(self):
self.generic_get_test(
Students(self.service, self.sql, self.config),
STUDENT_SOLUTION,
course_ids=[0, 1],
)
def test_get_teachers(self):
self.generic_get_test(
Teachers(self.service, self.sql, self.config),
TEACHER_SOLUTION,
course_ids=[0, 1],
)
def test_get_aliases(self):
self.generic_get_test(
CourseAliases(self.service, self.sql, self.config),
ALIAS_SOLUTION,
course_ids=[0, 1],
)
def test_get_invitations(self):
self.generic_get_test(
Invitations(self.service, self.sql, self.config),
INVITATION_SOLUTION,
course_ids=[0, 1],
)
def test_get_announcements(self):
self.generic_get_test(
Announcements(self.service, self.sql, self.config),
ANNOUNCEMENT_SOLUTION,
course_ids=[0, 1],
)
def generic_get_test(self, endpoint, solution, course_ids=[None]):
endpoint.batch_pull_data(course_ids=course_ids)
result = pd.read_sql_table(
endpoint.table_name, con=self.sql.engine, schema=self.sql.schema
)
assert result.equals(solution)