Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Unconditionally destroy buckets after testing (#516)
Madison Swain-Bowden4cba0ced9f7b
diff --git a/tests/dags/common/conftest.py b/tests/dags/common/conftest.pyindex ed4758c42..a5ae2b732 100644--- a/tests/dags/common/conftest.py+++ b/tests/dags/common/conftest.py@@ -11,7 +11,7 @@ def _delete_bucket(bucket):key_list = [{"Key": obj.key} for obj in bucket.objects.all()]if len(list(bucket.objects.all())) > 0:bucket.delete_objects(Delete={"Objects": key_list})- bucket.delete()+ bucket.delete()def pytest_configure(config):diff --git a/tests/dags/common/loader/test_s3.py b/tests/dags/common/loader/test_s3.pyindex 9c22f287b..1a5733b71 100644--- a/tests/dags/common/loader/test_s3.py+++ b/tests/dags/common/loader/test_s3.py@@ -146,15 +146,18 @@ def test_copy_file_to_s3_no_actual_file():s3.copy_file_to_s3("does_not_exist", "foo", "bar", "baz", None)-def test_copy_file_to_s3(tmp_path, mock_s3_load_file, empty_s3_bucket):+def test_copy_file_to_s3(tmp_path, empty_s3_bucket):tsv = tmp_path / "random_media_file.tsv"tsv.touch()version = "9000"ti_mock = mock.MagicMock(spec=TaskInstance)with mock.patch.object(s3.paths, "get_tsv_version", return_value=version):- s3.copy_file_to_s3(tsv, empty_s3_bucket, "fake-prefix", AWS_CONN_ID, ti_mock)+ s3.copy_file_to_s3(+ tsv, empty_s3_bucket.name, "fake-prefix", AWS_CONN_ID, ti_mock+ )assert not tsv.exists()assert ti_mock.xcom_push.call_args_list == [mock.call(key="tsv_version", value=version),mock.call(key="s3_key", value="fake-prefix/random_media_file.tsv"),]+ assert len(list(empty_s3_bucket.objects.all())) > 0diff --git a/tests/dags/common/loader/test_sql.py b/tests/dags/common/loader/test_sql.pyindex f08395163..cd5129c69 100644--- a/tests/dags/common/loader/test_sql.py+++ b/tests/dags/common/loader/test_sql.py@@ -178,7 +178,7 @@ def _load_local_tsv(tmpdir, bucket, tsv_file_name, identifier):def _load_s3_tsv(tmpdir, bucket, tsv_file_name, identifier):tsv_file_path = os.path.join(RESOURCES, tsv_file_name)- key = "path/to/object/{tsv_file_name}"+ key = f"path/to/object/{tsv_file_name}"bucket.upload_file(tsv_file_path, key)sql.load_s3_data_to_intermediate_table(POSTGRES_CONN_ID, bucket.name, key, identifier