示例#1
0
 def test_update_parent_road_condition_two_children(self):
     condition = self.conditions[0]
     parent = self.conditions[1]
     child = self.conditions[2]
     create_rc_to_rc([parent], [child])
     with self.assertRaises(ExceededRoadConditionChildNumbers):
         update_parents(condition, None, parent.id)
示例#2
0
 def test_delete_road_condition(self):
     condition = self.conditions[0]
     child = self.conditions[1]
     create_rc_to_rc([condition], [child])
     delete_road_condition(condition.id)
     self.assertFalse(has_road_condition_with_id(condition.id))
     self.assertFalse(has_road_condition_with_id(child.id))
示例#3
0
 def test_update_parent_road_condition_none(self):
     condition = self.conditions[0]
     parent = self.conditions[1]
     create_rc_to_rc([parent], [condition])
     update_parents(condition, None, None)
     updated_parent = get_road_condition_parents(condition)[0]
     self.assertEqual(parent, updated_parent)
 def test_to_json_road_condition(self):
     condition = self.conditions[0]
     child = self.conditions[1]
     action = self.rc_actions[0]
     create_rc_to_rc([condition], [child])
     create_rc_to_rca([condition], [action])
     json = to_json_road_condition(condition)
     expected = ("{'name': '%s', 'time': {}, "
                 "'value': %s, "
                 "'type': %s, "
                 "'actions': [{'goal_type': %s, "
                 "'instrument_system': %s, "
                 "'action_name': '%s', "
                 "'constraint': {}, "
                 "'description': %s, "
                 "'instrument_actions': []}], "
                 "'road_conditions': [{'name': '%s', 'time': {}, "
                 "'value': '%s', "
                 "'type': %s, "
                 "'actions': [], "
                 "'road_conditions': []}]}" % (
                     condition.name,
                     condition.value,
                     condition.road_condition_type.id,
                     action.road_condition_action_goal.id,
                     action.instrument_system.id,
                     action.action_name,
                     action.description,
                     child.name,
                     child.value,
                     child.road_condition_type.id,
                 ))
     self.maxDiff = None
     self.assertEqual(str(json), expected)
示例#5
0
 def test_update_parent_road_condition_incorrect_depth(self):
     condition = self.conditions[0]
     parent_1 = self.conditions[1]
     parent_2 = self.conditions[2]
     parent_3 = self.conditions[3]
     create_rc_to_rc([parent_1, parent_2], [parent_2, parent_3])
     with self.assertRaises(ExceededRoadConditionChildDepth):
         update_parents(condition, None, parent_3.id)
示例#6
0
 def test_update_parent_road_condition_correct(self):
     condition = self.conditions[0]
     parent = self.conditions[1]
     grand_parent = self.conditions[2]
     create_rc_to_rc([grand_parent], [parent])
     update_parents(condition, None, parent.id)
     updated_parent = get_road_condition_parents(condition)[0]
     self.assertEqual(parent, updated_parent)
 def test_query_children(self):
     client = Client(schema)
     segment = self.segments[0]
     condition = self.conditions[0]
     child = self.conditions[1]
     create_rs_to_rc([segment], [condition])
     create_rc_to_rc([condition], [child])
     executed = client.execute('''
                                 query {
                                     roadSegments
                                     (
                                         segmentId: %s,
                                         conditionId: %s,
                                     )
                                     {
                                         name
                                     }
                                 }
                                 ''' % (segment.id, child.id))
     self.assertEquals(executed['data']['roadSegments'][0]['name'],
                       segment.name)
示例#8
0
 def test_update_parent_road_condition_circular(self):
     condition = self.conditions[0]
     parent_1 = self.conditions[1]
     create_rc_to_rc([condition], [parent_1])
     with self.assertRaises(CircularRoadCondition):
         update_parents(condition, None, parent_1.id)