def test_given_one_user_three_lines_two_extensions_then_returns_user_hint( self): user = self.add_user(enablehint=1) extension1 = self.add_extension(exten='1001', context=self.context.name) extension2 = self.add_extension(exten='1002', context=self.context.name) self.add_user_destination(user.id) self.add_sip_line_to_extension_and_user('line1', user.id, extension1.id) self.add_sip_line_to_extension_and_user('line2', user.id, extension2.id, main_line=False) self.add_sip_line_to_extension_and_user('line3', user.id, extension2.id, main_line=False) assert_that( hint_dao.user_hints(self.context.name), contains_inanyorder( has_properties(user_id=user.id, extension='1001', argument='PJSIP/line1&PJSIP/line2&PJSIP/line3'), has_properties(user_id=user.id, extension='1002', argument='PJSIP/line1&PJSIP/line2&PJSIP/line3'), ))
def test_given_user_with_sccp_line_then_returns_user_hint(self): sccpline_row = self.add_sccpline(name='1001', context=self.context) user_row = self.add_user_and_func_key('sccp', sccpline_row.id, '1001') expected = Hint(user_id=user_row.id, extension='1001', argument='SCCP/1001') assert_that(hint_dao.user_hints(self.context), contains(expected))
def test_given_user_with_sip_line_then_returns_user_hint(self): usersip_row = self.add_usersip(name='abcdef') user_row = self.add_user_and_func_key('sip', usersip_row.id) expected = Hint(user_id=user_row.id, extension='1000', argument='SIP/abcdef') assert_that(hint_dao.user_hints(self.context), contains(expected))
def test_given_user_with_custom_line_then_returns_user_hint(self): custom_row = self.add_usercustom(interface='ghijkl', context=self.context) user_row = self.add_user_and_func_key('custom', custom_row.id, '1002') expected = Hint(user_id=user_row.id, extension='1002', argument='ghijkl') assert_that(hint_dao.user_hints(self.context), contains(expected))
def test_given_user_with_custom_line_then_returns_user_hint(self): custom_row = self.add_usercustom(interface='ghijkl', context=self.context.name) user_row = self.add_user_custom_and_func_key(custom_row.id, '1002') assert_that( hint_dao.user_hints(self.context.name), contains( has_properties( user_id=user_row.id, extension='1002', argument='ghijkl', )))
def test_given_user_with_sccp_line_then_returns_user_hint(self): sccpline_row = self.add_sccpline(name='1001', context=self.context.name) user_row = self.add_user_sccp_and_func_key(sccpline_row.id, '1001') assert_that( hint_dao.user_hints(self.context.name), contains( has_properties( user_id=user_row.id, extension='1001', argument='SCCP/1001', )))
def test_given_user_with_sip_line_then_returns_user_hint(self): endpoint_sip_row = self.add_endpoint_sip(name='abcdef') user_row = self.add_user_sip_and_func_key(endpoint_sip_row.uuid) assert_that( hint_dao.user_hints(self.context.name), contains( has_properties( user_id=user_row.id, extension='1000', argument='PJSIP/abcdef', )), )
def test_given_two_users_with_sip_line_then_returns_only_two_hints(self): user1 = self.add_user_and_func_key( self.add_endpoint_sip(name='user1').uuid, '1001') user2 = self.add_user_and_func_key( self.add_endpoint_sip(name='user2').uuid, '1002') assert_that( hint_dao.user_hints(self.context.name), contains_inanyorder( has_properties(user_id=user1.id, extension='1001', argument='PJSIP/user1'), has_properties(user_id=user2.id, extension='1002', argument='PJSIP/user2'), ))
def test_given_user_when_querying_different_context_then_returns_empty_list(self): self.add_user_and_func_key(exten='1004') assert_that(hint_dao.user_hints('othercontext'), contains())
def test_given_user_with_hints_disabled_then_returns_empty_list(self): self.add_user_and_func_key(exten='1003', enablehint=0) assert_that(hint_dao.user_hints(self.context), contains())
def test_given_user_with_commented_line_then_returns_empty_list(self): self.add_user_and_func_key(exten='1002', commented=1) assert_that(hint_dao.user_hints(self.context), contains())
def test_given_user_when_querying_different_context_then_returns_empty_list( self): self.add_user_and_func_key(exten='1004') assert_that(hint_dao.user_hints('othercontext'), empty())
def test_given_user_with_hints_disabled_then_returns_empty_list(self): self.add_user_and_func_key(exten='1003', enablehint=0) assert_that(hint_dao.user_hints(self.context.name), empty())
def test_given_user_with_commented_line_then_returns_empty_list(self): self.add_user_and_func_key(exten='1002', commented=1) assert_that(hint_dao.user_hints(self.context.name), empty())