2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 21:37:20 +00:00

tidy trailing slash everywhere & fix tests

This commit is contained in:
2025-02-19 16:00:53 +02:00
parent cc06e2e1f4
commit a950cc60d9
14 changed files with 141 additions and 49 deletions

View File

@@ -96,6 +96,7 @@ class SimpleTest(SimpleTestCase):
import troggle.parsers.QMs
import troggle.parsers.scans
import troggle.parsers.survex
import troggle.parsers.users
import troggle.settings
from troggle.parsers.logbooks import GetCaveLookup
@@ -106,6 +107,14 @@ class SimpleTest(SimpleTestCase):
from django.http import HttpResponse
from django.urls import reverse
def test_import_users_urls(self):
import base64
import json
import os
from cryptography.fernet import Fernet
from pathlib import Path
from django.contrib.auth.models import User
def test_import_urls(self):
from django.conf import settings

View File

@@ -187,7 +187,7 @@ class PostTests(TestCase):
with open("core/fixtures/test_upload_file.txt", "r") as testf:
response = self.client.post(
"/photoupload/", data={"name": "test_upload_file.txt", "renameto": "", "uploadfiles": testf}
"/photoupload", data={"name": "test_upload_file.txt", "renameto": "", "uploadfiles": testf}
)
content = response.content.decode()
self.assertEqual(response.status_code, HTTPStatus.OK)
@@ -224,7 +224,7 @@ class PostTests(TestCase):
rename = "RENAMED-FILE.JPG"
with open("core/fixtures/test_upload_file.txt", "r") as testf:
response = self.client.post(
"/photoupload/", data={"name": "test_upload_file.txt", "renameto": rename, "uploadfiles": testf}
"/photoupload", data={"name": "test_upload_file.txt", "renameto": rename, "uploadfiles": testf}
)
content = response.content.decode()
self.assertEqual(response.status_code, HTTPStatus.OK)
@@ -255,11 +255,11 @@ class PostTests(TestCase):
self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE")
c.login(username=u.username, password="secretword")
response = self.client.post("/photoupload/", data={"photographer": "GussieFinkNottle"})
response = self.client.post("/photoupload", data={"photographer": "GussieFinkNottle"})
content = response.content.decode()
self.assertEqual(response.status_code, HTTPStatus.OK)
# with open('_test_response.html', 'w') as f:
# f.write(content)
# f.write(content)
for ph in [r"Create new Photographer folder", r"/GussieFinkNottle/"]:
phmatch = re.search(ph, content)
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'")

View File

@@ -206,7 +206,7 @@ class ImportTest(TestCase):
def test_survexfiles(self):
# Needs another test with test data
response = self.client.get("/survexfile/caves/")
response = self.client.get("/survexfile/caves")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
# with open('_test_response.html', 'w') as f:

View File

@@ -141,18 +141,17 @@ class URLTests(TestCase):
def test_url_allscans(self):
"""Test the {% url "allscans" %} reverse resolution
path('survey_scans/', allscans, name="allscans"), # all the scans in all wallets
path('survey_scans', allscans, name="allscans"), # all the scans in all wallets
"""
reversed_url = reverse('allscans') # NB _ must be written as - if present in name
self.assertEqual(reversed_url, "/survey_scans/")
self.assertEqual(reversed_url, "/survey_scans")
def test_url_survexcaveslist(self):
"""Test the {% url "allscans" %} reverse resolution
path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"),
path('survexfile/caves/', survex.survexcaveslist, name="survexcaveslist"), # auto slash not working
"""
reversed_url = reverse('survexcaveslist') # NB _ must be written as - if present in name
self.assertEqual(reversed_url, "/survexfile/caves/")
self.assertEqual(reversed_url, "/survexfile/caves")
def test_url_threed(self):
"""Test the {% url "threed" %} reverse resolution

View File

@@ -457,7 +457,7 @@ class PageTests(TestCase):
def test_page_dwgallfiles_empty_slash(self):
# this gets an empty page as the database has not been loaded
response = self.client.get("/dwgfiles/")
response = self.client.get("/dwgfiles")
self.assertEqual(response.status_code, HTTPStatus.OK)
content = response.content.decode()
for ph in [