Exemple #1
0
    def test_associate_sip_fix(self):
        user_row = self.add_user()
        sip = self.add_endpoint_sip(name='sipname')
        line = self.add_line(endpoint_sip_uuid=sip.uuid)
        self.add_user_line(user_id=user_row.id, line_id=line.id)
        group = self.add_group()

        user_dao.associate_all_groups(user_row, [group])

        user = self.session.query(User).first()
        assert_that(user.group_members, contains(
            has_properties(queue_name=group.name,
                           interface='PJSIP/sipname',
                           channel='SIP')
        ))
Exemple #2
0
    def test_associate_multiple_users(self):
        user_row = self.add_user()
        sip = self.add_endpoint_sip()
        line = self.add_line(endpoint_sip_uuid=sip.uuid)
        self.add_user_line(user_id=user_row.id, line_id=line.id)

        group1 = self.add_group()
        group2 = self.add_group()
        group3 = self.add_group()

        user_dao.associate_all_groups(user_row, [group1, group2, group3])

        user = self.session.query(User).first()
        assert_that(user, equal_to(user_row))
        assert_that(user.groups, contains_inanyorder(group1, group2, group3))
Exemple #3
0
    def test_associate_custom_fix(self):
        user_row = self.add_user()
        custom = self.add_usercustom(interface='custom/interface')
        line = self.add_line(endpoint_custom_id=custom.id)
        self.add_user_line(user_id=user_row.id, line_id=line.id)
        group = self.add_group()

        user_dao.associate_all_groups(user_row, [group])

        user = self.session.query(User).first()
        assert_that(user.group_members, contains(
            has_properties(queue_name=group.name,
                           interface='custom/interface',
                           channel='**Unknown**')
        ))
Exemple #4
0
    def test_users_dissociation(self):
        user_row = self.add_user()
        sip = self.add_endpoint_sip(name='sipname')
        line = self.add_line(endpoint_sip_uuid=sip.uuid)
        self.add_user_line(user_id=user_row.id, line_id=line.id)
        group = self.add_group()
        user_dao.associate_all_groups(user_row, [group])

        user = self.session.query(User).first()
        assert_that(user.groups, contains(group))

        user_dao.associate_all_groups(user_row, [])

        user = self.session.query(User).first()
        assert_that(user, equal_to(user_row))
        assert_that(user.groups, empty())

        row = self.session.query(GroupFeatures).first()
        assert_that(row, not_(none()))

        row = self.session.query(QueueMember).first()
        assert_that(row, none())