def test_lookup(self): pb = "phonebook.pb" name = "Sarah" self.assertEqual(phonebook.lookup(name, pb), "Sarah could not be found.") name2 = "John" self.test_add() self.assertEqual(phonebook.lookup(name2, pb), "John Michael 123 456 4323\nJohn Doe 398 291 9281\n")
def testChange(self): phonebook.createTable('unittest', self.c) phonebook.add('Lita Cho', '510 938 3333', 'unittest', self.c) phonebook.change('Lita Cho', '333 333 3333', 'unittest', self.c) rows = phonebook.lookup('Lita Cho', 'unittest', self.c) self.assertTrue(rows.next()[1] == '333 333 3333')
def test_change(self): phonebook.change(pb_path, "John Smith", "212") phonebook.lookup(pb_path, "John Smith") self.verify('John Smith 212')
def test_cant_find(self): phonebook.lookup(pb_path, "Batman") self.verify("")
def test_lookup_partial(self): phonebook.lookup(pb_path, "Doge") self.verify('Wow Doge 212 234 2693')
def test_lookup_lower(self): phonebook.lookup(pb_path, "j") self.verify('James John 212 234 2693\nJohn Carter 212 234 2693\nSmith John 212 234 2693')
def test_lookup(self): phonebook.lookup(pb_path, "John Carter") self.verify('John Carter 212 234 2693')
def test_failed_lookup(self): self.assertEqual(phonebook.lookup("Joe Jan", "testing.db"), "Joe Jan does not exist in the db")
def test_successful_lookup(self): self.assertEqual(phonebook.lookup("Joe Jean", "testing.db"), "Joe Jean 123 345 2332")