Пример #1
0
def test_create_connection_maker(mocker):
    mock_connect = mocker.patch('local_data_api.resources.jdbc.connection_maker')
    connection_maker = DummyJDBC.create_connection_maker(
        host='127.0.0.1',
        port=3306,
        user_name='root',
        password='******',
        engine_kwargs={'JAR_PATH': 'test.jar'},
    )
    connection_maker()
    mock_connect.assert_called_once_with(
        'dummy',
        'jdbc:dummy://127.0.0.1:3306/',
        {'user': '******', 'password': '******'},
        'test.jar',
    )
Пример #2
0
def test_connection(mocker):
    mocker.patch('local_data_api.resources.jdbc.attach_thread_to_jvm')
    mock_jaydebeapi = mocker.patch('local_data_api.resources.jdbc.jaydebeapi')
    connection = connection_maker(
        jclassname='jdbc:db',
        url='localhost',
        driver_args={'user': '******'},
        jars='test.jar',
        libs='lib.so',
    )
    connection()
    mock_jaydebeapi.connect.assert_called_once_with('jdbc:db', 'localhost',
                                                    {'user': '******'},
                                                    'test.jar', 'lib.so')