class TestConfig(ShinkenTest): #setUp is in shinken_test def create_db(self): self.db = DB(table_prefix='test_') #Change ME :) def test_create_insert_query(self): self.create_db() data = {'id': "1", "is_master": True, 'plop': "master of the universe"} q = self.db.create_insert_query('instances', data) self.assert_( q == "INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , 'master of the universe' )" ) # Now some UTF8 funny characters data = {'id': "1", "is_master": True, 'plop': u'£°é§'} q = self.db.create_insert_query('instances', data) #print "Q", q c = u"INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , '£°é§' )" print type(q), type(c) print len(q), len(c) self.assert_(q == c) def test_update_query(self): self.create_db() data = {'id': "1", "is_master": True, 'plop': "master of the universe"} where = {'id': "1", "is_master": True} q = self.db.create_update_query('instances', data, where) #beware of the last space print "Q", q self.assert_( q == "UPDATE test_instances set plop='master of the universe' WHERE is_master='1' and id='1' " ) # Now some UTF8 funny characters data = {'id': "1", "is_master": True, 'plop': u'£°é§'} where = {'id': "£°é§", "is_master": True} q = self.db.create_update_query('instances', data, where) #print "Q", q c = u"UPDATE test_instances set plop='£°é§' WHERE is_master='1' and id='£°é§'" self.assert_(q.strip() == c.strip())
class TestConfig(ShinkenTest): #setUp is in shinken_test def create_db(self): self.db = DB(table_prefix = 'test_') #Change ME :) def test_create_insert_query(self): self.create_db() data = {'id' : "1", "is_master" : True, 'plop' : "master of the universe"} q = self.db.create_insert_query('instances' , data) self.assert_(q == "INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , 'master of the universe' )") # Now some UTF8 funny characters data = {'id' : "1", "is_master" : True, 'plop' : u'£°é§'} q = self.db.create_insert_query('instances' , data) #print "Q", q c = u"INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , '£°é§' )" print type(q), type(c) print len(q), len(c) self.assert_(q == c) def test_update_query(self): self.create_db() data = {'id' : "1", "is_master" : True, 'plop' : "master of the universe"} where = {'id' : "1", "is_master" : True} q = self.db.create_update_query('instances' , data, where) #beware of the last space print "Q", q self.assert_(q == "UPDATE test_instances set plop='master of the universe' WHERE is_master='1' and id='1' ") # Now some UTF8 funny characters data = {'id' : "1", "is_master" : True, 'plop' : u'£°é§'} where = {'id' : "£°é§", "is_master" : True} q = self.db.create_update_query('instances' , data, where) #print "Q", q c = u"UPDATE test_instances set plop='£°é§' WHERE is_master='1' and id='£°é§'" self.assert_(q.strip() == c.strip())
class TestConfig(ShinkenTest): # setUp is inherited from ShinkenTest def create_db(self): self.db = DB(table_prefix="test_") def test_create_insert_query(self): self.create_db() data = {"id": "1", "is_master": True, "plop": "master of the universe"} q = self.db.create_insert_query("instances", data) self.assertEqual( "INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , 'master of the universe' )", q ) # Now some UTF8 funny characters data = {"id": "1", "is_master": True, "plop": u"£°é§"} q = self.db.create_insert_query("instances", data) # print "Q", q c = u"INSERT INTO test_instances (is_master , id , plop ) VALUES ('1' , '1' , '£°é§' )" print type(q), type(c) print len(q), len(c) self.assertEqual(c, q) def test_update_query(self): self.create_db() data = {"id": "1", "is_master": True, "plop": "master of the universe"} where = {"id": "1", "is_master": True} q = self.db.create_update_query("instances", data, where) # beware of the last space print "Q", q self.assertEqual("UPDATE test_instances set plop='master of the universe' WHERE is_master='1' and id='1' ", q) # Now some UTF8 funny characters data = {"id": "1", "is_master": True, "plop": u"£°é§"} where = {"id": "£°é§", "is_master": True} q = self.db.create_update_query("instances", data, where) # print "Q", q c = u"UPDATE test_instances set plop='£°é§' WHERE is_master='1' and id='£°é§'" self.assertEqual(c.strip(), q.strip())
def create_db(self): self.db = DB(table_prefix='test_')
def create_db(self): self.db = DB(table_prefix = 'test_')