class Test_DiagnosticsClient(unittest.TestCase): def setUp(self): self.dc = DiagnosticsClient("Michaels iPhone", "ipod", "/diagnostics") def test_constructor(self): self.assertIsInstance(self.dc, DiagnosticsClient) def test_clientType(self): self.assertEqual("ipod", self.dc.type) def test_setClientType(self): self.dc.client_type = "ipad" self.assertEqual("ipad", self.dc.type) def test_clientType_unknownType(self): with self.assertRaises(ValueError) as cm: self.dc.type = "android" self.assertEqual(cm.exception.message, "Client type android is not supported") def test_clientTopic(self): self.assertEqual("/diagnostics", self.dc.topic) def test_setClientTopic(self): self.dc.client_topic = "/diagnostics_agg" self.assertEqual("/diagnostics_agg", self.dc.topic) def test_setClientTopic_unknownTopic(self): with self.assertRaises(ValueError) as cm: self.dc.topic = "notatopic" self.assertEqual(cm.exception.message, "Topic notatopic is not supported") def test_clear_display(self): to_display = self.dc.clear_diagnostics_display() self.assertEqual(len(to_display), 10*4 + 1)
def setUp(self): self.dc = DiagnosticsClient("Michaels iPhone", "ipod", "/diagnostics")