def setUp(self): super(ConfigurableComponentTestCase, self).setUp() self.config = {"a":"b", "c":"d", "e":["f", "g", 123]} self.component = ConfigurableComponent()
class ConfigurableComponentTestCase(unittest.TestCase): def setUp(self): super(ConfigurableComponentTestCase, self).setUp() self.config = {"a":"b", "c":"d", "e":["f", "g", 123]} self.component = ConfigurableComponent() def test_configure_empty(self): self.component.configure({}) self.assertEqual({}, self.component.configuration) def test_configure_non_empty(self): self.component.configure(self.config) self.assertEqual(self.config, self.component.configuration) def test_configure_non_dict_error(self): with self.assertRaises(ConfigError): self.component.configure(123) def test_check_configuration(self): self.component.configure(self.config) self.component.check_configuration(["a", "c", "e"]) self.assertTrue(True) def test_check_configuration_error(self): self.component.configure(self.config) with self.assertRaises(ConfigError): self.component.check_configuration(["a", "c", "expectfail"])