def test_delete(): source = "ftp://hostname/source.txt" with tentaclio.open(source, mode="w") as f: f.write("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.") tentaclio.remove(source) with pytest.raises(tentaclio.clients.exceptions.FTPError): with tentaclio.open(source) as f: ...
def test_delete(fixture_client, test_bucket): source = f"s3://{test_bucket}/source.txt" with tio.open(source, mode="w") as f: f.write("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.") tio.remove(source) with pytest.raises(S3Error, match="Unable to fetch the remote file"): with tio.open(source) as f: ...
def test_mocked_api_calls(m_connect, m_get, m_put, m_remove, url, bucket, key): """Test api calls reaches the mocks.""" data = bytes("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", "utf-8") with tentaclio.open(url, mode="wb") as f: f.write(data) m_put.assert_called_once_with(mock.ANY, bucket, key) with tentaclio.open(url, mode="rb") as f: f.read() m_get.assert_called_once_with(mock.ANY, bucket, key) tentaclio.remove(url) m_remove.assert_called_once_with(bucket, key) m_get.reset_mock() m_get.side_effect = google_exceptions.NotFound("Not found") with pytest.raises(google_exceptions.NotFound): tentaclio.open(url, mode="rb")
def test_authenticated_api_calls(gs_url, bucket_exists): """Test the authenticated API calls. Skipped unless configured in conftest or TENTACLIO__CONN__GS_TEST is set. 🚨🚨🚨WARNING🚨🚨🚨 The functional test for GS will: - create a bucket if non is found. This will be created in the configured project (see gcloud docs). - upload and remove a file as set in the URL To use run the test use command: ``` env TENTACLIO__CONN__GS_TEST=gs://tentaclio-bucket/test.txt \ make functional-gs ``` You will need to have your environment configured, credentials and project. This is done with the gcloud cli tool. See docs for more information: https://googleapis.dev/python/google-api-core/latest/auth.html """ data = bytes("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", "utf-8") with tentaclio.open(gs_url, mode="wb") as f: f.write(data) with tentaclio.open(gs_url, mode="rb") as f: result = f.read() assert result == data tentaclio.remove(gs_url) with pytest.raises(google_exceptions.NotFound): with tentaclio.open(gs_url, mode="rb") as f: result = f.read()