Esempio n. 1
0
def test_random_palette_rgb_mode_many_colours_called_that_many_times(
        mocked_method):
    colours.random_palette(100, mode="RGB")
    expected_call = 100
    assert (
        mocked_method.call_count == expected_call
    ), f"random_saturation was called {mocked_method.call_count} times, should have been {expected_call}"
Esempio n. 2
0
def test_random_palette_default_generator_many_colours_called_that_many_times(
        mocked_method):
    colours.random_palette(100)
    expected_call = 100
    assert (
        mocked_method.call_count == expected_call
    ), f"random_saturation was called {mocked_method.call_count} times, should have been {expected_call}"
Esempio n. 3
0
def test_random_palette_default_generator_with_one_colour_expected_result():
    assert len(colours.random_palette(1)) == 1
Esempio n. 4
0
def test_random_palette_default_generator_with_one_colour_called_once(
        mocked_method):
    colours.random_palette(1)
    mocked_method.assert_called_once_with()
Esempio n. 5
0
def test_random_palette_default_generator_zero_colours_expected_result():
    with pytest.raises(colours.ColourError):
        colours.random_palette(0)
Esempio n. 6
0
def test_random_palette_rgb_mode_with_many_colours_expected_result():
    assert len(colours.random_palette(11, mode="RGB")) == 11
Esempio n. 7
0
def test_random_palette_rgb_mode_with_one_colour_called_once(mocked_method):
    colours.random_palette(1, mode="RGB")
    mocked_method.assert_called_once_with()
Esempio n. 8
0
def test_random_palette_l_mode_with_one_colour_expected_result():
    assert len(colours.random_palette(1, mode="L")) == 1
Esempio n. 9
0
def test_random_palette_rgb_mode_zero_colours_expected_result():

    with pytest.raises(colours.ColourError):
        colours.random_palette(0)