def test_init_pooled_pghelper(self, pool_mock): help = PostgreSQLHelper(host='127.0.0.1', user='******', password='******', database='test_db', pooled=True) assert pool_mock.mock_calls == [ call.get_instance(host='127.0.0.1', user='******', password='******', database='test_db', database_args={}), call.get_instance().getconn(key=id(help)), call.get_instance().getconn().cursor() ]
def test_init_pooled(self, mocker): pool_mock = mocker.patch("nova_api.persistence.mysql_helper.MySQLPool") MySQLHelper(host='127.0.0.1', user='******', password='******', database='test_db', pooled=True) assert pool_mock.mock_calls == [ call.get_instance(host='127.0.0.1', user='******', password='******', database='test_db', database_args={}), call.get_instance().get_connection(), call.get_instance().get_connection().cursor() ]
def test_pass_multiple_batches_ids(monkeypatch): monkeypatch.setenv("APPLITOOLS_API_KEY", "abc") with patch("applitools.selenium.command_executor.CommandExecutor" ) as commands: BatchClose().set_batch_ids("test batch-id", "test-batch-second").close() assert commands.mock_calls == [ call.get_instance("eyes.sdk.python", ANY), call.get_instance().core_close_batches({ "batchIds": ["test batch-id", "test-batch-second"], "serverUrl": "https://eyesapi.applitools.com", "apiKey": "abc", }), ]
def test_batch_close_uses_proxy(): with patch("applitools.selenium.command_executor.CommandExecutor" ) as commands: BatchClose().set_batch_ids("test-id").set_proxy( ProxySettings("localhost", 80)).close() assert commands.mock_calls == [ call.get_instance("eyes.sdk.python", ANY), call.get_instance().core_close_batches({ "batchIds": ["test-id"], "serverUrl": "https://eyesapi.applitools.com", "apiKey": ANY, "proxy": { "url": "http://localhost:80" }, }), ]
def test_close_pooled(self, pool_mock, db_pooled, cursor_mock): db_pooled.close() my_conn = Mock() pool_mock.get_instance.return_value.getconn.return_value = my_conn assert call.get_instance().getconn().cursor().close() \ in pool_mock.mock_calls assert pool_mock.get_instance.return_value.putconn.called_with(my_conn)
def test_handler(mock_instance): """Alert Merger - Handler (Entry Point)""" main.handler(None, None) mock_instance.assert_has_calls( [call.get_instance(), call.get_instance().dispatch()])