Exemplo n.º 1
0
 def testAdd(self):
     envs = Environments()
     before_count = len(envs.all())
     self.assertTrue(envs.add(envs.new(), persist=False))
     after_count = len(envs.all())
     self.assertGreater(after_count, before_count)
     self.assertEqual(before_count + 1, after_count)
Exemplo n.º 2
0
    def testFirst(self):
        envs = Environments()
        self.assertIsNone(envs.first())

        envs.add(envs.new(), persist=False)
        first =  envs._items[0]
        self.assertEqual(envs.first(), first)
Exemplo n.º 3
0
    def test_InsertQuery(self):
        envs = Environments()
        entity = envs.new()

        expected = OrderedDict([('id', None), ('code', None), ('name', None)])
        data = envs._generate_query_data(entity)
        self.assertEqual(expected, data)

        expected = 'INSERT INTO environments(id,code,name) VALUES (?,?,?)'
        self.assertEqual(envs._generate_insert_query(data), expected)
Exemplo n.º 4
0
    def testDelete(self):
        envs = Environments()
        entity = envs.new()

        expected = 'DELETE FROM environments WHERE id = ?'
        self.assertEqual(envs._generate_delete_query(entity.id), expected)
Exemplo n.º 5
0
    def testNew(self):
        envs = Environments()
        self.assertIsInstance(envs.new(), Environment)

        e = envs.new(id="lol")
        self.assertEqual(e.id, 'lol')