| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | - import datetime | ||
| 2 | 1 | import mock | |
| 2 | + | ||
| 3 | 3 | import webuntis | |
| 4 | 4 | from . import WebUntisTestCase, stub_session_parameters, \ | |
| 5 | 5 | mock_results | |
@@ -303,3 +303,26 @@ def test_timegridUnits(self): | |||
| 303 | 303 | with self.noop_result_mock('getTimegridUnits'): | |
| 304 | 304 | st = s.timegridUnits() | |
| 305 | 305 | assert type(st) is webuntis.objects.TimegridObject | |
| 306 | + | ||
| 307 | + @staticmethod | ||
| 308 | + def student_result_mock(methodname): | ||
| 309 | + def inner(url, jsondata, headers): | ||
| 310 | + return { | ||
| 311 | + "result": [ | ||
| 312 | + {"id": 1, "key": "1234567", "name": u"MuellerAle", "foreName": "Alexander", "longName": u"Mueller", | ||
| 313 | + "gender": "male"}, | ||
| 314 | + ]} | ||
| 315 | + | ||
| 316 | + return mock_results({methodname: inner}) | ||
| 317 | + | ||
| 318 | + def test_students(self): | ||
| 319 | + s = webuntis.Session(**stub_session_parameters) | ||
| 320 | + with self.student_result_mock('getStudents'): | ||
| 321 | + st = s.students() | ||
| 322 | + assert st | ||
| 323 | + assert len(st) == 1 | ||
| 324 | + assert st == st | ||
| 325 | + assert type(st) is webuntis.objects.StudentsList | ||
| 326 | + student = st[0] | ||
| 327 | + assert type(student) == webuntis.objects.StudentObject | ||
| 328 | + assert student.full_name == "Alexander Mueller" | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -322,7 +322,6 @@ def timegridUnits(self): | |||
| 322 | 322 | """ | |
| 323 | 323 | return objects.TimegridObject, 'getTimegridUnits', {} | |
| 324 | 324 | ||
| 325 | - | ||
| 326 | 325 | @result_wrapper | |
| 327 | 326 | def students(self): | |
| 328 | 327 | """ | |
@@ -331,6 +330,7 @@ def students(self): | |||
| 331 | 330 | """ | |
| 332 | 331 | return objects.StudentsList, 'getStudents', {} | |
| 333 | 332 | ||
| 333 | + | ||
| 334 | 334 | class Session(JSONRPCSession, ResultWrapperMixin): | |
| 335 | 335 | """The origin of everything you want to do with the WebUntis API. Can be | |
| 336 | 336 | used as a context-manager to provide automatic log-out. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments