-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tracy.py
More file actions
146 lines (110 loc) · 5.35 KB
/
test_tracy.py
File metadata and controls
146 lines (110 loc) · 5.35 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import pytest
from app.logic.tracy import Tracy
from app.logic.tracy import InvalidQueryException
@pytest.fixture(scope='class')
def tracy(request):
return Tracy()
@pytest.mark.usefixtures("tracy")
class Test_Tracy:
@pytest.mark.unit
def test_init(self, tracy):
assert True
@pytest.mark.integration
def test_getStudents(self, tracy):
students = tracy.getStudents()
assert ['Elaheh','Guillermo','Jeremiah','Kat'] == [s.FIRST_NAME for s in students]
assert ['718','300','420','420'] == [s.STU_CPO for s in students]
@pytest.mark.integration
def test_getStudentFromBNumber(self, tracy):
student = tracy.getStudentFromBNumber("B00734292")
assert 'Guillermo' == student.FIRST_NAME
student = tracy.getStudentFromBNumber(" B00734292")
assert 'Guillermo' == student.FIRST_NAME
student = tracy.getStudentFromBNumber("B00888329 ")
assert 'Jeremiah' == student.FIRST_NAME
with pytest.raises(InvalidQueryException):
student = tracy.getStudentFromBNumber("B0000000")
with pytest.raises(InvalidQueryException):
student = tracy.getStudentFromBNumber(17)
@pytest.mark.integration
def test_getStudentFromEmail(self, tracy):
student = tracy.getStudentFromEmail("cruzg@berea.edu")
assert 'Guillermo' == student.FIRST_NAME
with pytest.raises(InvalidQueryException):
student = tracy.getStudentFromEmail("jimmyjoe@place.biz")
with pytest.raises(InvalidQueryException):
student = tracy.getStudentFromEmail(17)
@pytest.mark.integration
def test_getSupervisors(self, tracy):
supervisors = tracy.getSupervisors()
assert ['Alex','Brian','Jan','Jasmine','Mario','Megan','Scott'] == [s.FIRST_NAME for s in supervisors]
assert ['420','6305','6301','6301','6302','6303','6300'] == [s.CPO for s in supervisors]
@pytest.mark.integration
def test_getSupervisorFromID(self, tracy):
supervisor = tracy.getSupervisorFromID("B1236237")
assert 'Megan' == supervisor.FIRST_NAME
with pytest.raises(InvalidQueryException):
supervisor = tracy.getSupervisorFromID("eleven")
with pytest.raises(InvalidQueryException):
supervisor = tracy.getSupervisorFromID(17)
@pytest.mark.integration
def test_getSupervisorFromEmail(self, tracy):
supervisor = tracy.getSupervisorFromEmail("nakazawam@berea.edu")
assert 'Mario' == supervisor.FIRST_NAME
supervisor = tracy.getSupervisorFromEmail("heggens@berea.edu")
assert 'Scott' == supervisor.FIRST_NAME
with pytest.raises(InvalidQueryException):
supervisor = tracy.getSupervisorFromEmail("nakazawamasdfd.com")
with pytest.raises(InvalidQueryException):
supervisor = tracy.getSupervisorFromEmail(17)
@pytest.mark.integration
def test_getPositionsFromDepartment(self, tracy):
positions = tracy.getPositionsFromDepartment("2114","6740")
assert ['S12345','S61408','S61407','S61421','S61419'] == [p.POSN_CODE for p in positions]
positions = tracy.getPositionsFromDepartment("2114","0000")
assert [] == [p.POSN_CODE for p in positions]
@pytest.mark.integration
def test_getDepartments(self, tracy):
departments = tracy.getDepartments()
assert ['Biology','Computer Science','Mathematics','Technology and Applied Design'] == [d.DEPT_NAME for d in departments]
assert '2107' == departments[0].ORG
assert '6740' == departments[0].ACCOUNT
@pytest.mark.integration
def test_getPositionFromCode(self, tracy):
position = tracy.getPositionFromCode("S61427")
assert 'Teaching Associate' == position.POSN_TITLE
assert '2' == position.WLS
with pytest.raises(InvalidQueryException):
position = tracy.getPositionFromCode("eleven")
with pytest.raises(InvalidQueryException):
position = tracy.getPositionFromCode(17)
@pytest.mark.integration
def test_getSupervisorsFromUserInput(self, tracy):
supervisor = tracy.getSupervisorsFromUserInput("Jan Pearce")
assert "Jan" == supervisor[0].FIRST_NAME
assert 1 == len(supervisor)
supervisor = tracy.getSupervisorsFromUserInput("heggen")
assert "Scott" == supervisor[0].FIRST_NAME
assert 1 == len(supervisor)
supervisor = tracy.getSupervisorsFromUserInput("Peter Parker")
assert supervisor != True
assert 0 == len(supervisor)
@pytest.mark.integration
def test_getStudentsFromUserInput(self, tracy):
students = tracy.getStudentsFromUserInput("Guillermo")
assert "Guillermo" == students[0].FIRST_NAME
assert 1 == len(students)
students = tracy.getStudentsFromUserInput("Adams")
assert 2 == len(students)
assert "Adams" == students[1].LAST_NAME
students = tracy.getSupervisorsFromUserInput("John Smith")
assert students != True
assert 0 == len(students)
@pytest.mark.integration
def test_checkStudentOrSupervisor(self, tracy):
user = tracy.checkStudentOrSupervisor("cruzg")
assert "Student" == user
user = tracy.checkStudentOrSupervisor("heggens")
assert "Supervisor" == user
with pytest.raises(InvalidQueryException):
user = tracy.checkStudentOrSupervisor("smith")