diff --git a/pronotepy/dataClasses.py b/pronotepy/dataClasses.py index 6cf8031..4f99ea8 100644 --- a/pronotepy/dataClasses.py +++ b/pronotepy/dataClasses.py @@ -127,7 +127,7 @@ def __init__(self, client, parsed_json): @property def grades(self): """Get grades from the period.""" - json_data = {'Periode': {'N': self.id, 'L': self.name}} + json_data = {'periode': {'N': self.id, 'L': self.name}} response = self._client.post('DernieresNotes', 198, json_data) log.debug(response) grades = response['donneesSec']['donnees']['listeDevoirs']['V'] @@ -137,7 +137,7 @@ def grades(self): def averages(self): """Get averages from the period.""" - json_data = {'Periode': {'N': self.id, 'L': self.name}} + json_data = {'periode': {'N': self.id, 'L': self.name}} response = self._client.post('DernieresNotes', 198, json_data) crs = response['donneesSec']['donnees']['listeServices']['V'] return [Average(c) for c in crs] @@ -146,7 +146,7 @@ def averages(self): def overall_average(self): """Get overall average from the period. If the period average is not provided by pronote, then it's calculated. Calculation may not be the same as the actual average. (max difference 0.01)""" - json_data = {'Periode': {'N': self.id, 'L': self.name}} + json_data = {'periode': {'N': self.id, 'L': self.name}} response = self._client.post('DernieresNotes', 198, json_data) average = response['donneesSec']['donnees'].get('moyGenerale') if average: @@ -174,7 +174,7 @@ def overall_average(self): @property def evaluations(self): - json_data = {'Periode': {'N': self.id, 'L': self.name, 'G': 2}} + json_data = {'periode': {'N': self.id, 'L': self.name, 'G': 2}} response = self._client.post('DernieresEvaluations', 201, json_data) evaluations = response['donneesSec']['donnees']['listeEvaluations']['V'] return [Evaluation(e) for e in evaluations] diff --git a/pronotepy/test_pronotepy.py b/pronotepy/test_pronotepy.py index 615508a..6d21de7 100644 --- a/pronotepy/test_pronotepy.py +++ b/pronotepy/test_pronotepy.py @@ -13,8 +13,14 @@ def test__get_week(self): self.assertEqual(client.get_week(client.start_day + datetime.timedelta(days=8)), 2) def test_lessons(self): - self.assertIsNotNone( - client.lessons(client.start_day, client.start_day + datetime.timedelta(days=8))) + start = client.start_day + end = client.start_day+datetime.timedelta(days=8) + lessons = client.lessons(start, end) + # We assume demo website will always have some lessons + self.assertGreater(len(lessons), 0) + for lesson in lessons: + self.assertLessEqual(start, lesson.start.date()) + self.assertLessEqual(lesson.start.date(), end) def test_periods(self): self.assertIsNotNone(client.periods) @@ -23,8 +29,15 @@ def test_current_period(self): self.assertIsNotNone(client.current_period) def test_homework(self): - self.assertIsNotNone( - client.homework(client.start_day, client.start_day + datetime.timedelta(days=8))) + start = client.start_day + end = client.start_day+datetime.timedelta(days=31) + homework = client.homework(start, end) + + # We assume demo website will always have homework + self.assertGreater(len(homework), 0) + for hw in homework: + self.assertLessEqual(start, hw.date) + self.assertLessEqual(hw.date, end) def test_refresh(self): client.refresh() @@ -38,17 +51,19 @@ def setUpClass(cls) -> None: cls.period = client.current_period def test_grades(self): - self.assertIsNotNone(self.period.grades) + # We assume demo website will have grades + grades = self.period.grades + self.assertGreater(len(grades), 0) def test_averages(self): - self.assertIsNotNone(self.period.averages) + self.assertGreater(len(self.period.averages), 0) def test_overall_average(self): self.assertIsNotNone(self.period.overall_average) def test_evaluations(self): evaluations = self.period.evaluations - self.assertIsNotNone(evaluations) + self.assertGreater(len(evaluations), 0) for evaluation in evaluations: for acquisition in evaluation.acquisitions: self.assertIsNotNone(acquisition) @@ -80,7 +95,8 @@ def test_files(self): class TestParentClient(unittest.TestCase): @classmethod def setUpClass(cls) -> None: - cls.client = pronotepy.ParentClient('https://demo.index-education.net/pronote/parent.html', 'demonstration', 'pronotevs') + cls.client = pronotepy.ParentClient('https://demo.index-education.net/pronote/parent.html', + 'demonstration', 'pronotevs') def test_set_child(self): self.client.set_child(self.client.children[1]) @@ -88,7 +104,7 @@ def test_set_child(self): def test_homework(self): self.assertIsNotNone( - self.client.homework(self.client.start_day, self.client.start_day + datetime.timedelta(days=8))) + self.client.homework(self.client.start_day, self.client.start_day + datetime.timedelta(days=31))) if __name__ == '__main__':