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