Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update shared #1173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphql_api/tests/test_test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __call__(self, updated_at: datetime.datetime) -> dict[str, Any]:

@pytest.fixture
def mock_storage(mocker):
m = mocker.patch("utils.test_results.StorageService")
m = mocker.patch("utils.test_results.get_appropriate_storage_service")
storage_server = MemoryStorageService({})
m.return_value = storage_server
yield storage_server
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ freezegun
google-cloud-pubsub
gunicorn>=22.0.0
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
https://github.com/codecov/shared/archive/47fa7fd405cd4a37ab6df9f200d6b600795f2786.tar.gz#egg=shared
https://github.com/codecov/shared/archive/015d76ed1b6d8c85b5abd5f0825136ae7d6e0f4c.tar.gz#egg=shared
https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz
idna>=3.7
minio
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ sentry-sdk[celery]==2.13.0
# shared
setproctitle==1.1.10
# via -r requirements.in
shared @ https://github.com/codecov/shared/archive/47fa7fd405cd4a37ab6df9f200d6b600795f2786.tar.gz
shared @ https://github.com/codecov/shared/archive/015d76ed1b6d8c85b5abd5f0825136ae7d6e0f4c.tar.gz
# via -r requirements.in
simplejson==3.17.2
# via -r requirements.in
Expand Down
2 changes: 1 addition & 1 deletion staticanalysis/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def test_simple_static_analysis_call_no_uploads_yet(db, mocker):
mocked_task_service = mocker.patch.object(TaskService, "schedule_task")
mocked_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we have discussed in the retro, related to "overreliance on mocks", keep in mind that all of these mocks are potential breakage in production that we will never catch in tests :-(

return_value="banana.txt",
)
commit = CommitFactory.create(repository__active=True)
Expand Down
12 changes: 8 additions & 4 deletions upload/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_fake_upload_with_flags():

def test_serialize_upload(transactional_db, mocker):
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
fake_upload = get_fake_upload()
Expand All @@ -63,7 +63,7 @@ def test_serialize_upload(transactional_db, mocker):

def test_upload_serializer_contains_expected_fields_no_flags(transactional_db, mocker):
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload = get_fake_upload()
Expand All @@ -90,7 +90,7 @@ def test_upload_serializer_contains_expected_fields_with_flags(
transactional_db, mocker
):
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload = get_fake_upload_with_flags()
Expand All @@ -114,6 +114,10 @@ def test_upload_serializer_contains_expected_fields_with_flags(


def test_upload_serializer_null_build_url_empty_flags(transactional_db, mocker):
mocker.patch(
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
data = {
"ci_url": None,
"flags": [],
Expand All @@ -128,7 +132,7 @@ def test_upload_serializer_null_build_url_empty_flags(transactional_db, mocker):

def test__create_existing_flags_map(transactional_db, mocker):
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload = get_fake_upload_with_flags()
Expand Down
4 changes: 2 additions & 2 deletions upload/tests/test_upload_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_invalid_repo(self):
assert response.status_code == 404

@patch("shared.api_archive.archive.ArchiveService.get_archive_hash")
@patch("shared.api_archive.archive.StorageService.create_presigned_get")
@patch("shared.storage.MinioStorageService.create_presigned_get")
def test_invalid_archive_path(self, create_presigned_get, get_archive_hash):
create_presigned_get.side_effect = [
minio.error.S3Error(
Expand All @@ -93,7 +93,7 @@ def test_invalid_archive_path(self, create_presigned_get, get_archive_hash):
assert response.status_code == 404

@patch("shared.api_archive.archive.ArchiveService.get_archive_hash")
@patch("shared.api_archive.archive.StorageService.create_presigned_get")
@patch("shared.storage.MinioStorageService.create_presigned_get")
def test_valid_repo_archive_path(self, create_presigned_get, get_archive_hash):
create_presigned_get.return_value = "presigned-url"
get_archive_hash.return_value = "hasssshhh"
Expand Down
24 changes: 12 additions & 12 deletions upload/tests/views/test_bundle_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_upload_bundle_analysis_success(db, client, mocker, mock_redis):
"upload.views.bundle_analysis.BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER.labels"
)
create_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -112,7 +112,7 @@ def test_upload_bundle_analysis_success_shelter(db, client, mocker, mock_redis):
"upload.views.bundle_analysis.BUNDLE_ANALYSIS_UPLOAD_VIEWS_COUNTER.labels"
)
create_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -198,7 +198,7 @@ def test_upload_bundle_analysis_success_shelter(db, client, mocker, mock_redis):
def test_upload_bundle_analysis_org_token(db, client, mocker, mock_redis):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -236,7 +236,7 @@ def test_upload_bundle_analysis_org_token(db, client, mocker, mock_redis):
def test_upload_bundle_analysis_existing_commit(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -282,7 +282,7 @@ def test_upload_bundle_analysis_existing_commit(db, client, mocker, mock_redis):
def test_upload_bundle_analysis_missing_args(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_upload_bundle_analysis_missing_args(db, client, mocker, mock_redis):
def test_upload_bundle_analysis_invalid_token(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -361,7 +361,7 @@ def test_upload_bundle_analysis_github_oidc_auth(
):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -405,7 +405,7 @@ def test_upload_bundle_analysis_measurement_datasets_created(
):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_upload_bundle_analysis_measurement_timeseries_disabled(
):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -525,7 +525,7 @@ def test_upload_bundle_analysis_no_repo(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)
mock_metrics = mocker.patch(
Expand Down Expand Up @@ -570,7 +570,7 @@ def test_upload_bundle_analysis_tokenless_success(db, client, mocker, mock_redis
)

create_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -621,7 +621,7 @@ def test_upload_bundle_analysis_true_tokenless_success(db, client, mocker, mock_
upload = mocker.patch.object(TaskService, "upload")

create_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down
20 changes: 10 additions & 10 deletions upload/tests/views/test_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_upload_test_results(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mock_prometheus_metrics = mocker.patch("upload.metrics.API_UPLOAD_COUNTER.labels")
create_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -119,7 +119,7 @@ def test_upload_test_results(db, client, mocker, mock_redis):
def test_test_results_org_token(db, client, mocker, mock_redis):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -149,7 +149,7 @@ def test_test_results_github_oidc_token(
):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -180,7 +180,7 @@ def test_test_results_github_oidc_token(
def test_test_results_upload_token_not_required(db, client, mocker, mock_redis):
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -230,7 +230,7 @@ def test_upload_test_results_no_repo(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand All @@ -256,7 +256,7 @@ def test_upload_test_results_no_repo(db, client, mocker, mock_redis):
def test_upload_test_results_missing_args(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -292,7 +292,7 @@ def test_upload_test_results_missing_args(db, client, mocker, mock_redis):
def test_upload_test_results_missing_branch_no_commit(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -321,7 +321,7 @@ def test_upload_test_results_missing_branch_no_commit(db, client, mocker, mock_r
def test_upload_test_results_branch_none_no_commit(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -353,7 +353,7 @@ def test_update_repo_fields_when_upload_is_triggered(
) -> None:
mocker.patch.object(TaskService, "upload")
mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down Expand Up @@ -382,7 +382,7 @@ def test_update_repo_fields_when_upload_is_triggered(
def test_upload_test_results_file_not_found(db, client, mocker, mock_redis):
upload = mocker.patch.object(TaskService, "upload")
create_presigned_put = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="test-presigned-put",
)

Expand Down
4 changes: 2 additions & 2 deletions upload/tests/views/test_upload_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_upload_coverage_post(db, mocker):
CanDoCoverageUploadsPermission, "has_permission", return_value=True
)
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload_task_mock = mocker.patch(
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_upload_coverage_post_shelter(db, mocker):
CanDoCoverageUploadsPermission, "has_permission", return_value=True
)
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload_task_mock = mocker.patch(
Expand Down
14 changes: 7 additions & 7 deletions upload/tests/views/test_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def test_uploads_post(db, mocker, mock_redis):
CanDoCoverageUploadsPermission, "has_permission", return_value=True
)
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload_task_mock = mocker.patch(
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_uploads_post(db, mocker, mock_redis):
)
def test_uploads_post_tokenless(db, mocker, mock_redis, private, branch, branch_sent):
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload_task_mock = mocker.patch(
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_uploads_post_token_required_auth_check(
upload_token_required_for_public_repos,
):
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload_task_mock = mocker.patch(
Expand Down Expand Up @@ -600,7 +600,7 @@ def test_uploads_post_github_oidc_auth(
mock_redis,
):
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
upload_task_mock = mocker.patch(
Expand Down Expand Up @@ -726,7 +726,7 @@ def test_uploads_post_shelter(db, mocker, mock_redis):
CanDoCoverageUploadsPermission, "has_permission", return_value=True
)
presigned_put_mock = mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
mocker.patch("upload.views.uploads.trigger_upload_task", return_value=True)
Expand Down Expand Up @@ -883,7 +883,7 @@ def test_uploads_post_github_enterprise_oidc_auth_jwks_url(
analytics_service_mock,
):
self.mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
self.mocker.patch("upload.views.uploads.trigger_upload_task", return_value=True)
Expand Down Expand Up @@ -941,7 +941,7 @@ def test_uploads_post_github_enterprise_oidc_auth_no_url(
):
mock_config_helper(self.mocker, configs={"github_enterprise.url": None})
self.mocker.patch(
"shared.api_archive.archive.StorageService.create_presigned_put",
"shared.storage.MinioStorageService.create_presigned_put",
return_value="presigned put",
)
self.mocker.patch("upload.views.uploads.trigger_upload_task", return_value=True)
Expand Down
3 changes: 2 additions & 1 deletion upload/views/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ async def get_repo(self):
raise Http404("Requested report could not be found")
return repo

@sync_to_async
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks unrelated. why?
if the function was sync all along, there is no reason to make it async? the function body looks trivial enough that it wouldn’t benefit from running concurrently.

def validate_path(self, repo):
msg = "Requested report could not be found"
if not self.path:
Expand Down Expand Up @@ -435,7 +436,7 @@ async def get(self, request, *args, **kwargs):

self.read_params()
repo = await self.get_repo()
self.validate_path(repo)
await self.validate_path(repo)

response = HttpResponse(status=302)
response["Location"] = await self.get_presigned_url(repo)
Expand Down
Loading
Loading