def test_same_article():
    arts = [
        Article(url='dummy.com', body="Canada and USA.", title="Canada and USA.")
    ]
    states = [
        "yes"
    ]
    algo = CosineAlgorithm()
    algo.train(arts, states)
    assert math.ceil(algo.score_single_article(arts[0])) == math.ceil(ScoreMapper().map_score("yes"))
def test_different_article():
    arts = [
        Article(url='dummy.com', body="Canada and USA.", title="Canada and USA.")
    ]
    states = [
        "yes"
    ]
    algo = CosineAlgorithm()
    algo.train(arts, states)

    test_art = Article(url='dummy.com', body="Trinidad and Tobago.", title="Trinidad and Tobago.")
    assert math.floor(algo.score_single_article(test_art)) == 0
def test_existing_keywords():
    arts = [
        Article(url='dummy.com', body="Canada.", title="Canada."),
        Article(url='dummy.com', body="USA.", title="USA."),
        Article(url='dummy.com', body="Mexico.", title="Mexico.")
    ]
    states = [
        "yes",
        "read",
        "no"
    ]
    algo = CosineAlgorithm()
    algo.train(arts, states)

    test_art = Article(url='dummy.com', body="USA.", title="USA.")
    assert math.floor(algo.score([test_art])[0]) == math.ceil(ScoreMapper().map_score("read"))