Пример #1
0
def test_set_preference_value_MatrixPreferenceDataModel():
    #Add
    model = MatrixPreferenceDataModel(movies)
    model.set_preference('Maria Gabriela', 'Superman Returns', 2.0)
    assert_equals(2.0, model.preference_value('Maria Gabriela', 'Superman Returns'))
    #Edit
    model = MatrixPreferenceDataModel(movies)
    model.set_preference('Marcel Caraciolo', 'Superman Returns', 1.0)
    assert_equals(1.0, model.preference_value('Marcel Caraciolo', 'Superman Returns'))
    #invalid
    assert_raises(UserNotFoundError, model.set_preference, 'Carlos', 'Superman Returns', 2.0)
Пример #2
0
def test_remove_preference_value_MatrixPreferenceDataModel():
    model = MatrixPreferenceDataModel(movies)
    model.remove_preference('Maria Gabriela', 'Superman Returns')
    assert_array_equal(np.nan, model.preference_value('Maria Gabriela', 'Superman Returns'))
    assert_raises(ItemNotFoundError, model.remove_preference, 'Marcel Caraciolo', 'Indiana Jones')
Пример #3
0
def test_preference_value__invalid_MatrixPreferenceDataModel():
    model = MatrixPreferenceDataModel(movies)
    assert_raises(UserNotFoundError, model.preference_value, 'Flavia', 'Superman Returns')
    assert_raises(ItemNotFoundError, model.preference_value, 'Marcel Caraciolo', 'Back to the future')
    assert_array_equal(np.nan, model.preference_value('Maria Gabriela', 'The Night Listener'))
Пример #4
0
def test_preference_value_MatrixPreferenceDataModel():
    model = MatrixPreferenceDataModel(movies)
    assert_equals(3.5, model.preference_value('Marcel Caraciolo', 'Superman Returns'))