forked from expo/troggle
Fixed test to undo side-effect git commit
This commit is contained in:
parent
785845598f
commit
fd57071411
@ -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'← 2020#00 →',
|
||||
rf'← {testyear}#00 →',
|
||||
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)
|
||||
|
@ -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 = []
|
||||
|
Loading…
Reference in New Issue
Block a user