コード例 #1
0
    def test_driver_name_exists(self):
        db_credentials = {
            "db_name": 'test_db_name',
            "db_username": '******',
            "db_pwd": 'test_db_pwd',
            "host": pid.get_hostname(),
            "port": pid.get_open_port()
        }
        if pid.check_container_exists('test_instance_name'):
            pid.delete_postgres_instance('test_instance_name')
        id0 = pid.create_postgres_instance('test_instance_name', db_credentials)
        with pytest.raises(ValueError):
            pid.create_postgres_instance('test_instance_name', db_credentials)

        pid.delete_postgres_instance(id0)
        assert pid.check_container_exists(id0) is False, "container exists after it was deleted"
コード例 #2
0
    def test_driver_name_exists(self):
        db_credentials = {
            "db_name": 'test_db_name',
            "db_username": '******',
            "db_pwd": 'test_db_pwd',
            "host": pid.get_hostname(),
            "port": pid.get_open_port()
        }
        if pid.check_container_exists('test_instance_name'):
            pid.delete_postgres_instance('test_instance_name')
        id0 = pid.create_postgres_instance('test_instance_name',
                                           db_credentials)
        with pytest.raises(ValueError):
            pid.create_postgres_instance('test_instance_name', db_credentials)

        pid.delete_postgres_instance(id0)
        assert pid.check_container_exists(
            id0) is False, "container exists after it was deleted"
コード例 #3
0
 def test_create_postgres_instance_with_fully_qualified_username(self):
     db_credentials = {
         "db_name": 'test_db_name',
         "db_username": '******'.format(pid.get_hostname()),
         "db_pwd": 'test_db_pwd',
         "host": pid.get_hostname(),
         "port": pid.get_open_port()
     }
     mock_c = MagicMock()
     mock_c.id = 'dN4IsDN5eOqeCgli23MlxeTA'
     mock_create = Mock(return_value=mock_c)
     with patch.object(docker.models.containers.ContainerCollection, 'create', mock_create):
         result = pid.create_postgres_instance(
             'tests_postgraas_test_instance_name', db_credentials
         )
     assert result == 'dN4IsDN5eOqeCgli23MlxeTA'
コード例 #4
0
 def test_create_postgres_instance(self):
     db_credentials = {
         "db_name": 'test_db_name',
         "db_username": '******',
         "db_pwd": 'test_db_pwd',
         "host": pid.get_hostname(),
         "port": pid.get_open_port()
     }
     mock_c = MagicMock()
     mock_c.id = 'EW3uvF3C3tLce9Eo5D76NbQe'
     mock_create = Mock(return_value=mock_c)
     with patch.object(docker.models.containers.ContainerCollection, 'create', mock_create):
         result = pid.create_postgres_instance(
             'tests_postgraas_test_instance_name', db_credentials
         )
     assert result == 'EW3uvF3C3tLce9Eo5D76NbQe'
コード例 #5
0
 def test_create_postgres_instance_with_fully_qualified_username(self):
     db_credentials = {
         "db_name": 'test_db_name',
         "db_username": '******'.format(pid.get_hostname()),
         "db_pwd": 'test_db_pwd',
         "host": pid.get_hostname(),
         "port": pid.get_open_port()
     }
     mock_c = MagicMock()
     mock_c.id = 'dN4IsDN5eOqeCgli23MlxeTA'
     mock_create = Mock(return_value=mock_c)
     with patch.object(docker.models.containers.ContainerCollection,
                       'create', mock_create):
         result = pid.create_postgres_instance(
             'tests_postgraas_test_instance_name', db_credentials)
     assert result == 'dN4IsDN5eOqeCgli23MlxeTA'
コード例 #6
0
 def test_create_postgres_instance(self):
     db_credentials = {
         "db_name": 'test_db_name',
         "db_username": '******',
         "db_pwd": 'test_db_pwd',
         "host": pid.get_hostname(),
         "port": pid.get_open_port()
     }
     mock_c = MagicMock()
     mock_c.id = 'EW3uvF3C3tLce9Eo5D76NbQe'
     mock_create = Mock(return_value=mock_c)
     with patch.object(docker.models.containers.ContainerCollection,
                       'create', mock_create):
         result = pid.create_postgres_instance(
             'tests_postgraas_test_instance_name', db_credentials)
     assert result == 'EW3uvF3C3tLce9Eo5D76NbQe'
コード例 #7
0
def create_db_container():
    config = get_config()
    print(config)
    db_credentials = {
        "db_name": config['metadb']['db_name'],
        "db_username": get_user(config),
        "db_pwd": get_password(config),
        "host": config['metadb']['host'],
        "port": config['metadb']['port']
    }
    if pg.check_container_exists('postgraas_master_db'):
        print("warning container already exists")
        postgraas_db = pg.get_container_by_name('postgraas_master_db')
        db_credentials['container_id'] = postgraas_db.id
    else:
        db_credentials['container_id'] = pg.create_postgres_instance(
            'postgraas_master_db', db_credentials)
    return db_credentials
コード例 #8
0
def create_db_container():
    config = get_config()
    print(config)
    db_credentials = {
        "db_name": config['metadb']['db_name'],
        "db_username": get_user(config),
        "db_pwd": get_password(config),
        "host": config['metadb']['host'],
        "port": config['metadb']['port']
    }
    if pg.check_container_exists('postgraas_master_db'):
        print("warning container already exists")
        postgraas_db = pg.get_container_by_name('postgraas_master_db')
        db_credentials['container_id'] = postgraas_db.id
    else:
        db_credentials['container_id'] = pg.create_postgres_instance(
            'postgraas_master_db', db_credentials
        )
    return db_credentials