class SettingTest(unittest.TestCase): def setUp(self): # Called before the first testfunction is executed self._setting = Setting("TestSetting", 10, "int") self._machine_settings = MachineSettings() category = SettingsCategory("TestCategory") #category.addSetting(self._setting) self._machine_settings.addSettingsCategory(category) self._machine_settings.loadSettingsFromFile( "tests/Settings/SettingData.json") def tearDown(self): # Called after the last testfunction was executed pass def test_getSettingByKey(self): self.assertEqual( self._machine_settings.getSettingByKey("TestSetting").getType(), self._setting.getType()) self.assertEqual( self._machine_settings.getSettingByKey( "TestSetting").getDefaultValue(), self._setting.getDefaultValue()) pass def test_category(self): pass def test_validatorTest(self): pass
def test_fillByDict(self, data): setting = Setting(self._machine_manager, "test", self._catalog) setting.fillByDict(data) assert setting.getType() == data["type"] assert setting.getDefaultValue() == data["default"] assert setting.getLabel() == data["label"] assert setting.getDescription() == data["description"] assert setting.isVisible()
def test_construct(self): # Most basic construction, only required arguments. setting = Setting(self._machine_manager, "test", self._catalog) # This check is mostly to see if the object was constructed properly assert isinstance(setting, Setting) assert setting.getKey() == "test" # Construct with keyword arguments setting = Setting( self._machine_manager, "test", self._catalog, label = "Test Setting", type = "string", ) assert isinstance(setting, Setting) assert setting.getKey() == "test" assert setting.getLabel() == "Test Setting" assert setting.getType() == "string"
def test_fillByDict(self): setting = Setting(self._machine_manager, "test", self._catalog) data = { "type": "int", "default": 4, "label": "Test Setting", "description": "A Test Setting", "unit": "furlongs per fortnight", "visible": True } setting.fillByDict(data) self.assertEqual("int", setting.getType()) self.assertEqual(4, setting.getDefaultValue()) self.assertEqual("Test Setting", setting.getLabel()) self.assertEqual("A Test Setting", setting.getDescription()) self.assertEqual("furlongs per fortnight", setting.getUnit()) self.assertTrue(setting.isVisible())
def test_construct(self): # Most basic construction, only required arguments. setting = Setting(self._machine_manager, "test", self._catalog) # This check is mostly to see if the object was constructed properly assert isinstance(setting, Setting) assert setting.getKey() == "test" # Construct with keyword arguments setting = Setting( self._machine_manager, "test", self._catalog, label="Test Setting", type="string", ) assert isinstance(setting, Setting) assert setting.getKey() == "test" assert setting.getLabel() == "Test Setting" assert setting.getType() == "string"
class SettingTest(unittest.TestCase): def setUp(self): # Called before the first testfunction is executed self._setting = Setting("TestSetting",10,"int") self._machine_settings = MachineSettings() category = SettingsCategory("TestCategory") #category.addSetting(self._setting) self._machine_settings.addSettingsCategory(category) self._machine_settings.loadSettingsFromFile("tests/Settings/SettingData.json") def tearDown(self): # Called after the last testfunction was executed pass def test_getSettingByKey(self): self.assertEqual(self._machine_settings.getSettingByKey("TestSetting").getType(), self._setting.getType()) self.assertEqual(self._machine_settings.getSettingByKey("TestSetting").getDefaultValue(), self._setting.getDefaultValue()) pass def test_category(self): pass def test_validatorTest(self): pass