From c3672b476cdae13674aace3699cacd78ae47fe84 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 23 Sep 2022 21:23:15 +0300 Subject: [PATCH] test fixed to match new code --- core/TESTS/tests_logins.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py index b59a276..d69b394 100644 --- a/core/TESTS/tests_logins.py +++ b/core/TESTS/tests_logins.py @@ -13,6 +13,7 @@ from http import HTTPStatus from django.test import TestCase, SimpleTestCase, TransactionTestCase, Client from troggle.core.models.survex import Wallet +from troggle.core.models.troggle import Expedition import troggle.settings as settings @@ -80,13 +81,20 @@ class PostTests(TestCase): self.user = User.objects.get(username='expotest') self.client = Client() - wname = "2020#00" + testyear = '2022' + wname = f'{testyear}:00' + self.testyear = testyear w = Wallet() w.pk = 9100 w.fpath = str(pathlib.Path(settings.SCANS_ROOT, wname)) w.walletname = wname w.save() self.wallet = w + + e = Expedition() + e.year = testyear + e.save() + self.expedition = e def test_scan_upload(self): @@ -100,7 +108,7 @@ class PostTests(TestCase): w = self.wallet from django.contrib.auth.models import User u = User.objects.get(username='expotest') - testyear = '2049' + testyear = self.testyear self.assertTrue(u.is_active, 'User \'' + u.username + '\' is INACTIVE') logged_in = c.login(username=u.username, password='secretword') @@ -120,15 +128,15 @@ class PostTests(TestCase): phmatch = re.search(ph, content) 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) / 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)}') + # # Does not use the filename Django actually uses, assumes it is unchanged. Potential bug. + # 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):