def testAdd(self): firewalls = Firewalls() before_count = len(firewalls.all()) self.assertTrue(firewalls.add(firewalls.new(), persist=False)) after_count = len(firewalls.all()) self.assertGreater(after_count, before_count) self.assertEqual(before_count + 1, after_count)
def test_InsertQuery(self): firewalls = Firewalls() entity = firewalls.new() expected = OrderedDict([ ('id', None), ('name', None), ('data', None) ]) data = firewalls._generate_query_data(entity) self.assertEqual(expected, data) expected = 'INSERT INTO firewalls(id,name,data) VALUES (?,?,?)' self.assertEqual(firewalls._generate_insert_query(data), expected)
def testDelete(self): firewalls = Firewalls() entity = firewalls.new() expected = 'DELETE FROM firewalls WHERE id = ?' self.assertEqual(firewalls._generate_delete_query(entity.name), expected)
def testNew(self): firewalls = Firewalls() self.assertIsInstance(firewalls.new(), Firewall) e = firewalls.new(name="lol") self.assertEqual(e.name, 'lol')
def testFirst(self): firewalls = Firewalls() self.assertEqual(firewalls.first(), None) entity = firewalls.new() firewalls.add(entity, persist=False) self.assertEqual(firewalls.first(), entity)