예제 #1
0
    def test_create_db_pool(self):

        db_name = 'flyway'
        create_database(db_name)
        create_db_pool(db_name)
        from utils.db_base import db_pool
        self.assertIsInstance(db_pool, PooledDB)
예제 #2
0
 def test_delete_table(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'table_name_test'
     delete_table(table_name)
     self.assertFalse(check_table_exist(table_name))
    def test_create_db_pool(self):

        db_name = 'flyway'
        create_database(db_name)
        create_db_pool(db_name)
        from utils.db_base import db_pool
        self.assertIsInstance(db_pool, PooledDB)
 def test_delete_table(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'table_name_test'
     delete_table(table_name)
     self.assertFalse(check_table_exist(table_name))
예제 #5
0
 def test_check_table_exist(self):
     db_name = 'mysql'
     release_db_pool()
     create_db_pool(db_name)
     not_existed_table_name = 'table_name_should_not_exist'
     self.assertFalse(check_table_exist(not_existed_table_name))
     exacted_table_name = 'user'
     self.assertTrue(check_table_exist(exacted_table_name))
 def test_check_table_exist(self):
     db_name = 'mysql'
     release_db_pool()
     create_db_pool(db_name)
     not_existed_table_name = 'table_name_should_not_exist'
     self.assertFalse(check_table_exist(not_existed_table_name))
     exacted_table_name = 'user'
     self.assertTrue(check_table_exist(exacted_table_name))
    def __init__(self, *args, **kwargs):
        super(TestBase, self).__init__(*args, **kwargs)
        config.parse(['--config-file', '../../etc/flyway.conf'])
        setup_scheduler()

        db_name = 'flyway'
        create_database(db_name)
        release_db_pool()
        create_db_pool(db_name)
예제 #8
0
    def __init__(self, *args, **kwargs):
        super(TestBase, self).__init__(*args, **kwargs)
        config.parse(['--config-file', '../../etc/flyway.conf'])
        setup_scheduler()

        db_name = 'flyway'
        create_database(db_name)
        release_db_pool()
        create_db_pool(db_name)
예제 #9
0
 def test_create_table(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'test_table_name'
     try:
         create_table(table_name, 'id varchar(20)', True)
         self.assertTrue(check_table_exist(table_name))
     except Exception, e:
         self.fail(e.message)
 def test_create_table(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'test_table_name'
     try:
         create_table(table_name, 'id varchar(20)', True)
         self.assertTrue(check_table_exist(table_name))
     except Exception, e:
         self.fail(e.message)
 def test_read_record(self):
     db_name = 'mysql'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'user'
     data = read_record(table_name,
                        ['*'],
                        {'Host': 'localhost', 'User': '******'},
                        True)
     self.assertEqual('localhost', data[0][0])
     self.assertEqual('root', data[0][1])
예제 #12
0
 def test_read_record(self):
     db_name = 'mysql'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'user'
     data = read_record(table_name, ['*'], {
         'Host': 'localhost',
         'User': '******'
     }, True)
     self.assertEqual('localhost', data[0][0])
     self.assertEqual('root', data[0][1])
    def test_check_record_exist(self):
        db_name = 'mysql'
        release_db_pool()
        create_db_pool(db_name)
        table_name = 'user'
        result = check_record_exist(table_name,
                                    {'Host': 'localhost', 'User': '******'})
        self.assertTrue(result)

        result = check_record_exist(table_name,
                                    {'Host': 'localhost', 'User': '******'})
        self.assertFalse(result)
예제 #14
0
 def test_insert_record(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'test_table_name'
     create_table(table_name, 'id varchar(20)', True)
     test_id = 1
     try:
         insert_record(table_name, [{'id': test_id}], True)
         data = read_record(table_name, ['id'], {'1': 1}, True)
         self.assertIn((str(test_id), ), data)
     except Exception, e:
         self.fail(e.message)
 def test_insert_record(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'test_table_name'
     create_table(table_name, 'id varchar(20)', True)
     test_id = 1
     try:
         insert_record(table_name, [{'id': test_id}], True)
         data = read_record(table_name, ['id'], {'1': 1}, True)
         self.assertIn((str(test_id),), data)
     except Exception, e:
         self.fail(e.message)
예제 #16
0
    def test_check_record_exist(self):
        db_name = 'mysql'
        release_db_pool()
        create_db_pool(db_name)
        table_name = 'user'
        result = check_record_exist(table_name, {
            'Host': 'localhost',
            'User': '******'
        })
        self.assertTrue(result)

        result = check_record_exist(table_name, {
            'Host': 'localhost',
            'User': '******'
        })
        self.assertFalse(result)
예제 #17
0
 def test_delete_all_data(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'test_table_name'
     create_table(table_name, 'id varchar(20)', True)
     test_id, test_id2 = 1, 2
     insert_record(table_name, [{'id': test_id}, {'id': test_id2}], True)
     data = read_record(table_name, ['id'], {'1': 1}, True)
     self.assertIn((str(test_id), ), data)
     self.assertIn((str(test_id2), ), data)
     try:
         delete_all_data(table_name)
         data = read_record(table_name, ['id'], {'1': 1}, True)
         self.assertNotIn((str(test_id)), data)
         self.assertNotIn((str(test_id2), ), data)
     except Exception, e:
         self.fail(e)
 def test_delete_all_data(self):
     db_name = 'test'
     release_db_pool()
     create_db_pool(db_name)
     table_name = 'test_table_name'
     create_table(table_name, 'id varchar(20)', True)
     test_id, test_id2 = 1, 2
     insert_record(table_name, [{'id': test_id}, {'id': test_id2}], True)
     data = read_record(table_name, ['id'], {'1': 1}, True)
     self.assertIn((str(test_id),), data)
     self.assertIn((str(test_id2),), data)
     try:
         delete_all_data(table_name)
         data = read_record(table_name, ['id'], {'1': 1}, True)
         self.assertNotIn((str(test_id)), data)
         self.assertNotIn((str(test_id2),), data)
     except Exception, e:
         self.fail(e)
 def test_connect_with_db(self):
     db_name = 'flyway'
     create_database(db_name)
     create_db_pool(db_name)
     db_from_pool = connect(True)
     self.assertIsInstance(db_from_pool, PooledDedicatedDBConnection)
예제 #20
0
 def test_connect_with_db(self):
     db_name = 'flyway'
     create_database(db_name)
     create_db_pool(db_name)
     db_from_pool = connect(True)
     self.assertIsInstance(db_from_pool, PooledDedicatedDBConnection)