forked from expo/troggle
chnage maintenance menus & move tests
This commit is contained in:
parent
785d6360cd
commit
e3a341eb22
92
core/TESTS/test_imports.py
Normal file
92
core/TESTS/test_imports.py
Normal file
@ -0,0 +1,92 @@
|
||||
"""
|
||||
We are using unittest for troggle.
|
||||
|
||||
Note that the database has not been parsed from the source files when these tests are run,
|
||||
so any path that relies on data being in the database will fail.
|
||||
|
||||
The simple redirections to files which exist, e.g. in
|
||||
/expoweb/
|
||||
/expofiles/
|
||||
/expofiles/documents/
|
||||
etc. will test fine.
|
||||
|
||||
But paths like this:
|
||||
/survey_scans/
|
||||
/caves/
|
||||
which rely on database resolution will fail unless a fixture has been set up for
|
||||
them.
|
||||
|
||||
https://docs.djangoproject.com/en/3.0/topics/testing/tools/
|
||||
"""
|
||||
import unittest
|
||||
import re
|
||||
from django.test import TestCase, SimpleTestCase, Client
|
||||
|
||||
class SimpleTest(SimpleTestCase):
|
||||
def test_test_setting(self):
|
||||
from django.conf import settings
|
||||
self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend')
|
||||
def test_import_TroggleModel(self):
|
||||
from troggle.core.models import TroggleModel
|
||||
def test_import_Cave(self):
|
||||
from troggle.core.models_caves import Cave
|
||||
def test_import_parsers_surveys(self):
|
||||
from PIL import Image
|
||||
from utils import save_carefully
|
||||
from functools import reduce
|
||||
def test_import_parsers_survex(self):
|
||||
import troggle.settings as settings
|
||||
import troggle.core.models as models
|
||||
import troggle.core.models_caves as models_caves
|
||||
import troggle.core.models_survex as models_survex
|
||||
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||
from troggle.core.views.caves import MapLocations
|
||||
def test_import_parsers_QMs(self):
|
||||
from troggle.core.models_caves import QM, Cave, LogbookEntry
|
||||
from utils import save_carefully
|
||||
def test_import_parsers_people(self):
|
||||
from html.parser import HTMLParser
|
||||
from unidecode import unidecode
|
||||
def test_import_parsers_logbooks(self):
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.timezone import get_current_timezone, make_aware
|
||||
from troggle.core.models import DataIssue, Expedition
|
||||
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip
|
||||
from parsers.people import GetPersonExpeditionNameLookup
|
||||
def test_import_core_views_caves(self):
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
import troggle.core.views.expo
|
||||
from troggle.core.models import Expedition
|
||||
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation
|
||||
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
||||
from troggle.core.views.login import login_required_if_public
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.conf import settings
|
||||
def test_import_parsers_mix(self):
|
||||
from troggle.parsers.logbooks import GetCaveLookup
|
||||
import troggle.settings
|
||||
import troggle.logbooksdump
|
||||
import troggle.parsers.caves
|
||||
import troggle.parsers.people
|
||||
import troggle.parsers.surveys
|
||||
import troggle.parsers.logbooks
|
||||
import troggle.parsers.QMs
|
||||
import troggle.parsers.survex
|
||||
def test_import_imports(self):
|
||||
from django.core import management
|
||||
from django.db import connection, close_old_connections, connections
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpResponse
|
||||
from django.urls import reverse
|
||||
|
||||
def test_import_urls(self):
|
||||
from django.conf import settings
|
||||
from django.conf.urls import url, include
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.views.generic.edit import UpdateView
|
||||
from django.views.generic.list import ListView
|
||||
from django.contrib import admin
|
||||
from django.urls import reverse, resolve
|
||||
|
||||
|
@ -22,73 +22,6 @@ import unittest
|
||||
import re
|
||||
from django.test import TestCase, SimpleTestCase, Client
|
||||
|
||||
class SimpleTest(SimpleTestCase):
|
||||
def test_test_setting(self):
|
||||
from django.conf import settings
|
||||
self.assertEqual(settings.EMAIL_BACKEND, 'django.core.mail.backends.locmem.EmailBackend')
|
||||
def test_import_TroggleModel(self):
|
||||
from troggle.core.models import TroggleModel
|
||||
def test_import_Cave(self):
|
||||
from troggle.core.models_caves import Cave
|
||||
def test_import_parsers_surveys(self):
|
||||
from PIL import Image
|
||||
from utils import save_carefully
|
||||
from functools import reduce
|
||||
def test_import_parsers_survex(self):
|
||||
import troggle.settings as settings
|
||||
import troggle.core.models as models
|
||||
import troggle.core.models_caves as models_caves
|
||||
import troggle.core.models_survex as models_survex
|
||||
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||
from troggle.core.views.caves import MapLocations
|
||||
def test_import_parsers_QMs(self):
|
||||
from troggle.core.models_caves import QM, Cave, LogbookEntry
|
||||
from utils import save_carefully
|
||||
def test_import_parsers_people(self):
|
||||
from html.parser import HTMLParser
|
||||
from unidecode import unidecode
|
||||
def test_import_parsers_logbooks(self):
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.timezone import get_current_timezone, make_aware
|
||||
from troggle.core.models import DataIssue, Expedition
|
||||
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip
|
||||
from parsers.people import GetPersonExpeditionNameLookup
|
||||
def test_import_core_views_caves(self):
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
import troggle.core.views.expo
|
||||
from troggle.core.models import Expedition
|
||||
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation
|
||||
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
|
||||
from troggle.core.views.login import login_required_if_public
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.conf import settings
|
||||
def test_import_parsers_mix(self):
|
||||
from troggle.parsers.logbooks import GetCaveLookup
|
||||
import troggle.settings
|
||||
import troggle.logbooksdump
|
||||
import troggle.parsers.caves
|
||||
import troggle.parsers.people
|
||||
import troggle.parsers.surveys
|
||||
import troggle.parsers.logbooks
|
||||
import troggle.parsers.QMs
|
||||
import troggle.parsers.survex
|
||||
def test_import_imports(self):
|
||||
from django.core import management
|
||||
from django.db import connection, close_old_connections, connections
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpResponse
|
||||
from django.urls import reverse
|
||||
|
||||
def test_import_urls(self):
|
||||
from django.conf import settings
|
||||
from django.conf.urls import url, include
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.views.generic.edit import UpdateView
|
||||
from django.views.generic.list import ListView
|
||||
from django.contrib import admin
|
||||
from django.urls import reverse, resolve
|
||||
|
||||
|
||||
#class SimplePageTest(unittest.TestCase):
|
||||
class PageTests(TestCase):
|
||||
@ -191,6 +124,25 @@ class PageTests(TestCase):
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
|
||||
|
||||
def test_expoweb_troggle_default(self):
|
||||
# default page after logon
|
||||
response = self.client.get('/troggle')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
content = response.content.decode()
|
||||
ph = r'expeditions the club has undertaken'
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
|
||||
|
||||
|
||||
def test_expoweb_troggle_default_slash(self):
|
||||
response = self.client.get('/troggle/')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
content = response.content.decode()
|
||||
ph = r"<h1>Directory not found"
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
|
||||
|
||||
|
||||
def test_expoweb_via_areaid(self):
|
||||
# the dispatcher takes a detour via the cave renering procedure for this
|
||||
response = self.client.get('/1623/others/t/via201.jpg')
|
||||
|
@ -163,6 +163,5 @@ QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]"
|
||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||
|
||||
from localsettings import *
|
||||
|
||||
#localsettings needs to take precedence. Call it to override any existing vars.
|
||||
print("+ finished importing troggle/settings.py")
|
||||
|
||||
|
@ -4,22 +4,23 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}css/main3.css" title="eyeCandy"/>
|
||||
<link rel="alternate stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}css/mainplain.css" title="plain"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}css/dropdownNavStyle.css" />
|
||||
<!-- Only used on old troggle menu removed in 2020
|
||||
<link rel="stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}css/dropdownNavStyle.css" />-->
|
||||
<title>{% block title %}Troggle{% endblock %}</title>
|
||||
<!-- <script src="{{ settings.JSLIB_URL }}jquery/jquery.min.js" type="text/javascript"></script> -->
|
||||
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
<body onLoad="contentHeight();">
|
||||
<body>
|
||||
|
||||
<div id="header">
|
||||
<h1>CUCC Expeditions to Austria: 1976 - 2021</h1>
|
||||
<div id="editLinks"> {% block loginInfo %}
|
||||
<a href="{{settings.EXPOWEB_URL}}">Website home</a> |
|
||||
{% if user.username %}
|
||||
You are logged in as {{ user.username }}
|
||||
{% if user.person %}(<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>)
|
||||
{% endif %}.
|
||||
<a href="/">Home</a> |
|
||||
<a id="cuccLink" href="http://camcaving.uk/">CUCC</a> |
|
||||
<a id="expoWebsiteLink" href="http://expo.survex.com">expo.survex</a> |
|
||||
{% if user.username %}User:{{ user.username }}
|
||||
{% if user.person %}(<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>){% endif %}
|
||||
| <a <a href='/accounts/logout/'>Log out</a> {% else %} <a href='/accounts/login/'>Log in</a> {% endif %}
|
||||
{% endblock%}
|
||||
{% block editLink %}
|
||||
@ -38,14 +39,14 @@
|
||||
<a href="{% url "expedition" 2018 %}">Expo2018</a> |
|
||||
<a href="{% url "expedition" 2019 %}">Expo2019</a> |
|
||||
<br>
|
||||
<a id="cuccLink" href="https://camcaving.uk">cucc server</a> |
|
||||
<a id="expoWebsiteLink" href="http://expo.survex.com">expo server</a> |
|
||||
|
||||
<a href="{% url "frontpage" %}">tasks to do </a> |
|
||||
<a href="/handbook/computing/onlinesystems.html">handbook</a> |
|
||||
<a href="/handbook/computing/todo-data.html">tasks to do </a> |
|
||||
<a id="cavesLink" href="{% url "caveindex" %}">caves</a> |
|
||||
<a id="caversLink" href="{% url "personindex" %}">people</a> |
|
||||
<a id="folklink" href="/folk">expoers</a> |
|
||||
<a id="caversLink" href="{% url "personindex" %}">survey lengths</a> |
|
||||
<a href="{% url "stats" %}">expo statistics</a> |
|
||||
<a href="{% url "controlpanel" %}">import/export data</a>
|
||||
<a href="{% url "controlpanel" %}">import/export</a> |
|
||||
<a href="/admin/">Django admin</a>
|
||||
</div>
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
{% block title %}Cambridge Expeditions to Austria{% endblock %}
|
||||
|
||||
{% block related %}
|
||||
<h2>Recent Actions - admin user</h5>
|
||||
<!--
|
||||
<h2>Recent Actions - expoadmin</h5>
|
||||
{% load log %}
|
||||
{% get_admin_log 10 as admin_log for_user 1 %}
|
||||
{% if not admin_log %}
|
||||
@ -29,21 +30,30 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>This is not fully working currently</h2>
|
||||
<h2>The code behind this page is under repair</h2>
|
||||
-->
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<style>
|
||||
ul {list-style: disc}
|
||||
</style>
|
||||
<h2>You are now logged in</h2>
|
||||
<p>Now you can:
|
||||
<ul>
|
||||
<li>Use 'Edit This Page' to fix errors in the online handbook webpages
|
||||
<li>Edit the data on an existing cave description
|
||||
<li>Create a new cave description for a new cave, including all cave discovery data
|
||||
<li>Edit the data on an existing entrance description
|
||||
<li>Create a new cave description for a new cave, including all entrance discovery data
|
||||
<li>Edit any archived survex file online
|
||||
<li>Upload or type in new survex data for a new trip (see below)
|
||||
</ul>
|
||||
|
||||
<p>See the logged-in status indicator in the top-right of the page, in gray in the banner picture.
|
||||
<!--<h2>Expo member tasks</h2>-->
|
||||
|
||||
<h3>Expo member tasks</h3>
|
||||
<h3>Add new data</h3>
|
||||
<h3></h3>
|
||||
|
||||
<li><a href="">Upload a photo</a></li>
|
||||
<li><a href="">Upload a GPS track</a></li>
|
||||
<li><a href="">Upload a Tunnel or Therion drawing</a></li>
|
||||
<li><a href="/survexfile/caves-1623/999/999.svx">Upload or type in a Survex file</a></li>
|
||||
|
||||
<h3>Unfinished wallets work to do:</h3>
|
||||
<a href="/expofiles/surveyscans/2016/walletindex.html">2016 wallets</a><br>
|
||||
@ -51,18 +61,31 @@
|
||||
<a href="/expofiles/surveyscans/2018/walletindex.html">2018 wallets</a><br>
|
||||
<a href="/expofiles/surveyscans/2019/walletindex.html">2019 wallets</a><br>
|
||||
|
||||
<h3>Upload new data</h3>
|
||||
<ul>
|
||||
|
||||
<li><a style="color:grey"href=""><font style="color:grey">Upload a photo</font></a></li>
|
||||
<li><a style="color:grey" href="">Upload a GPS track</a></li>
|
||||
<li><a style="color:grey"href="">Upload a Tunnel or Therion drawing</a></li>
|
||||
|
||||
<li><a href="/survexfile/caves-1623/999/999.svx">Upload or type in a Survex file</a> - overwrite the area/number data in the browser title bar after the page loads, from 'caves-1623/999/999.svx' to whatever you need for your cave.
|
||||
</ul>
|
||||
<p>
|
||||
<h3>Unfinished surveys</h3>
|
||||
{% for survey in surveys_unfinished %}
|
||||
<li>{{survey|link}}</li>
|
||||
{% empty %}
|
||||
[none found in database[surveys_unfinished]]
|
||||
{% endfor %}
|
||||
|
||||
<h3>Caving QM recommendations</h3>
|
||||
{% for qm in qms_recommended %}
|
||||
<li>{{qm|link}}</li>
|
||||
{% empty %}
|
||||
[none found in database[qms_recommended]]
|
||||
{% endfor %}
|
||||
|
||||
{% endblock content %}
|
||||
|
||||
{% block margins %}
|
||||
<img class="leftMargin eyeCandy fadeIn" src="{{ settings.MEDIA_URL }}eieshole.jpg">
|
||||
<img class="rightMargin eyeCandy fadeIn" src="{{ settings.MEDIA_URL }}goesser.jpg">
|
||||
{% endblock margins %}
|
||||
|
Loading…
Reference in New Issue
Block a user