def test_serialize_course(self): """ Tests the serialize_course method. """ nodes, relationships = serialize_course(self.course.id) self.assertEqual(len(nodes), 9) # the course has 7 "PARENT_OF" relationships and 3 "PRECEDES" self.assertEqual(len(relationships), 10)
def test_serialize_course(self): """ Tests the serialize_course method. """ nodes, relationships = serialize_course(self.course.id) assert len(nodes) == 9 # the course has 7 "PARENT_OF" relationships and 3 "PRECEDES" assert len(relationships) == 10
def test_precedes_relationship(self): """ Tests that two nodes that should have a precedes relationship have it. """ __, relationships = serialize_course(self.course.id) self.assertBlockPairIsRelationship(self.video, self.video2, relationships, "PRECEDES") self.assertBlockPairIsNotRelationship(self.video2, self.video, relationships, "PRECEDES") self.assertBlockPairIsNotRelationship(self.vertical, self.video, relationships, "PRECEDES") self.assertBlockPairIsNotRelationship(self.html, self.video, relationships, "PRECEDES")
def test_parent_relationship(self): """ Test that two nodes that should have a parent_of relationship have it. """ __, relationships = serialize_course(self.course.id) self.assertBlockPairIsRelationship(self.vertical, self.video, relationships, "PARENT_OF") self.assertBlockPairIsRelationship(self.vertical, self.html, relationships, "PARENT_OF") self.assertBlockPairIsRelationship(self.course, self.chapter, relationships, "PARENT_OF") self.assertBlockPairIsNotRelationship(self.course, self.video, relationships, "PARENT_OF") self.assertBlockPairIsNotRelationship(self.video, self.vertical, relationships, "PARENT_OF") self.assertBlockPairIsNotRelationship(self.video, self.html, relationships, "PARENT_OF")
def test_nodes_have_indices(self): """ Test that we add index values on nodes """ nodes, relationships = serialize_course(self.course.id) # the html node should have 0 index, and the problem should have 1 html_nodes = [node for node in nodes if node['block_type'] == 'html'] self.assertEqual(len(html_nodes), 1) problem_nodes = [node for node in nodes if node['block_type'] == 'problem'] self.assertEqual(len(problem_nodes), 1) html_node = html_nodes[0] problem_node = problem_nodes[0] self.assertEqual(html_node['index'], 0) self.assertEqual(problem_node['index'], 1)
def test_nodes_have_indices(self): """ Test that we add index values on nodes """ nodes, relationships = serialize_course(self.course.id) # lint-amnesty, pylint: disable=unused-variable # the html node should have 0 index, and the problem should have 1 html_nodes = [node for node in nodes if node['block_type'] == 'html'] assert len(html_nodes) == 1 problem_nodes = [node for node in nodes if node['block_type'] == 'problem'] assert len(problem_nodes) == 1 html_node = html_nodes[0] problem_node = problem_nodes[0] assert html_node['index'] == 0 assert problem_node['index'] == 1