Exemplo n.º 1
0
    def test_given_no_main_user_then_no_associations_fixed(self,
                                                           line_extension_associate,
                                                           find_main_user_line,
                                                           fix_associations):
        line_extension = Mock(LineExtension)
        created_line_extension = line_extension_associate.return_value = Mock(LineExtension, line_id=1, extension_id=2)
        find_main_user_line.return_value = None

        result = ule_service.associate_line_extension(line_extension)

        assert_that(result, equal_to(created_line_extension))
        find_main_user_line.assert_called_once_with(created_line_extension.line_id)
        self.assertNotCalled(fix_associations)
Exemplo n.º 2
0
    def test_given_main_user_associated_then_associations_get_fixed(self,
                                                                    line_extension_associate,
                                                                    find_main_user_line,
                                                                    fix_associations):
        line_extension = Mock(LineExtension)
        created_line_extension = line_extension_associate.return_value = Mock(LineExtension, line_id=1, extension_id=2)
        main_user_line = find_main_user_line.return_value = Mock(UserLine, user_id=3, line_id=1)

        result = ule_service.associate_line_extension(line_extension)

        assert_that(result, equal_to(created_line_extension))
        find_main_user_line.assert_called_once_with(created_line_extension.line_id)
        fix_associations.assert_called_once_with(main_user_line)
Exemplo n.º 3
0
    def test_given_no_main_user_then_no_associations_fixed(
            self, line_extension_associate, find_main_user_line,
            fix_associations):
        line_extension = Mock(LineExtension)
        created_line_extension = line_extension_associate.return_value = Mock(
            LineExtension, line_id=1, extension_id=2)
        find_main_user_line.return_value = None

        result = ule_service.associate_line_extension(line_extension)

        assert_that(result, equal_to(created_line_extension))
        find_main_user_line.assert_called_once_with(
            created_line_extension.line_id)
        self.assertNotCalled(fix_associations)
Exemplo n.º 4
0
    def test_given_main_user_associated_then_associations_get_fixed(
            self, line_extension_associate, find_main_user_line,
            fix_associations):
        line_extension = Mock(LineExtension)
        created_line_extension = line_extension_associate.return_value = Mock(
            LineExtension, line_id=1, extension_id=2)
        main_user_line = find_main_user_line.return_value = Mock(UserLine,
                                                                 user_id=3,
                                                                 line_id=1)

        result = ule_service.associate_line_extension(line_extension)

        assert_that(result, equal_to(created_line_extension))
        find_main_user_line.assert_called_once_with(
            created_line_extension.line_id)
        fix_associations.assert_called_once_with(main_user_line)
Exemplo n.º 5
0
def _create_internal_association(line_extension):
    ule_services.associate_line_extension(line_extension)
Exemplo n.º 6
0
def _create_internal_association(line_extension):
    ule_services.associate_line_extension(line_extension)