ruf cleanup imports, bigly.

This commit is contained in:
2023-01-30 23:04:11 +00:00
parent e35fccea5d
commit 3aca0d0c76
29 changed files with 165 additions and 325 deletions

View File

@@ -26,10 +26,8 @@ todo = """ADD TESTS when we are redirecting /expofiles/ to a remote file-deliver
"""
import re
import unittest
from http import HTTPStatus
from django.test import Client, SimpleTestCase, TestCase
from django.test import Client, TestCase
# class SimplePageTest(unittest.TestCase):
@@ -76,12 +74,12 @@ class PageTests(TestCase):
def test_expoweb_dir(self):
response = self.client.get("/handbook")
content = response.content.decode()
response.content.decode()
self.assertEqual(response.status_code, 302) # directory, so redirects to /index.htm
def test_expoweb_dirslash(self):
response = self.client.get("/handbook/")
content = response.content.decode()
response.content.decode()
self.assertEqual(response.status_code, 302) # directory, so redirects to /index.htm
def test_expoweb_dir_no_index(self):
@@ -211,7 +209,7 @@ class PageTests(TestCase):
def test_page_admindocs_exped(self):
# Get redirected to login page
response = self.client.get("/admin/doc/models/core.expedition/")
content = response.content.decode()
response.content.decode()
self.assertEqual(response.status_code, 302)
def test_page_expofiles_root_dir(self):

View File

@@ -3,12 +3,11 @@ Modified for Expo April 2021.
"""
import re
import unittest
from django.test import Client, SimpleTestCase, TestCase
from django.test import Client, TestCase
from troggle.core.models.caves import Area, Cave
from troggle.core.models.troggle import Expedition, Person, PersonExpedition
from troggle.core.models.troggle import Person, PersonExpedition
class FixtureTests(TestCase):

View File

@@ -7,14 +7,12 @@ Modified for Expo April 2021.
import pathlib
import re
import subprocess
import unittest
from http import HTTPStatus
from django.test import Client, SimpleTestCase, TestCase, TransactionTestCase
from django.test import Client, TestCase
import troggle.settings as settings
from troggle.core.models.survex import Wallet
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import Expedition
@@ -112,14 +110,13 @@ class PostTests(TestCase):
identified in the wallet
"""
c = self.client
w = self.wallet
from django.contrib.auth.models import User
u = User.objects.get(username="expotest")
testyear = self.testyear
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
logged_in = c.login(username=u.username, password="secretword")
c.login(username=u.username, password="secretword")
with open("core/fixtures/test_upload_file.txt", "r") as testf:
response = self.client.post(
@@ -162,7 +159,7 @@ class PostTests(TestCase):
u = User.objects.get(username="expotest")
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
logged_in = c.login(username=u.username, password="secretword")
c.login(username=u.username, password="secretword")
with open("core/fixtures/test_upload_file.txt", "r") as testf:
response = self.client.post(
@@ -199,7 +196,7 @@ class PostTests(TestCase):
u = User.objects.get(username="expotest")
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
logged_in = c.login(username=u.username, password="secretword")
c.login(username=u.username, password="secretword")
rename = "RENAMED-FILE.JPG"
with open("core/fixtures/test_upload_file.txt", "r") as testf:
@@ -231,7 +228,7 @@ class PostTests(TestCase):
u = User.objects.get(username="expotest")
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
logged_in = c.login(username=u.username, password="secretword")
c.login(username=u.username, password="secretword")
response = self.client.post("/photoupload/", data={"photographer": "GussieFinkNottle"})
content = response.content.decode()
@@ -257,7 +254,7 @@ class PostTests(TestCase):
u = User.objects.get(username="expotest")
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
logged_in = c.login(username=u.username, password="secretword")
c.login(username=u.username, password="secretword")
with open("core/fixtures/test_upload_file.pdf", "r") as testf:
response = self.client.post(
@@ -279,7 +276,7 @@ class PostTests(TestCase):
u = User.objects.get(username="expotest")
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
logged_in = c.login(username=u.username, password="secretword")
c.login(username=u.username, password="secretword")
with open("core/fixtures/test_upload_nosuffix", "r") as testf:
response = self.client.post(
@@ -383,7 +380,6 @@ class ComplexLoginTests(TestCase):
self.assertIsNotNone(t, "Logged in as '" + u.username + "' but failed to get the Troggle Admin page")
def test_noinfo_login(self):
from django.contrib.auth.models import User
c = self.client # inherited from TestCase
u = self.user
@@ -401,7 +397,6 @@ class ComplexLoginTests(TestCase):
self.assertIsNotNone(t, "Logged in as '" + u.username + "' but failed to get /noinfo/ content")
def test_user_force(self):
from django.conf import settings
c = self.client
u = self.user