コード例 #1
0
def test_recommendations(mock_s3_json_downloader):
    # Test that the legacy recommender returns the correct addons from the json loaded.
    r = LegacyRecommender()

    limit = 10
    profile_with_legacy = dict(
        client_id="test-client-id",
        disabled_addons_ids=["{test_guid_1}",
                             "test_guid_8"],
        locale="it-IT"
    )

    recommendations = r.recommend(profile_with_legacy, limit)

    # Make sure the structure of the recommendations is correct and that we recommended the the right addons.
    assert isinstance(recommendations, list)

    # Make sure that the reported addons are the ones from the fake data.
    assert "test_guid_2" in recommendations
    assert "test_guid_3" in recommendations
コード例 #2
0
def test_recommendations(mock_s3_json_downloader):
    """Test that the legacy recommender returns the correct addons from the json loaded.

    The JSON output for this recommender should be a list of 2-tuples
    of (GUID, weight).
    """
    r = LegacyRecommender()

    profile_with_many_legacy = dict(
        client_id="test-client-id",
        disabled_addons_ids=["guid-01", "guid-05", "guid-12"],
        locale="it-IT")

    recommendations = r.recommend(profile_with_many_legacy, LIMIT)

    assert len(recommendations) == LIMIT
    assert ("guid-13-1", 1) in recommendations
    assert ("guid-21-9", 1) not in recommendations
    assert ("guid-22-10", 1) not in recommendations
    assert ("guid-21-9", 1) not in recommendations