コード例 #1
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    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'))
コード例 #2
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    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))
コード例 #3
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    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())
コード例 #4
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    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'))
コード例 #5
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    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))
コード例 #6
0
ファイル: model.py プロジェクト: jaunis/xivo-dao
    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
コード例 #7
0
ファイル: model.py プロジェクト: jaunis/xivo-dao
    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
コード例 #8
0
ファイル: model.py プロジェクト: jaunis/xivo-dao
    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
コード例 #9
0
ファイル: model.py プロジェクト: jaunis/xivo-dao
    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
コード例 #10
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    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())
コード例 #11
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    def test_given_no_destination_types_then_returns_none(self):
        result = dao.find_destination_type_for_name('type')

        assert_that(result, none())
コード例 #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])
コード例 #13
0
ファイル: test_type_dao.py プロジェクト: jaunis/xivo-dao
    def test_given_no_destination_types_then_returns_none(self):
        result = dao.find_destination_type_for_name('type')

        assert_that(result, none())
コード例 #14
0
ファイル: validator.py プロジェクト: jlebleu/xivo-dao
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)