class BlockedContactTest(BaseTestCase): def setUp(self): self.clean_db() self.blocked_contact = BlockedContact('8888888', u'中介') def tearDown(self): pass def test_save(self): self.blocked_contact.save() conn = self.connect_db() try: c = conn.cursor() c.execute('SELECT COUNT(*) FROM ' + BlockedContact.table_name) self.assertEqual(c.fetchone()[0], 1, 'Count of blocked contacts should be 1') except: pass finally: conn.close() def test_find_all(self): self.blocked_contact.save() another_blocked_contact = BlockedContact('99999999', u'中介') another_blocked_contact.save() records = BlockedContact.findall() print 'BlockedContacts', records self.assertEqual(2, len(records)) def test_find(self): self.blocked_contact.save() result = BlockedContact.find(self.blocked_contact) self.assertEqual(self.blocked_contact.contact, result.contact, 'Item found should be the same as saved') def test_remove(self): self.blocked_contact.save() self.blocked_contact.remove() conn = self.connect_db() try: c = conn.cursor() c.execute('SELECT COUNT(*) FROM ' + BlockedContact.table_name) self.assertEqual(c.fetchone()[0], 0, 'Count of blocked contacts should be 0 after removing') except: pass finally: conn.close() def test_is_contact_blocked(self): self.blocked_contact.save() self.assertTrue(BlockedContact.is_contact_blocked(self.blocked_contact.contact), 'Contact should been blocked') def test_find_with_pagination(self): for i in range(0, 20): BlockedContact('%d' % i, '').save() records = BlockedContact.find_with_pagination(page_request={'page_no': 2, 'size': 10}) print 'items', records self.assertEqual(10, len(records))
class BlockedContactTest(BaseTestCase): def setUp(self): self.clean_db() self.blocked_contact = BlockedContact("8888888", u"中介") def tearDown(self): pass def test_save(self): self.blocked_contact.save() conn = self.connect_db() try: c = conn.cursor() c.execute("SELECT COUNT(*) FROM " + BlockedContact.table_name) self.assertEqual(c.fetchone()[0], 1, "Count of blocked contacts should be 1") except: pass finally: conn.close() def test_find_all(self): self.blocked_contact.save() another_blocked_contact = BlockedContact("99999999", u"中介") another_blocked_contact.save() records = BlockedContact.findall() print "BlockedContacts", records self.assertEqual(2, len(records)) def test_find(self): self.blocked_contact.save() result = BlockedContact.find(self.blocked_contact) self.assertEqual(self.blocked_contact.contact, result.contact, "Item found should be the same as saved") def test_remove(self): self.blocked_contact.save() self.blocked_contact.remove() conn = self.connect_db() try: c = conn.cursor() c.execute("SELECT COUNT(*) FROM " + BlockedContact.table_name) self.assertEqual(c.fetchone()[0], 0, "Count of blocked contacts should be 0 after removing") except: pass finally: conn.close() def test_is_contact_blocked(self): self.blocked_contact.save() self.assertTrue(BlockedContact.is_contact_blocked(self.blocked_contact.contact), "Contact should been blocked") def test_find_with_pagination(self): for i in range(0, 20): BlockedContact("%d" % i, "").save() records = BlockedContact.find_with_pagination(page_request={"page_no": 2, "size": 10}) print "items", records self.assertEqual(10, len(records))
def test_find_all(self): self.blocked_contact.save() another_blocked_contact = BlockedContact("99999999", u"中介") another_blocked_contact.save() records = BlockedContact.findall() print "BlockedContacts", records self.assertEqual(2, len(records))
def test_find_all(self): self.blocked_contact.save() another_blocked_contact = BlockedContact('99999999', u'中介') another_blocked_contact.save() records = BlockedContact.findall() print 'BlockedContacts', records self.assertEqual(2, len(records))