mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-02 19:02:31 +00:00
test(monitor): support discovery without TMPDIR
This commit is contained in:
@@ -60,6 +60,10 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PYTHONDONTWRITEBYTECODE: '1'
|
PYTHONDONTWRITEBYTECODE: '1'
|
||||||
run: python3 -I -B .github/scripts/run_offline_qualified.py --lane python
|
run: python3 -I -B .github/scripts/run_offline_qualified.py --lane python
|
||||||
|
- name: Run health recurrence tests without TMPDIR
|
||||||
|
env:
|
||||||
|
PYTHONDONTWRITEBYTECODE: '1'
|
||||||
|
run: env -u TMPDIR python3 -I -B -m unittest discover -s AppImage/scripts/tests -p test_health_persistence_recurrence.py -v
|
||||||
|
|
||||||
offline-node:
|
offline-node:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
"""Offline recurrence tests against the complete, real persistence module.
|
"""Offline recurrence tests against the complete, real persistence module.
|
||||||
|
|
||||||
From the repository root (stdlib only; no broad test discovery):
|
From the repository root (stdlib only; no broad test discovery):
|
||||||
TMPDIR=/path/to/private/scratch python3 -I -B -m unittest discover \
|
python3 -I -B -m unittest discover \
|
||||||
-s AppImage/scripts/tests -p test_health_persistence_recurrence.py -v
|
-s AppImage/scripts/tests -p test_health_persistence_recurrence.py -v
|
||||||
|
|
||||||
TMPDIR must already exist and must not be the system temporary directory.
|
Each test creates and removes its own private temporary directory.
|
||||||
|
No temporary-directory environment variable is required.
|
||||||
Only the data-directory Path boundary and datetime clock are redirected, before
|
Only the data-directory Path boundary and datetime clock are redirected, before
|
||||||
module execution (including the real global constructor). No persistence method
|
module execution (including the real global constructor). No persistence method
|
||||||
is stubbed. Every test has its own real SQLite DB. Audit guards constrain DB
|
is stubbed. Every test has its own real SQLite DB. Audit guards constrain DB
|
||||||
@@ -101,12 +102,7 @@ class FrozenDatetime(datetime):
|
|||||||
class HealthPersistenceRecurrenceTests(unittest.TestCase):
|
class HealthPersistenceRecurrenceTests(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
global _AUDIT_SCOPE
|
global _AUDIT_SCOPE
|
||||||
scratch = os.environ.get('TMPDIR')
|
temporary = tempfile.TemporaryDirectory(prefix='health-recurrence-')
|
||||||
if not scratch or not Path(scratch).is_dir():
|
|
||||||
self.fail('Set TMPDIR to an existing private scratch directory')
|
|
||||||
if Path(scratch).resolve() in (Path('/tmp'), Path('/var/tmp')):
|
|
||||||
self.fail('System temporary directories are not allowed')
|
|
||||||
temporary = tempfile.TemporaryDirectory(prefix='health-recurrence-', dir=scratch)
|
|
||||||
self.addCleanup(temporary.cleanup)
|
self.addCleanup(temporary.cleanup)
|
||||||
self.data_dir = Path(temporary.name)
|
self.data_dir = Path(temporary.name)
|
||||||
self.scope = {'root': self.data_dir, 'db': self.data_dir / 'health_monitor.db',
|
self.scope = {'root': self.data_dir, 'db': self.data_dir / 'health_monitor.db',
|
||||||
|
|||||||
Reference in New Issue
Block a user