31
31
from wtforms .form import Form
32
32
from wtforms .validators import ValidationError
33
33
34
- from tests .common .db .organizations import (
35
- OrganizationFactory ,
36
- OrganizationProjectFactory ,
37
- OrganizationRoleFactory ,
38
- TeamFactory ,
39
- TeamProjectRoleFactory ,
40
- TeamRoleFactory ,
41
- )
42
34
from warehouse .admin .flags import AdminFlag , AdminFlagValue
43
35
from warehouse .classifiers .models import Classifier
44
36
from warehouse .errors import BasicAuthTwoFactorEnabled
@@ -85,13 +77,6 @@ def _get_whl_testdata(name="fake_package", version="1.0"):
85
77
return temp_f .getvalue ()
86
78
87
79
88
- def _get_egg_testdata ():
89
- temp_f = io .BytesIO ()
90
- with zipfile .ZipFile (file = temp_f , mode = "w" ) as zfp :
91
- zfp .writestr ("fake_package/PKG-INFO" , "Fake metadata" )
92
- return temp_f .getvalue ()
93
-
94
-
95
80
def _storage_hash (data ):
96
81
return hashlib .blake2b (data , digest_size = 256 // 8 ).hexdigest ()
97
82
@@ -107,12 +92,6 @@ def _storage_hash(data):
107
92
_TAR_BZ2_PKG_STORAGE_HASH = _storage_hash (_TAR_BZ2_PKG_TESTDATA )
108
93
109
94
110
- _EGG_PKG_TESTDATA = _get_egg_testdata ()
111
- _EGG_PKG_MD5 = hashlib .md5 (_EGG_PKG_TESTDATA ).hexdigest ()
112
- _EGG_PKG_SHA256 = hashlib .sha256 (_EGG_PKG_TESTDATA ).hexdigest ()
113
- _EGG_PKG_STORAGE_HASH = _storage_hash (_EGG_PKG_TESTDATA )
114
-
115
-
116
95
class TestExcWithMessage :
117
96
def test_exc_with_message (self ):
118
97
exc = legacy ._exc_with_message (HTTPBadRequest , "My Test Message." )
@@ -510,7 +489,6 @@ def test_defaults_to_true(self):
510
489
("filename" , "filetype" ),
511
490
[
512
491
("test.zip" , "sdist" ),
513
- ("test.egg" , "bdist_egg" ),
514
492
("test.whl" , "bdist_wheel" ),
515
493
],
516
494
)
@@ -610,23 +588,6 @@ def test_zipfile_exceeds_compression_threshold(self, tmpdir):
610
588
611
589
assert not legacy ._is_valid_dist_file (f , "" )
612
590
613
- def test_egg_no_pkg_info (self , tmpdir ):
614
- f = str (tmpdir .join ("test.egg" ))
615
-
616
- with zipfile .ZipFile (f , "w" ) as zfp :
617
- zfp .writestr ("something.txt" , b"Just a placeholder file" )
618
-
619
- assert not legacy ._is_valid_dist_file (f , "bdist_egg" )
620
-
621
- def test_egg_has_pkg_info (self , tmpdir ):
622
- f = str (tmpdir .join ("test.egg" ))
623
-
624
- with zipfile .ZipFile (f , "w" ) as zfp :
625
- zfp .writestr ("something.txt" , b"Just a placeholder file" )
626
- zfp .writestr ("PKG-INFO" , b"this is the package info" )
627
-
628
- assert legacy ._is_valid_dist_file (f , "bdist_egg" )
629
-
630
591
def test_wheel_no_wheel_file (self , tmpdir ):
631
592
f = str (tmpdir .join ("test.whl" ))
632
593
@@ -1594,9 +1555,9 @@ def test_upload_fails_with_legacy_ext(self, pyramid_config, db_request):
1594
1555
1595
1556
assert resp .status_code == 400
1596
1557
assert resp .status == (
1597
- "400 Invalid file extension: Use .egg, . tar.gz, .whl or .zip "
1558
+ "400 Invalid file extension: Use .tar.gz, .whl or .zip "
1598
1559
"extension. See https://www.python.org/dev/peps/pep-0527 "
1599
- "for more information. "
1560
+ "and https://peps.python.org/pep-0715/ for more information"
1600
1561
)
1601
1562
1602
1563
def test_upload_fails_for_second_sdist (self , pyramid_config , db_request ):
@@ -2314,15 +2275,12 @@ def test_upload_fails_with_diff_filename_same_blake2(
2314
2275
# completely different
2315
2276
("nope-{version}.tar.gz" , "something_else" ),
2316
2277
("nope-{version}-py3-none-any.whl" , "something_else" ),
2317
- ("nope-{version}-py3-none-any.egg" , "something_else" ),
2318
2278
# starts with same prefix
2319
2279
("nope-{version}.tar.gz" , "no" ),
2320
2280
("nope-{version}-py3-none-any.whl" , "no" ),
2321
- ("nope-{version}-py3-none-any.egg" , "no" ),
2322
2281
# starts with same prefix with hyphen
2323
2282
("no-way-{version}.tar.gz" , "no" ),
2324
2283
("no_way-{version}-py3-none-any.whl" , "no" ),
2325
- ("no_way-{version}-py3-none-any.egg" , "no" ),
2326
2284
# multiple delimiters
2327
2285
("foo__bar-{version}-py3-none-any.whl" , "foo-.bar" ),
2328
2286
],
@@ -2407,9 +2365,9 @@ def test_upload_fails_with_invalid_extension(self, pyramid_config, db_request):
2407
2365
2408
2366
assert resp .status_code == 400
2409
2367
assert resp .status == (
2410
- "400 Invalid file extension: Use .egg, . tar.gz, .whl or .zip "
2368
+ "400 Invalid file extension: Use .tar.gz, .whl or .zip "
2411
2369
"extension. See https://www.python.org/dev/peps/pep-0527 "
2412
- "for more information. "
2370
+ "and https://peps.python.org/pep-0715/ for more information"
2413
2371
)
2414
2372
2415
2373
@pytest .mark .parametrize ("character" , ["/" , "\\ " ])
@@ -3921,111 +3879,6 @@ def test_fails_without_user(self, pyramid_config, pyramid_request):
3921
3879
"See /the/help/url/ for more information."
3922
3880
)
3923
3881
3924
- def test_egg_upload_sends_pep_715_notice (
3925
- self , pyramid_config , db_request , metrics , monkeypatch
3926
- ):
3927
- user = UserFactory .create ()
3928
- EmailFactory .create (user = user )
3929
- project = ProjectFactory .create ()
3930
- RoleFactory .create (user = user , project = project )
3931
-
3932
- pyramid_config .testing_securitypolicy (identity = user )
3933
- db_request .user = user
3934
- db_request .user_agent = "warehouse-tests/6.6.6"
3935
- db_request .POST = MultiDict (
3936
- {
3937
- "metadata_version" : "1.2" ,
3938
- "name" : project .name ,
3939
- "version" : "1.0.0" ,
3940
- "summary" : "This is my summary!" ,
3941
- "filetype" : "bdist_egg" ,
3942
- "pyversion" : "2.7" ,
3943
- "md5_digest" : _EGG_PKG_MD5 ,
3944
- "content" : pretend .stub (
3945
- filename = "{}-{}.egg" .format (project .name , "1.0.0" ),
3946
- file = io .BytesIO (_EGG_PKG_TESTDATA ),
3947
- type = "application/zip" ,
3948
- ),
3949
- }
3950
- )
3951
-
3952
- send_email = pretend .call_recorder (lambda * a , ** kw : None )
3953
- monkeypatch .setattr (legacy , "send_egg_uploads_deprecated_email" , send_email )
3954
-
3955
- storage_service = pretend .stub (store = lambda path , filepath , meta : None )
3956
- db_request .find_service = lambda svc , name = None , context = None : {
3957
- IFileStorage : storage_service ,
3958
- IMetricsService : metrics ,
3959
- }.get (svc )
3960
-
3961
- resp = legacy .file_upload (db_request )
3962
-
3963
- assert resp .status_code == 200
3964
- assert send_email .calls == [
3965
- pretend .call (db_request , user , project_name = project .name )
3966
- ]
3967
-
3968
- def test_egg_upload_sends_pep_715_notice_org_roles (
3969
- self , pyramid_config , db_request , metrics , monkeypatch
3970
- ):
3971
- user = UserFactory .create ()
3972
- EmailFactory .create (user = user )
3973
- project = ProjectFactory .create ()
3974
- RoleFactory .create (user = user , project = project )
3975
-
3976
- org = OrganizationFactory ()
3977
- OrganizationProjectFactory (organization = org , project = project )
3978
- org_owner = UserFactory .create ()
3979
- OrganizationRoleFactory .create (user = org_owner , organization = org )
3980
-
3981
- org_member = UserFactory .create ()
3982
- OrganizationRoleFactory .create (
3983
- user = org_member , organization = org , role_name = "Member"
3984
- )
3985
- team = TeamFactory .create (organization = org )
3986
- TeamRoleFactory .create (team = team , user = org_member )
3987
- # Duplicate the role directly on the project to ensure only one email
3988
- RoleFactory .create (user = org_member , project = project , role_name = "Maintainer" )
3989
- TeamProjectRoleFactory .create (project = project , team = team )
3990
-
3991
- pyramid_config .testing_securitypolicy (identity = user )
3992
- db_request .user = user
3993
- db_request .user_agent = "warehouse-tests/6.6.6"
3994
- db_request .POST = MultiDict (
3995
- {
3996
- "metadata_version" : "1.2" ,
3997
- "name" : project .name ,
3998
- "version" : "1.0.0" ,
3999
- "summary" : "This is my summary!" ,
4000
- "filetype" : "bdist_egg" ,
4001
- "pyversion" : "2.7" ,
4002
- "md5_digest" : _EGG_PKG_MD5 ,
4003
- "content" : pretend .stub (
4004
- filename = "{}-{}.egg" .format (project .name , "1.0.0" ),
4005
- file = io .BytesIO (_EGG_PKG_TESTDATA ),
4006
- type = "application/zip" ,
4007
- ),
4008
- }
4009
- )
4010
-
4011
- send_email = pretend .call_recorder (lambda * a , ** kw : None )
4012
- monkeypatch .setattr (legacy , "send_egg_uploads_deprecated_email" , send_email )
4013
-
4014
- storage_service = pretend .stub (store = lambda path , filepath , meta : None )
4015
- db_request .find_service = lambda svc , name = None , context = None : {
4016
- IFileStorage : storage_service ,
4017
- IMetricsService : metrics ,
4018
- }.get (svc )
4019
-
4020
- resp = legacy .file_upload (db_request )
4021
-
4022
- assert resp .status_code == 200
4023
- assert set (send_email .calls ) == {
4024
- pretend .call (db_request , user , project_name = project .name ),
4025
- pretend .call (db_request , org_owner , project_name = project .name ),
4026
- pretend .call (db_request , org_member , project_name = project .name ),
4027
- }
4028
-
4029
3882
4030
3883
def test_submit (pyramid_request ):
4031
3884
resp = legacy .submit (pyramid_request )
0 commit comments