Fix unit tests

This commit is contained in:
Ramon Wenger 2021-05-12 15:25:42 +02:00
parent 1ca6cec0a5
commit a168b3141e
4 changed files with 23 additions and 38 deletions

View File

@ -53,16 +53,12 @@ class CustomAssignmentTestCase(TestCase):
module(slug: $slug) { module(slug: $slug) {
id id
chapters { chapters {
edges {
node {
contentBlocks { contentBlocks {
contents contents
} }
} }
} }
} }
}
}
''' '''
result = self.client.execute(query, variables={ result = self.client.execute(query, variables={
@ -74,7 +70,8 @@ class CustomAssignmentTestCase(TestCase):
@staticmethod @staticmethod
def get_first_contents(result): 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): def test_module_query(self):
result = self.query_module() result = self.query_module()

View File

@ -6,8 +6,6 @@ CONTENT_BLOCK_QUERY = """
query ContentBlockQuery($slug: String!) { query ContentBlockQuery($slug: String!) {
module(slug: $slug) { module(slug: $slug) {
chapters { chapters {
edges {
node {
id id
contentBlocks { contentBlocks {
id id
@ -16,8 +14,6 @@ query ContentBlockQuery($slug: String!) {
} }
} }
} }
}
}
} }
""" """
@ -42,7 +38,7 @@ class ContentBlockTestCase(SkillboxTestCase):
}) })
self.assertIsNone(result.get('errors')) self.assertIsNone(result.get('errors'))
module = result.get('data').get('module') 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.assertEqual(content_block['title'], 'Title')
self.assertIsNotNone(content_block['type']) self.assertIsNotNone(content_block['type'])

View File

@ -54,8 +54,6 @@ query ObjectiveGroupQuery($id: ID!) {
...SchoolClassFragment ...SchoolClassFragment
} }
objectives { objectives {
edges {
node {
id id
text text
hiddenFor { hiddenFor {
@ -66,8 +64,6 @@ query ObjectiveGroupQuery($id: ID!) {
} }
} }
} }
}
}
} }
""" """
@ -307,7 +303,7 @@ class CopyVisibilityForClassesTestCase(TestCase):
def test_objective_visibility(self): def test_objective_visibility(self):
query, variables = self._objective_group_query() query, variables = self._objective_group_query()
objective_group = self._get_objective_group(self.student2_client, query, variables) 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') hidden_for = objective.get('hiddenFor')
self.assertTrue(TEMPLATE_CLASS_NAME in map(lambda x: x['name'], hidden_for)) 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)) self.assertTrue(SYNC_CLASS_NAME not in map(lambda x: x['name'], hidden_for))
@ -315,7 +311,7 @@ class CopyVisibilityForClassesTestCase(TestCase):
self._execute_sync() self._execute_sync()
objective_group = self._get_objective_group(self.student2_client, query, variables) 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') hidden_for = objective.get('hiddenFor')
self.assertTrue(TEMPLATE_CLASS_NAME in map(lambda x: x['name'], hidden_for)) 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)) self.assertTrue(SYNC_CLASS_NAME in map(lambda x: x['name'], hidden_for))

View File

@ -39,15 +39,11 @@ class ObjectiveOrderTestCase(TestCase):
query ObjectiveGroupQuery($id: ID!) { query ObjectiveGroupQuery($id: ID!) {
objectiveGroup(id: $id) { objectiveGroup(id: $id) {
objectives { objectives {
edges {
node {
id id
text text
} }
} }
} }
}
}
""" """
result = self.client.execute(query, variables={ result = self.client.execute(query, variables={
@ -55,9 +51,9 @@ class ObjectiveOrderTestCase(TestCase):
}) })
self.assertIsNone(result.get('errors')) 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(objective1.get('text'), 'first')
self.assertEqual(objective2.get('text'), 'second') self.assertEqual(objective2.get('text'), 'second')