FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Test students() and StudentsList · robquant/python-webuntis@c336247 · GitHub

Commit c336247

Browse files
committed
Test students() and StudentsList
1 parent 57c2c2b commit c336247

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

‎tests/test_session.py‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import datetime
21
import mock
2+
33
import webuntis
44
from . import WebUntisTestCase, stub_session_parameters, \
55
mock_results
@@ -303,3 +303,26 @@ def test_timegridUnits(self):
303303
with self.noop_result_mock('getTimegridUnits'):
304304
st = s.timegridUnits()
305305
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"

‎webuntis/session.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ def timegridUnits(self):
322322
"""
323323
return objects.TimegridObject, 'getTimegridUnits', {}
324324

325-
326325
@result_wrapper
327326
def students(self):
328327
"""
@@ -331,6 +330,7 @@ def students(self):
331330
"""
332331
return objects.StudentsList, 'getStudents', {}
333332

333+
334334
class Session(JSONRPCSession, ResultWrapperMixin):
335335
"""The origin of everything you want to do with the WebUntis API. Can be
336336
used as a context-manager to provide automatic log-out.

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL