From 18541de37143a91bcf937503971420c804c8388a Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 2 Feb 2023 14:51:20 +0000 Subject: [PATCH] test file permissions --- core/TESTS/tests_logins.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py index 0e6da96..81ba976 100644 --- a/core/TESTS/tests_logins.py +++ b/core/TESTS/tests_logins.py @@ -102,6 +102,33 @@ class PostTests(TestCase): e.save() self.expedition = e + def test_file_permissions(self): + """Expect to be allowed to write to expofiles + Need to login first. + """ + c = self.client + from django.contrib.auth.models import User + + u = User.objects.get(username="expotest") + testyear = self.testyear + + self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE") + c.login(username=u.username, password="secretword") + + for p in [settings.SCANS_ROOT, + settings.DRAWINGS_DATA / "walletjson", + settings.EXPOWEB / "documents", + settings.SURVEX_DATA / "docs" + ]: + + _test_file_path = pathlib.Path(p, "_created_by_test_suite.txt") + self.assertEqual(_test_file_path.is_file(), False) + + with open(_test_file_path, "w") as f: + f.write("test string: can we write to this directory?") + self.assertEqual(_test_file_path.is_file(), True) + #_test_file_path.unlink() + def test_scan_upload(self): """Expect scan upload to wallet to work on any file Need to login first.