コード例 #1
0
    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()
コード例 #2
0
    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()
コード例 #3
0
    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()
コード例 #4
0
    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()
コード例 #5
0
    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()
コード例 #6
0
    def test_lineNumber_setter_none(self):
        """Test the lineNumber setter assigning None."""
        unit = GcodeParser()
        unit.parse("N1234 G0")
        self.assertEqual(unit.lineNumber, 1234, "The lineNumber should be 1234.")

        unit.lineNumber = None

        self.assertIsNone(unit.lineNumber, "The lineNumber should be None.")
        self.assertEqual(unit.gcode, "G0", "The gcode should be 'G0'.")
        self.assertEqual(unit.commandString, "G0", "The commandString should be 'G0'.")