コード例 #1
0
 def test_CommandOnlyWhitespaceBefore(self):
     """Ensure that gcode with a command only (no parameters or coments) preceeded by whitespace returns the
     command, a null comment, and no parameters """
     gcode_parts = GcodeParts("		THECOMMANDWITHTABSANDSPACES")
     self.assertTrue(gcode_parts.Command == "THECOMMANDWITHTABSANDSPACES")
     self.assertTrue(gcode_parts.Comment is None)
     self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #2
0
 def test_SemicolonOnly(self):
     """If only a semicolon is given, the command should be None and the comment should be the empty string,
     with no parameters """
     gcode_parts = GcodeParts(";")
     self.assertTrue(gcode_parts.Command is None)
     self.assertTrue(gcode_parts.Comment == "")
     self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #3
0
 def test_CommandOnly(self):
     """Ensure that gcode with a command only (no parameters or coments) returns the command, a null comment,
     and no parameters """
     gcode_parts = GcodeParts("THECOMMAND")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment is None)
     self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #4
0
 def test_CommentOnly(self):
     """Ensure that gcode consisting of only a semicolon and a comment contain a null command, the comment,
     and no parameters """
     gcode_parts = GcodeParts(";Here is a comment")
     self.assertTrue(gcode_parts.Command is None)
     self.assertTrue(gcode_parts.Comment == "Here is a comment")
     self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #5
0
 def test_gcode(self):
     """Test a command, make sure the original gcode is stored properly."""
     gcode_parts = GcodeParts(
         "	THECOMMAND		param1   param2  param3 param4		;   The Comment")
     self.assertTrue(
         gcode_parts.Gcode ==
         "	THECOMMAND		param1   param2  param3 param4		;   The Comment")
コード例 #6
0
    def test_NullCommand(self):
        """Using None for your gcode will result in both the comand and the comment being None, with no parameters"""

        gcode_parts = GcodeParts(None)
        self.assertTrue(gcode_parts.Command is None)
        self.assertTrue(gcode_parts.Comment is None)
        self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #7
0
 def test_CommandAndCommentWhitespace(self):
     """Ensure that gcode with a command, a comment, and whitespace around both the command and comment returns
     the trimmed command and the untrimmed comment with no parameters. """
     gcode_parts = GcodeParts("	THECOMMAND	;	The Comment		")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment == "	The Comment		")
     self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #8
0
 def test_CommandAndParameters_single(self):
     """Test a command and a single parameter without comments, make sure they are returned and that the comment
     is None. """
     gcode_parts = GcodeParts("THECOMMAND param1")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment is None)
     self.assertTrue(len(gcode_parts.Parameters) == 1)
     self.assertTrue(gcode_parts.Parameters[0] == "param1")
コード例 #9
0
 def test_WhitespaceAndComment(self):
     """Ensure that gcode consisting of whitespace,a semicolon and a comment contain a null command, the comment,
     and no parameters """
     gcode_parts = GcodeParts(
         "			;Here is a comment preceeded by spaces and tabs.")
     self.assertTrue(gcode_parts.Command is None)
     self.assertTrue(gcode_parts.Comment ==
                     "Here is a comment preceeded by spaces and tabs.")
     self.assertTrue(len(gcode_parts.Parameters) == 0)
コード例 #10
0
 def test_CommandParametersAndComment(self):
     """Test a command, 4 parameters and a comment, make sure they are all returned."""
     gcode_parts = GcodeParts(
         "THECOMMAND param1 param2 param3 param4;The Comment")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment == "The Comment")
     self.assertTrue(len(gcode_parts.Parameters) == 4)
     self.assertTrue(gcode_parts.Parameters[0] == "param1")
     self.assertTrue(gcode_parts.Parameters[1] == "param2")
     self.assertTrue(gcode_parts.Parameters[2] == "param3")
     self.assertTrue(gcode_parts.Parameters[3] == "param4")
コード例 #11
0
 def test_CommandAndParameters_multiple(self):
     """Test a command and 4 parameters without comments, make sure they are returned and that the comment is
     None. """
     gcode_parts = GcodeParts("THECOMMAND param1 param2 param3 param4")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment is None)
     self.assertTrue(len(gcode_parts.Parameters) == 4)
     self.assertTrue(gcode_parts.Parameters[0] == "param1")
     self.assertTrue(gcode_parts.Parameters[1] == "param2")
     self.assertTrue(gcode_parts.Parameters[2] == "param3")
     self.assertTrue(gcode_parts.Parameters[3] == "param4")
コード例 #12
0
 def test_CommandAndParametersWhitespace(self):
     """Test a command and 4 parameters without comments including extra whitespace.  Make sure they are returned
     and trimmed, and that the comment is None. """
     gcode_parts = GcodeParts(
         "	 THECOMMAND		param1  param2 param3	param4   ")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment is None)
     self.assertTrue(len(gcode_parts.Parameters) == 4)
     self.assertTrue(gcode_parts.Parameters[0] == "param1")
     self.assertTrue(gcode_parts.Parameters[1] == "param2")
     self.assertTrue(gcode_parts.Parameters[2] == "param3")
     self.assertTrue(gcode_parts.Parameters[3] == "param4")
コード例 #13
0
 def test_CommandAndComment(self):
     """Ensure that gcode with a command and a comment return both the command, the comment, and no parameters."""
     gcode_parts = GcodeParts("THECOMMAND;The Comment")
     self.assertTrue(gcode_parts.Command == "THECOMMAND")
     self.assertTrue(gcode_parts.Comment == "The Comment")
     self.assertTrue(len(gcode_parts.Parameters) == 0)