예제 #1
0
def test_euromil_grid_init_ko_duplicates():
    """ __init__ test Ko out of bonds values """
    with pytest.raises(ValueError):
        _ = Grid([1, 1, 2, 3, 4], [1, 2])

    with pytest.raises(ValueError):
        _ = Grid(list(range(1, 6)), [2, 2, 3])
예제 #2
0
def test_euromil_grid_init_ko_number_of_values():
    """ __init__ test Ko wrong number of values """
    with pytest.raises(ValueError):
        _ = Grid(list(range(1, 12)), [1, 2])

    with pytest.raises(ValueError):
        _ = Grid(list(range(1, 11)), list(range(1, 14)))
예제 #3
0
def test_euromil_grid_init_ko_outofbounds_of_values():
    """ __init__ test Ko out of bonds values """
    with pytest.raises(ValueError):
        _ = Grid(list(range(45, 55)), [1, 2])

    with pytest.raises(ValueError):
        _ = Grid(list(range(1, 6)), [1, 13])
예제 #4
0
def test_euromil_grid_init_ko_type_of_values():
    """ __init__ test Ko wrong number of values """
    with pytest.raises(ValueError):
        _ = Grid(list(range(1, 11)), ["1", "2"])

    with pytest.raises(ValueError):
        _ = Grid([str(x) for x in range(1, 5)], [1, 2])
예제 #5
0
def test_euromil_grid_init_ko_basic():
    """ __init__ test Ko wrong params """
    with pytest.raises(ValueError):
        test_grid = Grid("", [])

    with pytest.raises(ValueError):
        test_grid = Grid([], "")
예제 #6
0
def test_euromil_grid_evaluate_grid_ok_no_results():
    """ grid_evaluate ok without result"""
    result = EuroResult(date(2018, 1, 1), [1, 2, 3, 4, 5], [1, 2])
    test_grid = Grid(list(range(11, 16)), list(range(10, 13)), star_plus=False)

    test_numbers, test_stars = test_grid.evaluate_grid(result)

    assert test_numbers == []
    assert test_stars == []
예제 #7
0
def test_euromil_play_append_ko(play):
    """ append ko because of dates """
    with pytest.raises(ValueError):
        play.append(None)

    with pytest.raises(ValueError):
        play.append(Grid([1, 2, 3, 4, 5], [1, 2]), start="", end=date(2018, 1, 1))

    with pytest.raises(ValueError):
        play.append(Grid([1, 2, 3, 4, 5], [1, 2]), start=date(2018, 1, 1), end="")
예제 #8
0
def test_euromil_grid_init_ok_basic():
    """ __init__ test Ok simple cases """
    test_grid = Grid(list(range(1, 6)), list(range(1, 3)), star_plus=True)
    assert test_grid.numbers == [1, 2, 3, 4, 5]
    assert test_grid.stars == [1, 2]
    assert test_grid.start_plus

    test_grid = Grid(list(range(21, 31)), list(range(1, 12)))
    assert test_grid.numbers == [x for x in range(21, 31)]
    assert test_grid.stars == [x for x in range(1, 12)]
    assert not test_grid.start_plus
예제 #9
0
def test_euromil_play_dunder(play):
    """ dunder methods test test"""
    # test init
    assert play.plays_list == []

    # bool
    assert not play

    # test len
    assert len(play) == 0
    play.append(
        Grid([1, 2, 3, 4, 5], [1, 2]),
        start=date(2018, 1, 1),
        end=date(2018, 1, 1),
        friday=True,
    )
    assert len(play) == 1

    # test repr
    assert (
        str(play)
        == "Plays(1 play(s): [Play(grid=Grid(Numbers:[1, 2, 3, 4, 5], Stars:[1, 2], Star Plus:False), start=datetime.date(2018, 1, 1), end=datetime.date(2018, 1, 1), tuesday=False, friday=True)])"
    )

    # bool
    assert play
예제 #10
0
def test_euromil_play_summary_multiple_dates():
    """ play_summary tests multiple date """
    play = EuroPlay(
        Grid([1, 2, 3, 4, 5], [2, 12]),
        date(2018, 10, 16),
        date(2018, 10, 23),
        True,
        False,
    )
    summary = Plays.play_summary(play)

    assert len(summary) == 2

    summary0 = summary[0]
    assert summary0["date"] == date(2018, 10, 23)
    assert summary0["numbers"] == [1, 2, 5]
    assert summary0["stars"] == [2, 12]
    assert summary0["ranking"] == 6
    assert summary0["ranking_star_plus"] == 4

    summary1 = summary[1]
    assert summary1["date"] == date(2018, 10, 16)
    assert summary1["numbers"] == []
    assert summary1["stars"] == []
    assert summary1["ranking"] == 0
    assert summary1["ranking_star_plus"] == 0

    summary = Plays.play_summary(play, only_wins=True)
    assert len(summary) == 1
예제 #11
0
def test_euromil_play_iter(play):
    play.append(
        Grid([1, 2, 3, 4, 5], [1, 2]),
        start=date(2018, 1, 1),
        end=date(2018, 1, 1),
        friday=True,
    )
    play.append(
        Grid([11, 12, 13, 14, 15], [11, 12]),
        start=date(2018, 1, 1),
        end=date(2018, 1, 1),
        friday=True,
    )

    nb = 0
    for a_play in play:
        assert isinstance(a_play, EuroPlay)
        nb += 1

    assert nb == 2
예제 #12
0
def test_euromil_game_summary():
    """ game_summary tests """
    summary = Plays._game_summary(
        Grid([1, 2, 3, 4, 5], [1, 2]),
        euro_results(date(2018, 10, 23), date(2018, 10, 23))[0],
    )

    assert summary["date"] == date(2018, 10, 23)
    assert summary["numbers"] == [1, 2, 5]
    assert summary["stars"] == [2]
    assert summary["ranking"] == 9
    assert summary["ranking_star_plus"] == 6
예제 #13
0
def test_euromil_play_append_ok(play):
    """ append ok """
    play.append(
        Grid([1, 2, 3, 4, 5], [1, 2]),
        start=date(2018, 1, 1),
        end=date(2018, 1, 1),
        friday=True,
    )

    assert play.plays_list[0].grid.stars == [1, 2]
    assert play.plays_list[0].start == date(2018, 1, 1)
    assert play.plays_list[0].end == date(2018, 1, 1)
    assert not play.plays_list[0].tuesday
    assert play.plays_list[0].friday
예제 #14
0
def test_euromil_play_summary_one_date():
    """ play_summary tests only 1 date """
    play = EuroPlay(
        Grid([1, 2, 3, 4, 5], [1, 2]),
        date(2018, 10, 23),
        date(2018, 10, 23),
        True,
        True,
    )

    summary = Plays.play_summary(play)[0]

    assert summary["date"] == date(2018, 10, 23)
    assert summary["numbers"] == [1, 2, 5]
    assert summary["stars"] == [2]
    assert summary["ranking"] == 9
    assert summary["ranking_star_plus"] == 6
예제 #15
0
def test_euromil_grid_evaluate_grid_ok_results():
    """ grid_evaluate ok with results"""
    result = EuroResult(date(2018, 1, 1), [1, 2, 3, 4, 5], [1, 2])
    test_grid = Grid(list(range(1, 6)), list(range(1, 3)), star_plus=True)
    test_numbers, test_stars = test_grid.evaluate_grid(result)

    assert test_numbers == [1, 2, 3, 4, 5]
    assert test_stars == [1, 2]

    test_grid = Grid(list(range(5, 13)), list(range(2, 4)), star_plus=True)
    test_numbers, test_stars = test_grid.evaluate_grid(result)

    assert test_numbers == [5]
    assert test_stars == [2]
예제 #16
0
def test_euromil_repr():
    """ __repr__ test"""
    test_grid = Grid(list(range(1, 6)), list(range(1, 3)))
    assert (str(test_grid) ==
            "Grid(Numbers:[1, 2, 3, 4, 5], Stars:[1, 2], Star Plus:False)")
예제 #17
0
def test_euromil_grid_evaluate_grid_ko():
    """ grid_evaluate ko """
    with pytest.raises(ValueError):
        test_grid = Grid(list(range(1, 6)), list(range(1, 3)), star_plus=True)
        _, _ = test_grid.evaluate_grid("")