Пример #1
0
    def test_save(self):
        context = self.target
        tablename = 'table1'
        context.set_metadata(tablename, [
            kida.IntField("id", is_key=True),
            kida.StringField("fstr"),
            kida.IntField("fint")
        ])

        data = {"id": 1, "fint": 1, "fstr": 'abc'}
        context.save(tablename, data)
        context.commit()

        row = context.get(tablename, {'id': 1})
        logging.debug(row)
        self.assertIsNotNone(row)
        self.assertEqual(row['fstr'], 'abc')
        self.assertEqual(row['fint'], 1)
Пример #2
0
    def test_save_column_insentisive(self):
        context = self.target
        tablename = 'table1'
        tablename_upper = 'TABLE1'
        context.set_metadata(tablename, [
            kida.IntField("id", is_key=True),
            kida.StringField("fstr"),
            kida.IntField("fint")
        ])

        data = {"ID": 1, "FINT": 1, "FSTR": 'abc'}
        context.save(tablename_upper, data)
        context.commit()

        row = context.get(tablename_upper, {'id': 1})
        logging.debug(row)
        self.assertIsNotNone(row)
        self.assertEqual(row['fstr'], 'abc')
        self.assertEqual(row['fint'], 1)
Пример #3
0
    def test_save_update_column_caseinsentive(self):
        context = self.target
        tablename = 'table1'
        context.set_metadata(tablename, [
            kida.IntField("id", is_key=True),
            kida.StringField("fstr"),
            kida.IntField("fint")
        ])

        data = {"id": 1, "fint": 1, "fstr": 'abc'}
        context.save(tablename, data)

        data['fint'] = 2
        data['fstr'] = 'abcd'
        data = {"ID": 1, "FINT": 2, "FSTR": 'abcd'}
        context.save(tablename, data)

        row = context.get(tablename, {'id': 1})
        self.assertIsNotNone(row)
        self.assertEqual(row['fstr'], 'abcd')
        self.assertEqual(row['fint'], 2)
Пример #4
0
 def test_set_metadata(self):
     context = self.target
     context.set_metadata("table1", [kida.IntField("id", is_key=True)])
     data = {"id": 1, "fielda": 'a'}
     tablename = 'table1'
     context.save(tablename, data)