mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
test: each app keeps its tests in a tests package
131 test modules sat next to the code they test; instances alone had 51 of them beside views.py and utils.py. They move into a tests/ package per app, and the JavaScript checks into webvirtcloud/tests/js. Each non-empty tests.py becomes tests/test_views.py; the empty generated stubs are removed. Imports of the app's own modules become absolute, paths built from __file__ go one level up, the live helper is instances.tests.livetest, and coverage omits */tests/*. The suite discovers the same 960 tests as before.
This commit is contained in:
parent
0906838193
commit
c55f52f025
154 changed files with 27 additions and 39 deletions
|
|
@ -1,26 +0,0 @@
|
|||
"""After saving a user, the edit page goes back to ?next= only on this site."""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
LIMITS = {"max_instances": 1, "max_cpus": 1, "max_memory": 1024, "max_disk_size": 4}
|
||||
|
||||
|
||||
class UserUpdateNextTests(TestCase):
|
||||
def setUp(self):
|
||||
self.client.force_login(User.objects.create_superuser("un-admin", "un@example.com", "pw"))
|
||||
self.user = User.objects.create_user("un-user", password="pw")
|
||||
|
||||
def save(self, next_url):
|
||||
url = reverse("admin:user_update", args=[self.user.id]) + "?next=" + next_url
|
||||
return self.client.post(url, {"username": "un-user", "is_active": "on", **LIMITS})
|
||||
|
||||
def test_a_page_of_this_site(self):
|
||||
account = reverse("accounts:account", args=[self.user.id])
|
||||
self.assertRedirects(self.save(account), account, fetch_redirect_response=False)
|
||||
|
||||
def test_another_site_is_not_followed(self):
|
||||
for next_url in ("https://evil.example/", "//evil.example/", "/\\evil.example/"):
|
||||
with self.subTest(next_url=next_url):
|
||||
self.assertRedirects(self.save(next_url), reverse("admin:user_list"), fetch_redirect_response=False)
|
||||
Loading…
Add table
Add a link
Reference in a new issue