Skip to content

Commit

Permalink
Remove legacy path storage (#10677)
Browse files Browse the repository at this point in the history
* Add a failing test

* Remove support for legacy paths
  • Loading branch information
di authored Feb 2, 2022
1 parent f116534 commit 54ebfc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
23 changes: 23 additions & 0 deletions tests/unit/packaging/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,29 @@ def test_stores_file(self, tmpdir):
assert bucket.blob.calls == [pretend.call("foo/bar.txt")]
assert blob.upload_from_filename.calls == [pretend.call(filename)]

@pytest.mark.parametrize(
"path, expected",
[
("xx/foo/bar.txt", "myprefix/xx/foo/bar.txt"),
("foo/bar.txt", "myprefix/foo/bar.txt"),
],
)
def test_stores_file_with_prefix(self, tmpdir, path, expected):
filename = str(tmpdir.join("testfile.txt"))
with open(filename, "wb") as fp:
fp.write(b"Test File!")

blob = pretend.stub(
upload_from_filename=pretend.call_recorder(lambda file_path: None),
exists=lambda: False,
)
bucket = pretend.stub(blob=pretend.call_recorder(lambda path: blob))
storage = GCSFileStorage(bucket, prefix="myprefix/")
storage.store(path, filename)

assert bucket.blob.calls == [pretend.call(expected)]
assert blob.upload_from_filename.calls == [pretend.call(filename)]

def test_stores_two_files(self, tmpdir):
filename1 = str(tmpdir.join("testfile1.txt"))
with open(filename1, "wb") as fp:
Expand Down
5 changes: 0 additions & 5 deletions warehouse/packaging/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ def __init__(self, bucket, *, prefix=None):
self.prefix = prefix

def _get_path(self, path):
# Legacy paths will have a first directory of something like 2.7, we
# want to just continue to support them for now.
if len(path.split("/")[0]) > 2:
return path

# If we have a prefix, then prepend it to our path. This will let us
# store items inside of a sub directory without exposing that to end
# users.
Expand Down

0 comments on commit 54ebfc0

Please sign in to comment.