def test_string_operations(self): """Test string output and comparison behaviors""" # String comparisons expected = 'cisco' self.assertEqual(expected, self.vendor.normalized) self.assertEqual(expected, str(self.vendor)) self.assertEqual(expected, Vendor(expected)) # Title casing expected = 'Cisco' self.assertEqual(expected, self.vendor.title) self.assertEqual(expected.lower(), self.vendor.lower()) # Mfr equates to object self.assertEqual(self.mfr, self.vendor)
class TestVendorObject(unittest.TestCase): """Test Vendor object""" def setUp(self): self.mfr = 'CISCO SYSTEMS' self.vendor = Vendor(self.mfr) def test_creation(self): """Test creation of a Vendor instance""" expected = 'cisco' self.assertEqual(expected, self.vendor) def test_string_operations(self): """Test string output and comparison behaviors""" # String comparisons expected = 'cisco' self.assertEqual(expected, self.vendor.normalized) self.assertEqual(expected, str(self.vendor)) self.assertEqual(expected, Vendor(expected)) # Title casing expected = 'Cisco' self.assertEqual(expected, self.vendor.title) self.assertEqual(expected.lower(), self.vendor.lower()) # Mfr equates to object self.assertEqual(self.mfr, self.vendor) def test_membership(self): """Test membership w/ __eq__ and __contains__""" expected = 'cisco' self.assertTrue(expected in [self.vendor]) self.assertTrue(self.vendor in [self.vendor]) self.assertTrue(self.vendor in [expected]) self.assertFalse(self.vendor in ['juniper', 'foundry']) def test_determine_vendor(self): """Test determine_vendor() method""" expected = 'cisco' self.assertEqual(expected, self.vendor.determine_vendor(self.mfr))
def setUp(self): self.mfr = 'CISCO SYSTEMS' self.vendor = Vendor(self.mfr)