Ejemplo n.º 1
0
def test_rotation():
    """Test rotation API change and alias."""
    sys.modules['spidev'] = mock.MagicMock()
    import unicornhathd
    unicornhathd.setup()

    unicornhathd.set_rotation(90)
    assert unicornhathd.set_rotation == unicornhathd.rotation
Ejemplo n.º 2
0
def test_brightness():
    """Test brightness API change and alias."""
    sys.modules['spidev'] = mock.MagicMock()
    import unicornhathd
    unicornhathd.setup()

    unicornhathd.set_brightness(0.5)
    assert unicornhathd.set_brightness == unicornhathd.brightness
Ejemplo n.º 3
0
def test_invalid_text_colour():
    """Test valid text colour."""
    sys.modules['spidev'] = mock.MagicMock()
    import unicornhathd
    unicornhathd.setup()

    with pytest.raises(ValueError):
        unicornhathd.set_pixel(0, 0, "Octarine")
Ejemplo n.º 4
0
def test_valid_text_colour():
    """Test valid text colour."""
    sys.modules['spidev'] = mock.MagicMock()
    import unicornhathd
    unicornhathd.setup()

    unicornhathd.set_pixel(0, 0, "Teal")

    assert tuple(unicornhathd._buf[0, 0]) == unicornhathd.COLORS['teal']
Ejemplo n.º 5
0
def test_tuple_colour():
    """Test valid text colour."""
    sys.modules['spidev'] = mock.MagicMock()
    import unicornhathd
    unicornhathd.setup()

    unicornhathd.set_pixel(0, 0, (255, 0, 0))

    assert tuple(unicornhathd._buf[0, 0]) == (255, 0, 0)
Ejemplo n.º 6
0
def test_setup():
    """Test that the library sets up correctly with numpy and spidev."""
    sys.modules['spidev'] = mock.MagicMock()
    import unicornhathd
    unicornhathd.setup()