def test_given_template_has_park_position_func_key_when_getting_then_returns_service_func_key( self): destination_row = self.create_park_position_func_key('701') expected = self.prepare_template(destination_row, FuncKeyDestParkPosition(position=701)) result = dao.get(expected.id) assert_that(expected, equal_to(result))
def test_given_template_has_park_position_func_key_when_deleting_then_deletes_park_position( self): destination_row = self.create_park_position_func_key('701') template = self.prepare_template(destination_row, FuncKeyDestParkPosition(position=701)) dao.delete(template) self.assert_destination_deleted('park_position', destination_row.park_position)
def find_or_create(self, destination): func_key_row = self.create_func_key(self.TYPE_ID, self.DESTINATION_TYPE_ID) destination_row = FuncKeyDestParkPosition(func_key_id=func_key_row.id, park_position=str( destination.position)) self.session.add(destination_row) self.session.flush() return destination_row
def test_given_template_has_park_position_func_key_when_creating_then_creates_mapping( self): template = self.build_template_with_key( FuncKeyDestParkPosition(position=701)) result = dao.create(template) destination_row = self.find_destination('park_position', '701') assert_that(destination_row.park_position, equal_to('701')) self.assert_mapping_has_destination('park_position', destination_row) assert_that(result.keys[1].id, equal_to(destination_row.func_key_id))
def test_given_position_inside_range_then_validation_passes(self): destination = FuncKeyDestParkPosition(position=710) self.validator.validate(destination) self.dao.find_park_position_range.assert_called_once_with()
def test_given_position_over_maximum_then_raises_error(self): destination = FuncKeyDestParkPosition(position=800) assert_that( calling(self.validator.validate).with_args(destination), raises(InputError))