diff --git a/tests/unit/admin/views/test_projects.py b/tests/unit/admin/views/test_projects.py index 1e3cfe0ff56a..349fd87d0a4d 100644 --- a/tests/unit/admin/views/test_projects.py +++ b/tests/unit/admin/views/test_projects.py @@ -354,21 +354,21 @@ def test_sets_limitwith_integer(self, db_request): flash=pretend.call_recorder(lambda *a, **kw: None), ) db_request.matchdict["project_name"] = project.normalized_name - db_request.POST["upload_limit"] = "12345" + db_request.POST["upload_limit"] = "90" views.set_upload_limit(project, db_request) assert db_request.session.flash.calls == [ pretend.call( - "Successfully set the upload limit on 'foo' to 12345", + "Successfully set the upload limit on 'foo'.", queue="success"), ] - assert project.upload_limit == 12345 + assert project.upload_limit == 90 * views.ONE_MB def test_sets_limit_with_none(self, db_request): project = ProjectFactory.create(name="foo") - project.upload_limit = 12345 + project.upload_limit = 90 * views.ONE_MB db_request.route_path = pretend.call_recorder( lambda *a, **kw: "/admin/projects/") @@ -381,13 +381,13 @@ def test_sets_limit_with_none(self, db_request): assert db_request.session.flash.calls == [ pretend.call( - "Successfully set the upload limit on 'foo' to None", + "Successfully set the upload limit on 'foo'.", queue="success"), ] assert project.upload_limit is None - def test_sets_limit_with_bad_value(self, db_request): + def test_sets_limit_with_non_integer(self, db_request): project = ProjectFactory.create(name="foo") db_request.matchdict["project_name"] = project.normalized_name @@ -395,3 +395,12 @@ def test_sets_limit_with_bad_value(self, db_request): with pytest.raises(HTTPBadRequest): views.set_upload_limit(project, db_request) + + def test_sets_limit_with_less_than_minimum(self, db_request): + project = ProjectFactory.create(name="foo") + + db_request.matchdict["project_name"] = project.normalized_name + db_request.POST["upload_limit"] = "20" + + with pytest.raises(HTTPBadRequest): + views.set_upload_limit(project, db_request) diff --git a/warehouse/admin/templates/admin/projects/detail.html b/warehouse/admin/templates/admin/projects/detail.html index 4c7cea25c1c7..8f798e33743f 100644 --- a/warehouse/admin/templates/admin/projects/detail.html +++ b/warehouse/admin/templates/admin/projects/detail.html @@ -54,7 +54,13 @@