Example #1
0
 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)
Example #2
0
    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)
Example #3
0
    def testDelete(self):
        firewalls = Firewalls()
        entity = firewalls.new()

        expected = 'DELETE FROM firewalls WHERE id = ?'
        self.assertEqual(firewalls._generate_delete_query(entity.name), expected)
Example #4
0
    def testNew(self):
        firewalls = Firewalls()
        self.assertIsInstance(firewalls.new(), Firewall)

        e = firewalls.new(name="lol")
        self.assertEqual(e.name, 'lol')
Example #5
0
 def testFirst(self):
     firewalls = Firewalls()
     self.assertEqual(firewalls.first(), None)
     entity = firewalls.new()
     firewalls.add(entity, persist=False)
     self.assertEqual(firewalls.first(), entity)