def test_given_two_destination_types_when_one_queried_returns_true(self): self.add_func_key_destination_type(id=1, name='user') self.add_func_key_destination_type(id=2, name='queue') result = dao.find_destination_type_for_name('queue') assert_that(result, has_property('name', 'queue'))
def test_given_one_destination_type_when_queried_returns_true(self): name = 'user' self.add_func_key_destination_type(id=1, name=name) result = dao.find_destination_type_for_name(name) assert_that(result, has_property('name', name))
def test_given_one_destination_type_when_other_name_queried_returns_false( self): self.add_func_key_destination_type(id=1, name='user') result = dao.find_destination_type_for_name('queue') assert_that(result, none())
def create_func_key_row(self, model): destination_type_row = func_key_type_dao.find_destination_type_for_name(model.destination) type_row = func_key_type_dao.find_type_for_name(model.type) func_key_row = FuncKeySchema(type_id=type_row.id, destination_type_id=destination_type_row.id) return func_key_row
def create_destination_row(self, model): destination_type_row = func_key_type_dao.find_destination_type_for_name(model.destination) schema, column_name = self.destination_mapping[model.destination] destination_row = schema(destination_type_id=destination_type_row.id, func_key_id=model.id) setattr(destination_row, column_name, model.destination_id) return destination_row
def create_func_key_row(self, model): destination_type_row = func_key_type_dao.find_destination_type_for_name( model.destination) type_row = func_key_type_dao.find_type_for_name(model.type) func_key_row = FuncKeySchema( type_id=type_row.id, destination_type_id=destination_type_row.id) return func_key_row
def create_destination_row(self, model): destination_type_row = func_key_type_dao.find_destination_type_for_name( model.destination) schema, column_name = self.destination_mapping[model.destination] destination_row = schema(destination_type_id=destination_type_row.id, func_key_id=model.id) setattr(destination_row, column_name, model.destination_id) return destination_row
def test_given_one_destination_type_when_other_name_queried_returns_false(self): self.add_func_key_destination_type(id=1, name='user') result = dao.find_destination_type_for_name('queue') assert_that(result, none())
def test_given_no_destination_types_then_returns_none(self): result = dao.find_destination_type_for_name('type') assert_that(result, none())
def validate_destination_type(func_key): if not func_key_type_dao.find_destination_type_for_name(func_key.destination): raise InvalidParametersError(['destination of type %s does not exist' % func_key.destination])
def validate_destination_type(func_key): if not func_key_type_dao.find_destination_type_for_name(func_key.destination): raise errors.invalid_destination_type(func_key.destination)