def test_parameterDict_setter_emptyStr_none(self): """Test the parameterDict setter when passed {"": None}.""" unit = GcodeParser() unit.parse("G28 X") self.assertEqual( unit.parameterDict, OrderedDict([("X", None), ("", "X")]), "The parameterDict should be the expected value" ) unit.parameterDict = {"": None} self.assertIsNone(unit.parameters, "The parameters should be None") self.assertIsNone(unit.parameterDict, "The parameterDict should be None")
def test_parameterDict_setter_label_value(self): """Test the parameterDict setter when passed a label and non empty value.""" unit = GcodeParser() unit.parse("G28 X") self.assertEqual( unit.parameterDict, OrderedDict([("X", None), ("", "X")]), "The parameterDict should be the expected value" ) unit.parameterDict = {"A": 12} self.assertEqual(unit.parameters, "A12", "The parameters should be 'A12'") self.assertEqual( unit.parameterDict, OrderedDict([("A", 12)]), "The parameterDict should be the expected value" )
def test_parameterDict_setter_label_none(self): """Test the parameterDict setter when passed a label with a value of None.""" unit = GcodeParser() unit.parse("G28 X") self.assertEqual( unit.parameterDict, OrderedDict([("X", None), ("", "X")]), "The parameterDict should be the expected value" ) unit.parameterDict = {"A": None} self.assertEqual(unit.parameters, "A", "The parameters should be 'A'") self.assertEqual( unit.parameterDict, OrderedDict([("A", None), ("", "A")]), "The parameterDict should be the expected value" )
def test_parameterDict_setter_noLabel_falsyValue(self): """Test the parameterDict setter when passed {"": "0"}.""" unit = GcodeParser() unit.parse("G28 X") self.assertEqual( unit.parameterDict, OrderedDict([("X", None), ("", "X")]), "The parameterDict should be the expected value" ) unit.parameterDict = {"": "0"} self.assertEqual(unit.parameters, "0", "The parameters should be '0'") self.assertEqual( unit.parameterDict, OrderedDict([("", "0")]), "The parameterDict should be the expected value" )