Exemple #1
0
def associate(user_line):
    validator.validate_association(user_line)

    _adjust_optional_parameters(user_line)
    ule_service.associate_user_line(user_line)

    notifier.associated(user_line)
    return user_line
Exemple #2
0
def associate(user_line):
    validator.validate_association(user_line)

    _adjust_optional_parameters(user_line)
    ule_service.associate_user_line(user_line)

    notifier.associated(user_line)
    return user_line
Exemple #3
0
    def test_given_user_and_line_associated_then_associations_get_fixed(self,
                                                                        user_line_associate,
                                                                        find_main_user_line,
                                                                        fix_associations):
        user_line = Mock(UserLine)
        created_user_line = user_line_associate.return_value = Mock(UserLine, user_id=1, line_id=2)
        main_user_line = find_main_user_line.return_value = Mock(UserLine, user_id=3, line_id=2)

        result = ule_service.associate_user_line(user_line)

        assert_that(result, equal_to(created_user_line))
        find_main_user_line.assert_called_once_with(created_user_line.line_id)
        fix_associations.assert_called_once_with(main_user_line)
Exemple #4
0
    def test_given_user_and_line_associated_then_associations_get_fixed(
            self, user_line_associate, find_main_user_line, fix_associations):
        user_line = Mock(UserLine)
        created_user_line = user_line_associate.return_value = Mock(UserLine,
                                                                    user_id=1,
                                                                    line_id=2)
        main_user_line = find_main_user_line.return_value = Mock(UserLine,
                                                                 user_id=3,
                                                                 line_id=2)

        result = ule_service.associate_user_line(user_line)

        assert_that(result, equal_to(created_user_line))
        find_main_user_line.assert_called_once_with(created_user_line.line_id)
        fix_associations.assert_called_once_with(main_user_line)