def test_validate_noLineNumber_noChecksum(self): # pylint: disable=no-self-use """Test validate when no lineNumber or checksum value is present.""" unit = GcodeParser() unit.lineNumber = None unit._checksum = None # pylint: disable=protected-access unit.validate()
def test_validate_checksum_ok(self): # pylint: disable=no-self-use """Test validate when a lineNumber and checksum are present, and the checksum is valid.""" unit = GcodeParser() unit.text = "G28" unit.lineNumber = 10 unit._checksum = 77 # pylint: disable=protected-access unit.validate()
def test_validate_noLineNumber_checksum(self): """Test validate when a no lineNumber is present but a checksum value is.""" unit = GcodeParser() unit._checksum = 10 # pylint: disable=protected-access unit.lineNumber = None with self.assertRaises(ValueError): unit.validate()
def test_validate_lineNumber_noChecksum(self): """Test validate when a lineNumber is present without a checksum value.""" unit = GcodeParser() unit.lineNumber = 10 unit._checksum = None # pylint: disable=protected-access with self.assertRaises(ValueError): unit.validate()
def test_validate_checksum_mismatch(self): """Test validate when a lineNumber and checksum are present, but the checksum is invalid.""" unit = GcodeParser() unit.text = "G28" # Checksum should be 77 unit.lineNumber = 10 unit._checksum = 20 # pylint: disable=protected-access with self.assertRaises(ValueError): unit.validate()