def test__set(self, serial_mock): """ Test the private set function of DisplayController """ serial = MagicMock() serial.write = MagicMock() dc = DisplayController(0, 9600) dc._connection = serial dc._set(0, 0) serial.write.assert_has_calls([ call('1'), call('0'), call('0') ])
def test_output_pattern(self, serial_mock): """ This method ensures the prototype display controller can correctly output a pattern to the DisplayController. """ dc = DisplayController(0, 9600) dc._connection = MagicMock() dc._clear = MagicMock() dc._set = MagicMock() dc._draw = MagicMock() dc.output_pattern("-*-\n-*-\n-*-") # Ensure clear and draw were called once dc._clear.assert_called_once_with() dc._draw.assert_called_once_with() # Test the set calls dc._set.assert_has_calls([ call(1, 0), call(1, 1), call(1, 2) ])