Skip to content

Commit

Permalink
Added Primary color setting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
speratus committed Sep 16, 2019
1 parent 7988dc6 commit 150d3fd
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from unittest import mock

#import blinkt
import sys
sys.modules['blinkt'] = mock.MagicMock()

from blinkter import BlinktBoard, Pixel, LED

Expand All @@ -45,13 +47,51 @@ def SetUp(self):
# mock_show.assert_called()
# mock_release.assert_called()


class ColorSettingTests(unittest.TestCase):
def SetUp(self):
def setUp(self):
self.board = BlinktBoard()
self.pixel = self.board.get_pixe(0)
self.pixel = self.board.get_pixel(0)

def test_correct_pixel(self):
pass
self.assertEqual(self.pixel.addr, 0, msg='The Pixel address was incorrect!')

@mock.patch.object(Pixel, 'draw', autospec=True)
def test_black(self, mock_draw):
self.pixel.set_color(14, 14, 14)
mock_draw.assert_called()
self.pixel.black()
black = [0, 0, 0]
self.assertEqual(self.pixel.rgb, black, msg=f'pixel.black() failed. {self.pixel.rgb} did not equal {black}.')
mock_draw.assert_called()

@mock.patch.object(Pixel, 'draw', autospec=True)
def test_white(self, mock_draw):
self.pixel.white()
mock_draw.assert_called()
white = [255,255,255]
self.assertEqual(self.pixel.rgb, white, msg=f'pixel.white() failed. {self.pixel.rgb} does not equal {white}.')

@mock.patch.object(Pixel, 'draw', autospec=True)
def test_red(self, mock_draw):
self.pixel.red()
mock_draw.assert_called()
red = [255, 0, 0]
self.assertEqual(self.pixel.rgb, red, msg=f'pixel.red() failed. {self.pixel.rgb} does not equal {red}.')

@mock.patch.object(Pixel, 'draw', autospec=True)
def test_green(self, mock_draw):
self.pixel.green()
mock_draw.assert_called()
green = [0, 255, 0]
self.assertEqual(self.pixel.rgb, green, msg=f'pixel.red() failed. {self.pixel.rgb} does not equal {green}.')

@mock.patch.object(Pixel, 'draw', autospec=True)
def test_blue(self, mock_draw):
self.pixel.blue()
mock_draw.assert_called()
blue = [0, 0, 255]
self.assertEqual(self.pixel.rgb, blue, msg=f'pixel.red() failed. {self.pixel.rgb} does not equal {blue}.')

if __name__ == '__main__':
unittest.main()

0 comments on commit 150d3fd

Please sign in to comment.