summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-09-12 21:28:07 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-09-12 21:28:07 +0300
commitfd57071411610911913cbd3414adf3b206dead4f (patch)
tree162e1ede2913c847e2de6dea07fd784e1f594f25
parent785845598f2a18f075c1306221e07a6c0d634dda (diff)
downloadtroggle-fd57071411610911913cbd3414adf3b206dead4f.tar.gz
troggle-fd57071411610911913cbd3414adf3b206dead4f.tar.bz2
troggle-fd57071411610911913cbd3414adf3b206dead4f.zip
Fixed test to undo side-effect git commit
-rw-r--r--core/TESTS/tests_logins.py15
-rw-r--r--core/views/uploads.py2
2 files changed, 13 insertions, 4 deletions
diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py
index 4fcaac3..b59a276 100644
--- a/core/TESTS/tests_logins.py
+++ b/core/TESTS/tests_logins.py
@@ -8,6 +8,7 @@ Modified for Expo April 2021.
import unittest
import re
import pathlib
+import subprocess
from http import HTTPStatus
from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client
@@ -99,19 +100,20 @@ class PostTests(TestCase):
w = self.wallet
from django.contrib.auth.models import User
u = User.objects.get(username='expotest')
+ testyear = '2049'
self.assertTrue(u.is_active, 'User \'' + u.username + '\' is INACTIVE')
logged_in = c.login(username=u.username, password='secretword')
with open('core/fixtures/test_upload_file.txt','r') as testf:
- response = self.client.post('/scanupload/2020:00', data={'name': 'test_upload_file.txt', 'uploadfiles': testf })
+ response = self.client.post(f'/scanupload/{testyear}:00', data={'name': 'test_upload_file.txt', 'uploadfiles': testf })
content = response.content.decode()
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, HTTPStatus.OK)
with open('_test_response.html', 'w') as f:
f.write(content)
for ph in [ r'test_upload_',
- r'&larr; 2020#00 &rarr;',
+ rf'&larr; {testyear}#00 &rarr;',
r'description written',
r'Plan not required',
r'edit settings or upload a file']:
@@ -119,8 +121,15 @@ class PostTests(TestCase):
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
# Does not use the filename Django actually uses, assumes it is unchanged. Potential bug.
- remove_file = pathlib.Path(settings.SCANS_ROOT) / '2020' / '2020#00'/ 'test_upload_file.txt'
+ remove_file = pathlib.Path(settings.SCANS_ROOT) / f'{testyear}' / f'{testyear}#00'/ 'test_upload_file.txt'
remove_file.unlink()
+ # Undo the auto create and commit of a new wallet
+ cwd = settings.DRAWINGS_DATA
+ sp = subprocess.run([settings.GIT, "reset", "--hard", "master^"], cwd=cwd, capture_output=True, text=True)
+ print(f'git output: {cwd}:\n # {sp.stderr=}\n # {sp.stdout=} \n # return code: {str(sp.returncode)}')
+ if sp.returncode != 0:
+ print(f'git output: {cwd}:\n # {sp.stderr=}\n # {sp.stdout=} \n # return code: {str(sp.returncode)}')
+
def test_photo_upload(self):
'''Expect photo upload to work on any file (contrary to msg on screen)
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 6b6161d..3320386 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -495,7 +495,7 @@ def scanupload(request, path=None):
if not waldata["date"] or not waldata["people"] or waldata["people"] == ["Unknown"]: # json file does not exist, blank data, or people not typed into JSON file
# refactor into separate functions for no date set or no people set
# print(f'No date set')
- print(f'\n - Incomplete or empty wallet data {wallet} {waldata=}')
+ print(f'\n - Incomplete, empty or default wallet data {wallet} {waldata=}')
refs=[]
dates = []
team = []