Skip to content

Commit 8ae1fc1

Browse files
didomdfcoding
authored andcommitted
Remove legacy path storage (pypi#10677)
* Add a failing test * Remove support for legacy paths
1 parent 016f360 commit 8ae1fc1

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

tests/unit/packaging/test_services.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,29 @@ def test_stores_file(self, tmpdir):
378378
assert bucket.blob.calls == [pretend.call("foo/bar.txt")]
379379
assert blob.upload_from_filename.calls == [pretend.call(filename)]
380380

381+
@pytest.mark.parametrize(
382+
"path, expected",
383+
[
384+
("xx/foo/bar.txt", "myprefix/xx/foo/bar.txt"),
385+
("foo/bar.txt", "myprefix/foo/bar.txt"),
386+
],
387+
)
388+
def test_stores_file_with_prefix(self, tmpdir, path, expected):
389+
filename = str(tmpdir.join("testfile.txt"))
390+
with open(filename, "wb") as fp:
391+
fp.write(b"Test File!")
392+
393+
blob = pretend.stub(
394+
upload_from_filename=pretend.call_recorder(lambda file_path: None),
395+
exists=lambda: False,
396+
)
397+
bucket = pretend.stub(blob=pretend.call_recorder(lambda path: blob))
398+
storage = GCSFileStorage(bucket, prefix="myprefix/")
399+
storage.store(path, filename)
400+
401+
assert bucket.blob.calls == [pretend.call(expected)]
402+
assert blob.upload_from_filename.calls == [pretend.call(filename)]
403+
381404
def test_stores_two_files(self, tmpdir):
382405
filename1 = str(tmpdir.join("testfile1.txt"))
383406
with open(filename1, "wb") as fp:

warehouse/packaging/services.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ def __init__(self, bucket, *, prefix=None):
106106
self.prefix = prefix
107107

108108
def _get_path(self, path):
109-
# Legacy paths will have a first directory of something like 2.7, we
110-
# want to just continue to support them for now.
111-
if len(path.split("/")[0]) > 2:
112-
return path
113-
114109
# If we have a prefix, then prepend it to our path. This will let us
115110
# store items inside of a sub directory without exposing that to end
116111
# users.

0 commit comments

Comments
 (0)