def test__clear(self, serial_mock): """ Test the private clear function of DisplayController """ serial = MagicMock() serial.write = MagicMock() dc = DisplayController(0, 9600) dc._connection = serial dc._clear() serial.write.assert_called_once_with('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) ])