Update base client usage
This commit is contained in:
parent
b4fbfce684
commit
2fe7a684c5
|
|
@ -89,8 +89,8 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
result = client.execute(MODULE_QUERY, variables={
|
result = client.execute(MODULE_QUERY, variables={
|
||||||
'slug': self.module.slug
|
'slug': self.module.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
module = result.get('data').get('module')
|
module = result.data.get('module')
|
||||||
chapter = module.get('chapters')[0]
|
chapter = module.get('chapters')[0]
|
||||||
self.assertIsNotNone(chapter)
|
self.assertIsNotNone(chapter)
|
||||||
content_blocks = chapter.get('contentBlocks')
|
content_blocks = chapter.get('contentBlocks')
|
||||||
|
|
@ -144,8 +144,8 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
self._test_module_visibility(self.client, 'skillbox')
|
self._test_module_visibility(self.client, 'skillbox')
|
||||||
|
|
||||||
def _test_create_snapshot(self, result, num_snapshots=1):
|
def _test_create_snapshot(self, result, num_snapshots=1):
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
snapshot = result.get('data').get('createSnapshot').get('snapshot')
|
snapshot = result.data.get('createSnapshot').get('snapshot')
|
||||||
chapter = snapshot.get('chapters')[0]
|
chapter = snapshot.get('chapters')[0]
|
||||||
|
|
||||||
self.assertIsNotNone(snapshot.get('created'))
|
self.assertIsNotNone(snapshot.get('created'))
|
||||||
|
|
@ -206,7 +206,7 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', self.second_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', self.second_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
module = self._test_module_visibility(self.get_client(self.teacher2), self.second_class_name)
|
module = self._test_module_visibility(self.get_client(self.teacher2), self.second_class_name)
|
||||||
original_creator = module['chapters'][0]['contentBlocks'][2].get('originalCreator')
|
original_creator = module['chapters'][0]['contentBlocks'][2].get('originalCreator')
|
||||||
self.assertIsNotNone(original_creator)
|
self.assertIsNotNone(original_creator)
|
||||||
|
|
@ -219,8 +219,8 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
snapshot_result = self.client.execute(SNAPSHOT_MODULE_QUERY, variables={
|
snapshot_result = self.client.execute(SNAPSHOT_MODULE_QUERY, variables={
|
||||||
'id': id
|
'id': id
|
||||||
})
|
})
|
||||||
self.assertIsNone(snapshot_result.get('errors'))
|
self.assertIsNone(snapshot_result.errors)
|
||||||
snapshot = snapshot_result.get('data').get('snapshot')
|
snapshot = snapshot_result.data.get('snapshot')
|
||||||
chapters = snapshot.get('chapters')
|
chapters = snapshot.get('chapters')
|
||||||
self.assertEqual(len(chapters), 2)
|
self.assertEqual(len(chapters), 2)
|
||||||
chapter = chapters[0]
|
chapter = chapters[0]
|
||||||
|
|
@ -259,7 +259,7 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', third_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', third_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
snapshot_id = result['data']['createSnapshot']['snapshot']['id']
|
snapshot_id = result['data']['createSnapshot']['snapshot']['id']
|
||||||
|
|
||||||
result = self.client.execute(APPLY_SNAPSHOT_MUTATION, variables={
|
result = self.client.execute(APPLY_SNAPSHOT_MUTATION, variables={
|
||||||
|
|
@ -268,12 +268,12 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
|
|
||||||
result = self.client.execute(MODULE_QUERY, variables={
|
result = self.client.execute(MODULE_QUERY, variables={
|
||||||
'slug': self.module.slug
|
'slug': self.module.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
module = result['data']['module']
|
module = result['data']['module']
|
||||||
chapter1, chapter2 = module['chapters']
|
chapter1, chapter2 = module['chapters']
|
||||||
visible, hidden, custom, custom_hidden = chapter1['contentBlocks']
|
visible, hidden, custom, custom_hidden = chapter1['contentBlocks']
|
||||||
|
|
@ -286,7 +286,7 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
result = self.graphene_client.execute(MODULE_QUERY, variables={
|
result = self.graphene_client.execute(MODULE_QUERY, variables={
|
||||||
'slug': self.module.slug
|
'slug': self.module.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
chapter = result['data']['module']['chapters'][0]
|
chapter = result['data']['module']['chapters'][0]
|
||||||
self.assertEqual(len(chapter['contentBlocks']), 4)
|
self.assertEqual(len(chapter['contentBlocks']), 4)
|
||||||
|
|
||||||
|
|
@ -296,7 +296,7 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
snapshot_id = result['data']['createSnapshot']['snapshot']['id']
|
snapshot_id = result['data']['createSnapshot']['snapshot']['id']
|
||||||
|
|
||||||
teacher2 = User.objects.get(username='teacher2')
|
teacher2 = User.objects.get(username='teacher2')
|
||||||
|
|
@ -307,16 +307,15 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', self.second_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', self.second_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
|
|
||||||
result = self.graphene_client.execute(MODULE_QUERY, variables={
|
result = self.graphene_client.execute(MODULE_QUERY, variables={
|
||||||
'slug': self.module.slug
|
'slug': self.module.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
chapter = result['data']['module']['chapters'][0]
|
chapter = result['data']['module']['chapters'][0]
|
||||||
self.assertEqual(len(chapter['contentBlocks']), 4)
|
self.assertEqual(len(chapter['contentBlocks']), 4)
|
||||||
|
|
||||||
|
|
||||||
def test_snapshot_chapter_visibility_after_apply(self):
|
def test_snapshot_chapter_visibility_after_apply(self):
|
||||||
result = self.graphene_client.execute(CREATE_SNAPSHOT_MUTATION, variables={
|
result = self.graphene_client.execute(CREATE_SNAPSHOT_MUTATION, variables={
|
||||||
'input': {
|
'input': {
|
||||||
|
|
@ -335,10 +334,11 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
a_result = self.get_client(self.teacher2).execute(MODULE_QUERY, variables={
|
a_result = self.get_client(self.teacher2).execute(MODULE_QUERY, variables={
|
||||||
'slug': self.module.slug
|
'slug': self.module.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(a_result.get('errors'))
|
self.assertIsNone(a_result.errors)
|
||||||
a_chapter = a_result['data']['module']['chapters'][0]
|
a_chapter = a_result['data']['module']['chapters'][0]
|
||||||
self.assertEqual(self.second_class_name in map(lambda x: x['name'], a_chapter['titleHiddenFor']), hidden)
|
self.assertEqual(self.second_class_name in map(lambda x: x['name'], a_chapter['titleHiddenFor']), hidden)
|
||||||
self.assertEqual(self.second_class_name in map(lambda x: x['name'], a_chapter['descriptionHiddenFor']), hidden)
|
self.assertEqual(self.second_class_name in map(lambda x: x['name'], a_chapter['descriptionHiddenFor']),
|
||||||
|
hidden)
|
||||||
|
|
||||||
assert_chapter_hidden(True)
|
assert_chapter_hidden(True)
|
||||||
|
|
||||||
|
|
@ -348,7 +348,7 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', self.skillbox_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
snapshot = result['data']['createSnapshot']['snapshot']
|
snapshot = result['data']['createSnapshot']['snapshot']
|
||||||
snapshot_id = snapshot['id']
|
snapshot_id = snapshot['id']
|
||||||
chapter = snapshot['chapters'][0]
|
chapter = snapshot['chapters'][0]
|
||||||
|
|
@ -361,7 +361,7 @@ class CreateSnapshotTestCase(SkillboxTestCase):
|
||||||
'selectedClass': to_global_id('SchoolClassNode', self.second_class.pk),
|
'selectedClass': to_global_id('SchoolClassNode', self.second_class.pk),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
|
|
||||||
assert_chapter_hidden(False)
|
assert_chapter_hidden(False)
|
||||||
|
|
||||||
|
|
@ -384,8 +384,8 @@ class SnapshotTestCase(SkillboxTestCase):
|
||||||
result = self.client.execute(MODULE_SNAPSHOTS_QUERY, variables={
|
result = self.client.execute(MODULE_SNAPSHOTS_QUERY, variables={
|
||||||
"slug": self.slug
|
"slug": self.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
snapshots = result['data']['module']['snapshots']
|
snapshots = result.data['module']['snapshots']
|
||||||
self.assertEqual(len(snapshots), 1)
|
self.assertEqual(len(snapshots), 1)
|
||||||
self.assertEqual(snapshots[0]['creator'], f'{self.teacher.first_name} {self.teacher.last_name}')
|
self.assertEqual(snapshots[0]['creator'], f'{self.teacher.first_name} {self.teacher.last_name}')
|
||||||
|
|
||||||
|
|
@ -397,8 +397,8 @@ class SnapshotTestCase(SkillboxTestCase):
|
||||||
'shared': True
|
'shared': True
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
data = result['data']['shareSnapshot']
|
data = result.data['shareSnapshot']
|
||||||
self.assertTrue(data['success'])
|
self.assertTrue(data['success'])
|
||||||
self.assertTrue(data['snapshot']['shared'])
|
self.assertTrue(data['snapshot']['shared'])
|
||||||
snapshot = Snapshot.objects.get(pk=self.snapshot.pk)
|
snapshot = Snapshot.objects.get(pk=self.snapshot.pk)
|
||||||
|
|
@ -413,7 +413,7 @@ class SnapshotTestCase(SkillboxTestCase):
|
||||||
'shared': True
|
'shared': True
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
self.assertIsNotNone(result.get('errors'))
|
self.assertIsNotNone(result.errors)
|
||||||
|
|
||||||
def test_snapshot_without_creator(self):
|
def test_snapshot_without_creator(self):
|
||||||
self.snapshot.creator = None
|
self.snapshot.creator = None
|
||||||
|
|
@ -422,5 +422,5 @@ class SnapshotTestCase(SkillboxTestCase):
|
||||||
result = self.client.execute(MODULE_SNAPSHOTS_QUERY, variables={
|
result = self.client.execute(MODULE_SNAPSHOTS_QUERY, variables={
|
||||||
"slug": self.slug
|
"slug": self.slug
|
||||||
})
|
})
|
||||||
self.assertIsNone(result.get('errors'))
|
self.assertIsNone(result.errors)
|
||||||
self.assertEqual(len(result.get('data').get('module').get('snapshots')), 1)
|
self.assertEqual(len(result.data.get('module').get('snapshots')), 1)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ class GQLClient(Client):
|
||||||
def get_result(self, *args, **kwargs):
|
def get_result(self, *args, **kwargs):
|
||||||
return GQLResult(self.execute(*args, **kwargs))
|
return GQLResult(self.execute(*args, **kwargs))
|
||||||
|
|
||||||
|
def execute(self, *args, **kwargs):
|
||||||
|
res = super(GQLClient, self).execute(*args, **kwargs)
|
||||||
|
return GQLResult(res)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SkillboxTestCase(TestCase):
|
class SkillboxTestCase(TestCase):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue