def athena(region_name, athena_database, athena_workgroup, s3_tmp_uri): proxy = Boto3Proxy(region=region_name) athena = Athena(proxy) athena.database = athena_database athena.workgroup = athena_workgroup athena.output_location = s3_tmp_uri return athena
def athena_fixture(fake): orig_sleep = time.sleep time.sleep = fake_sleep athena = Athena(fake) athena.kill_on_interrupt = True yield athena time.sleep = orig_sleep
def test_cached_remotely_only(self, full_athena, fake): """ Test that remote cache is used to populate local cache. """ # Another client populates remote cache. another_athena = Athena(fake) another_athena.cache.remote_storage = full_athena.cache.remote_storage another_athena.execute("SELECT 1 id, 'foo' name") fake.request_log.clear() # First execution uses remote cache full_athena.execute("SELECT 1 id, 'foo' name") assert fake.request_log == [ "GetQueryExecution", "GetQueryResults", ] assert full_athena.cache.local_storage.size() == 2
def full_athena_fixture(fake, storage): """ Athena client caching both locally and remotely. """ athena = Athena(fake) athena.cache.local_storage = storage athena.cache.remote_storage = MemoryStorage() return athena
def remote_athena_fixture(fake, storage): """ Athena client caching remotely. In remote mode, only query execution IDs are cached. """ athena = Athena(fake) athena.cache.remote_storage = storage return athena
def local_athena_fixture(fake, storage): """ Athena client caching locally. In local mode, both query execution IDs and results are cached. """ athena = Athena(fake) athena.cache.local_storage = storage return athena
def athena_fixture(fake): athena = Athena(fake) athena.database = "example_database" athena.workgroup = "example-workgroup" athena.output_location = "s3://example-output/" return athena
def test_quote_invalid(value): with pytest.raises(TypeError): Athena.quote(value)
def test_quote_value(value, quoted): assert Athena.quote(value) == quoted