Skip to content

Commit

Permalink
bug-1889185: fix pytest markers and generalize generate_storage_key
Browse files Browse the repository at this point in the history
  • Loading branch information
willkg committed May 21, 2024
1 parent 5462819 commit 00d064a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ filterwarnings =
# pubsub deprecated the return_immediately flag because it negatively impacts performance, but
# that performance cost is fine for our use case, especially in tests.
ignore:The return_immediately flag is deprecated and should be set to False.:DeprecationWarning:google.pubsub_v1

markers =
aws: tests that require aws backends to be configured in the environment. this is the default.
gcp: tests that require gcp backends to be configured in the environment. skipped unless explicitly requested.
14 changes: 7 additions & 7 deletions socorro/tests/stage_submitter/test_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_app():
return app


def generate_s3_key(kind, crash_id):
def generate_storage_key(kind, crash_id):
"""Generates the key in S3 for this object kind
:arg kind: the kind of thing to fetch
Expand All @@ -34,12 +34,12 @@ def generate_s3_key(kind, crash_id):
"""
if kind == "raw_crash":
return "v1/raw_crash/20%s/%s" % (crash_id[-6:], crash_id)
return f"v1/raw_crash/20{crash_id[-6:]}/{crash_id}"
if kind == "dump_names":
return "v1/dump_names/%s" % crash_id
return f"v1/dump_names/{crash_id}"
if kind in (None, "", "upload_file_minidump"):
kind = "dump"
return "v1/%s/%s" % (kind, crash_id)
return f"v1/{kind}/{crash_id}"


def jsonify(data):
Expand All @@ -50,18 +50,18 @@ def save_crash(storage_helper, bucket, raw_crash, dumps):
crash_id = raw_crash["uuid"]

# Save raw crash
key = generate_s3_key("raw_crash", crash_id)
key = generate_storage_key("raw_crash", crash_id)
data = jsonify(raw_crash).encode("utf-8")
storage_helper.upload(bucket, key, data)

# Save dump_names
key = generate_s3_key("dump_names", crash_id)
key = generate_storage_key("dump_names", crash_id)
data = jsonify(list(dumps.keys())).encode("utf-8")
storage_helper.upload(bucket, key, data)

# Save dumps
for name, data in dumps.items():
key = generate_s3_key(name, crash_id)
key = generate_storage_key(name, crash_id)
data = data.encode("utf-8")
storage_helper.upload(bucket, key, data)

Expand Down

0 comments on commit 00d064a

Please sign in to comment.