Esempio n. 1
0
    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'))
Esempio n. 2
0
    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))
Esempio n. 3
0
    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())
Esempio n. 4
0
    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'))
Esempio n. 5
0
    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))
Esempio n. 6
0
    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
Esempio n. 7
0
    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
Esempio n. 8
0
    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
Esempio n. 9
0
    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
Esempio n. 10
0
    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())
Esempio n. 11
0
    def test_given_no_destination_types_then_returns_none(self):
        result = dao.find_destination_type_for_name('type')

        assert_that(result, none())
Esempio n. 12
0
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])
Esempio n. 13
0
    def test_given_no_destination_types_then_returns_none(self):
        result = dao.find_destination_type_for_name('type')

        assert_that(result, none())
Esempio n. 14
0
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)