From a168b3141e181d482ca68a059caa34240f77c632 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Wed, 12 May 2021 15:25:42 +0200 Subject: [PATCH] Fix unit tests --- .../tests/test_custom_assignments.py | 11 ++++------ server/books/tests/test_content_blocks.py | 16 +++++--------- .../test_copy_visibility_for_other_class.py | 22 ++++++++----------- .../objectives/tests/test_objective_order.py | 12 ++++------ 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/server/assignments/tests/test_custom_assignments.py b/server/assignments/tests/test_custom_assignments.py index 435a394b..b8905c1d 100644 --- a/server/assignments/tests/test_custom_assignments.py +++ b/server/assignments/tests/test_custom_assignments.py @@ -53,12 +53,8 @@ class CustomAssignmentTestCase(TestCase): module(slug: $slug) { id chapters { - edges { - node { - contentBlocks { - contents - } - } + contentBlocks { + contents } } } @@ -74,7 +70,8 @@ class CustomAssignmentTestCase(TestCase): @staticmethod def get_first_contents(result): - return result.get('data').get('module').get('chapters').get('edges')[0].get('node').get('contentBlocks')[0].get('contents') + return result.get('data').get('module').get('chapters')[0].get('contentBlocks')[0].get( + 'contents') def test_module_query(self): result = self.query_module() diff --git a/server/books/tests/test_content_blocks.py b/server/books/tests/test_content_blocks.py index c8ea52ee..d5dbb58a 100644 --- a/server/books/tests/test_content_blocks.py +++ b/server/books/tests/test_content_blocks.py @@ -6,15 +6,11 @@ CONTENT_BLOCK_QUERY = """ query ContentBlockQuery($slug: String!) { module(slug: $slug) { chapters { - edges { - node { - id - contentBlocks { - id - title - type - } - } + id + contentBlocks { + id + title + type } } } @@ -42,7 +38,7 @@ class ContentBlockTestCase(SkillboxTestCase): }) self.assertIsNone(result.get('errors')) module = result.get('data').get('module') - content_block = module['chapters']['edges'][0]['node']['contentBlocks'][0] + content_block = module['chapters'][0]['contentBlocks'][0] self.assertEqual(content_block['title'], 'Title') self.assertIsNotNone(content_block['type']) diff --git a/server/books/tests/test_copy_visibility_for_other_class.py b/server/books/tests/test_copy_visibility_for_other_class.py index 74342dd5..004aa921 100644 --- a/server/books/tests/test_copy_visibility_for_other_class.py +++ b/server/books/tests/test_copy_visibility_for_other_class.py @@ -54,17 +54,13 @@ query ObjectiveGroupQuery($id: ID!) { ...SchoolClassFragment } objectives { - edges { - node { - id - text - hiddenFor { - ...SchoolClassFragment - } - visibleFor { - ...SchoolClassFragment - } - } + id + text + hiddenFor { + ...SchoolClassFragment + } + visibleFor { + ...SchoolClassFragment } } } @@ -307,7 +303,7 @@ class CopyVisibilityForClassesTestCase(TestCase): def test_objective_visibility(self): query, variables = self._objective_group_query() objective_group = self._get_objective_group(self.student2_client, query, variables) - objective = objective_group.get('objectives')['edges'][0]['node'] + objective = objective_group.get('objectives')[0] hidden_for = objective.get('hiddenFor') self.assertTrue(TEMPLATE_CLASS_NAME in map(lambda x: x['name'], hidden_for)) self.assertTrue(SYNC_CLASS_NAME not in map(lambda x: x['name'], hidden_for)) @@ -315,7 +311,7 @@ class CopyVisibilityForClassesTestCase(TestCase): self._execute_sync() objective_group = self._get_objective_group(self.student2_client, query, variables) - objective = objective_group.get('objectives')['edges'][0]['node'] + objective = objective_group.get('objectives')[0] hidden_for = objective.get('hiddenFor') self.assertTrue(TEMPLATE_CLASS_NAME in map(lambda x: x['name'], hidden_for)) self.assertTrue(SYNC_CLASS_NAME in map(lambda x: x['name'], hidden_for)) diff --git a/server/objectives/tests/test_objective_order.py b/server/objectives/tests/test_objective_order.py index f17dfcde..08396988 100644 --- a/server/objectives/tests/test_objective_order.py +++ b/server/objectives/tests/test_objective_order.py @@ -39,12 +39,8 @@ class ObjectiveOrderTestCase(TestCase): query ObjectiveGroupQuery($id: ID!) { objectiveGroup(id: $id) { objectives { - edges { - node { - id - text - } - } + id + text } } } @@ -55,9 +51,9 @@ class ObjectiveOrderTestCase(TestCase): }) self.assertIsNone(result.get('errors')) - objective_nodes = result.get('data').get('objectiveGroup').get('objectives').get('edges') + objective_nodes = result.get('data').get('objectiveGroup').get('objectives') - objective1, objective2, objective3, objective4 = [node['node'] for node in objective_nodes] + objective1, objective2, objective3, objective4 = [node for node in objective_nodes] self.assertEqual(objective1.get('text'), 'first') self.assertEqual(objective2.get('text'), 'second')