Skip to content

Commit

Permalink
fix FlareCleanup tests along with removing more unused `Archive/Sto…
Browse files Browse the repository at this point in the history
…rageService` fn
  • Loading branch information
Swatinem committed Jan 21, 2025
1 parent 6693116 commit 5b6206c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
14 changes: 9 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,17 @@ def mock_storage(mocker):

@pytest.fixture
def mock_archive_storage(mocker):
m = mocker.patch("shared.api_archive.archive.StorageService")
use_archive = mocker.patch(
"shared.django_apps.core.models.should_write_data_to_storage_config_check"
mocker.patch(
"shared.django_apps.core.models.should_write_data_to_storage_config_check",
return_value=True,
)
use_archive.return_value = True
storage_server = MemoryStorageService({})
m.return_value = storage_server
mocker.patch(
"shared.api_archive.archive.StorageService", return_value=storage_server
)
mocker.patch(
"shared.storage.get_appropriate_storage_service", return_value=storage_server
)
return storage_server


Expand Down
7 changes: 0 additions & 7 deletions services/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,6 @@ def delete_file(self, path) -> None:
"""
self.storage.delete_file(self.root, path)

@sentry_sdk.trace()
def delete_files(self, paths: list[str]) -> list[bool]:
"""
Batch-deletes the gives list of files.
"""
return self.storage.delete_files(self.root, paths)

def read_chunks(self, commit_sha, report_code=None) -> str:
"""
Convenience method to read a chunks file from the archive.
Expand Down
12 changes: 3 additions & 9 deletions tasks/tests/unit/test_flare_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ def test_limits_on_manual_run(self, transactional_db, mocker, mock_archive_stora
merged_pull_with_archive_flare.id
)

everything_in_archive_storage = mock_archive_storage.list_folder_contents(
bucket_name="archive"
)
everything_in_archive_storage = mock_archive_storage.storage["archive"]
assert len(everything_in_archive_storage) == 5

task = FlareCleanupTask()
Expand Down Expand Up @@ -180,13 +178,9 @@ def test_limits_on_manual_run(self, transactional_db, mocker, mock_archive_stora
assert pull._flare == local_value_for_flare
assert pull._flare_storage_path is None

everything_in_archive_storage = mock_archive_storage.list_folder_contents(
bucket_name="archive"
)
everything_in_archive_storage = mock_archive_storage.storage["archive"]
assert len(everything_in_archive_storage) == 2
file_names_in_archive_storage = [
file["name"] for file in everything_in_archive_storage
]
file_names_in_archive_storage = set(everything_in_archive_storage.keys())

should_be_cleared = oldest_to_newest_pulls_with_archive_flare[:3]
should_not_be_cleared = oldest_to_newest_pulls_with_archive_flare[3:]
Expand Down

0 comments on commit 5b6206c

Please sign in to comment.