class PhonebookTestCase(unittest.TestCase):
    def setUp(self):
        self.contact = Contact()

    def test_add_contact(self):
        result = self.contact.add_contact("pete", "0712351423")
        self.assertEqual(result["info"], "Contact added")

    def test_add_contact_with_contact_greater_than_10_digits(self):
        result = self.contact.add_contact("anne", "3414444444444414")
        self.assertNotEqual(result["info"], "Contact added")
        self.assertEqual(result["info"],
                         "Re-enter the contact, contact must be 10 digits")

    def test_delete_contact(self):
        result = self.contact.delete_contact("jane", "1873137103")
        self.assertEqual(result["info"], "Contact deleted")

    def test_update_contact(self):
        result = self.contact.update_contact("jane", "34251617181",
                                             "5463727828")
        self.assertEqual(result, "My new contact is 5463727828")

    def test_view_contacts(self):
        result = self.contact.view_contacts("shaz", "2151853811")
        self.assertEqual(result, "Contact for shaz is 2151853811")
예제 #2
0
class TestContact(unittest.TestCase):
	def setUp(self):
		self.contact = Contact()

	def test_add_contact(self):
		result = self.contact.add_contact("Tittoh", "0729261228")
		self.assertEqual(result["message"], "Contact added successfully")

	def test_update_contact(self):
		result =self.contact.update_contact("Tittoh", "0729261228", "0736197716")
		self.assertEqual(result["message"], "Contact updated successfully")

	def test_delete_contact(self):
		result = self.contact.delete_contact("Ken", "0734123456")
		self.assertEqual(result["message"], "Contact deleted successfully")

	def test_view_contact(self):
		result = self.contact.view_contact("Emmy", "099345667")
		self.assertEqual(result, "Contact for Emmy is 099345667")