示例#1
0
    def test_find_main_user_line_no_line(self):
        self.add_user()
        line_id = 2

        result = user_line_dao.find_main_user_line(line_id)

        assert_that(result, equal_to(None))
示例#2
0
    def test_find_main_user_line(self):
        user = self.add_user()
        line1 = self.add_line()
        line2 = self.add_line()
        main_user_line = self.add_user_line(user_id=user.id,
                                            line_id=line1.id,
                                            main_user=True,
                                            main_line=True)
        self.add_user_line(user_id=user.id,
                           line_id=line2.id,
                           main_user=False,
                           main_line=True)

        result = user_line_dao.find_main_user_line(line1.id)

        assert_that(result, instance_of(UserLine))
        assert_that(result,
                    has_property('user_id', main_user_line.user_id),
                    has_property('line_id', main_user_line.line_id)
                    )
示例#3
0
def _adjust_optional_parameters(user_line):
    user_line_main_user = dao.find_main_user_line(user_line.line_id)
    if user_line_main_user is not None:
        user_line.main_user = (user_line.user_id == user_line_main_user.user_id)
示例#4
0
def associate_line_extension(line_extension):
    created_line_extension = line_extension_dao.associate(line_extension)
    main_user_line = user_line_dao.find_main_user_line(created_line_extension.line_id)
    if main_user_line:
        fix_associations(main_user_line)
    return created_line_extension
示例#5
0
def associate_user_line(user_line):
    created_user_line = user_line_dao.associate(user_line)
    main_user_line = user_line_dao.find_main_user_line(created_user_line.line_id)
    fix_associations(main_user_line)
    return created_user_line
示例#6
0
    def test_find_main_user_line_one_line_no_user(self):
        user_line = self.add_user_line_without_user()

        result = user_line_dao.find_main_user_line(user_line.line_id)

        assert_that(result, none())
示例#7
0
    def test_find_main_user_line_one_user(self):
        user_line = self.add_user_line_without_exten()

        result = user_line_dao.find_main_user_line(user_line.line_id)

        assert_that(result.user_id, equal_to(user_line.user_id))
示例#8
0
    def test_find_main_user_line_no_user(self):
        line_id = 33

        result = user_line_dao.find_main_user_line(line_id)

        assert_that(result, equal_to(None))