Fix unit tests
This commit is contained in:
parent
1ca6cec0a5
commit
a168b3141e
|
|
@ -53,12 +53,8 @@ class CustomAssignmentTestCase(TestCase):
|
||||||
module(slug: $slug) {
|
module(slug: $slug) {
|
||||||
id
|
id
|
||||||
chapters {
|
chapters {
|
||||||
edges {
|
contentBlocks {
|
||||||
node {
|
contents
|
||||||
contentBlocks {
|
|
||||||
contents
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,11 @@ CONTENT_BLOCK_QUERY = """
|
||||||
query ContentBlockQuery($slug: String!) {
|
query ContentBlockQuery($slug: String!) {
|
||||||
module(slug: $slug) {
|
module(slug: $slug) {
|
||||||
chapters {
|
chapters {
|
||||||
edges {
|
id
|
||||||
node {
|
contentBlocks {
|
||||||
id
|
id
|
||||||
contentBlocks {
|
title
|
||||||
id
|
type
|
||||||
title
|
|
||||||
type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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'])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,17 +54,13 @@ query ObjectiveGroupQuery($id: ID!) {
|
||||||
...SchoolClassFragment
|
...SchoolClassFragment
|
||||||
}
|
}
|
||||||
objectives {
|
objectives {
|
||||||
edges {
|
id
|
||||||
node {
|
text
|
||||||
id
|
hiddenFor {
|
||||||
text
|
...SchoolClassFragment
|
||||||
hiddenFor {
|
}
|
||||||
...SchoolClassFragment
|
visibleFor {
|
||||||
}
|
...SchoolClassFragment
|
||||||
visibleFor {
|
|
||||||
...SchoolClassFragment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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))
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,8 @@ class ObjectiveOrderTestCase(TestCase):
|
||||||
query ObjectiveGroupQuery($id: ID!) {
|
query ObjectiveGroupQuery($id: ID!) {
|
||||||
objectiveGroup(id: $id) {
|
objectiveGroup(id: $id) {
|
||||||
objectives {
|
objectives {
|
||||||
edges {
|
id
|
||||||
node {
|
text
|
||||||
id
|
|
||||||
text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue