test_prox_pulse.py 743 Bytes
import pytest
import math
import src.prox_pulse
from tests.helpers.naming import apply_names
from tests.helpers.pixel import Pixel
from tests.helpers.prox_pulse_data import PROX_PULSE_DATA

from tests.helpers.pixel import Pixel, fake_sleep

src.prox_pulse.time.sleep = fake_sleep


@pytest.mark.parametrize("prox_val, duration, set_color", apply_names(
    "prox_pulse", [False, True, True], PROX_PULSE_DATA))
def test_prox_pulse(prox_val, set_color, duration):
    pixel = Pixel(duration)
    src.prox_pulse.prox_pulse(pixel, set_color, prox_val)
    color, hist = pixel.look()
    assert [
        ((0, 0, 0), 0),
        (set_color, 1),
        ((0, 0, 0), 2),
    ] == hist, "the prox_pulse function should have pulsed the provided color"