1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 16:27:13 +03:00

78 Commits

Author SHA1 Message Date
Athanasius
baca42f06e JournalLock: Fix update_lock() with an extra mock
* update_lock() wants to, potentially, invoke
  JournalLock.JournalAlreadyLocked() instance for a tkinter pop-up.
  We do *not* want to mock all of that, so monkeypatch a mock so that in
  the 'test PASSED' case this just works.
2021-04-01 14:45:52 +01:00
Athanasius
8c74d46368 JournalLock: Implement update_lock() test.
* This uses a separate mock_journaldir_changing() that returns a new
  tmpdir on each invocation of config.get_str('journaldir').
2021-04-01 14:45:52 +01:00
Athanasius
0c9b841e80 JournalLock: Test release_lock()
This re-factored other_process_lock() a little for DRY reasons.
2021-04-01 14:45:52 +01:00
Athanasius
cda6d344ae JournalLock: Tag sub-process locker prints for easy reading 2021-04-01 14:45:52 +01:00
Athanasius
1a1ad86840 JournalLock: Implement non-win32 sub-process lock 2021-04-01 14:45:52 +01:00
Athanasius
6d33ee0d8b JournalLock: Use multiprocessing for 'already locked' test.
Confirmed working on Windows.
2021-04-01 14:45:52 +01:00
Athanasius
e84af6ae7f Update: "TODO" tests comments 2021-04-01 14:45:52 +01:00
Athanasius
1fca5703c1 Add self.locked asserts as check on _obtain_lock() side effects 2021-04-01 14:45:52 +01:00
Athanasius
cfdf9fbf20 Re-factor JournalLock.obtain_lock() for 'ALREADY_LOCKED' test.
This splits the code for opening the lockfile away from that for
actually obtaining the lock.  It enables a test for trying to lock again
with the same file handle.
2021-04-01 14:45:52 +01:00
Athanasius
70bdc5e0e9 Read-Only obtain_lock() test commented and cleaned up.
* Comment added about what you'd see if you could check tmpdir
  properties whilst it's set !Write.
* Deleted all the testing print()s.
2021-04-01 14:45:52 +01:00
Athanasius
ec230a9c05 Make tmpdir non-writable for the read-only test
* On win32 this uses pywin32 package modules, so that's now in
  requirements-dev.txt.
* I *think* that code is as clean as it's going to be.  Windows is a
  pain with having you *append* a Deny ACL (rather than remove an Allow
  one), and then you have to find it in all the ACLs for the object in
  order to remove it by index.
* Linux version of this using `os.chmod()` currently untested.
2021-04-01 14:45:52 +01:00
Athanasius
fbad8e240f obtain_lock() Read-Only test
Only tested under win32 so far, but I'd hope os.chmod() is the way to go
on Linux and macOS.

The win32 implementation currently relies on the pywin32 package being
installed in order to use its ntsecuritycon and win32security modules.
It might be possible to do this with ctypes instead, but this sure looks
cleaner than most ctypes code I've seen.
2021-04-01 14:45:52 +01:00
Athanasius
80b99195eb Differentiate test docstrings. 2021-04-01 14:45:52 +01:00
Athanasius
12e5d26276 Add tests on JournalLock.set_path_from_journaldir() 2021-04-01 14:45:51 +01:00
Athanasius
7bd6e8ff58 Move test & fixture into a class.
This is for then adding more tests.
2021-04-01 14:45:51 +01:00
Athanasius
c344d612ad No need to str(tmpdir), as comparison works without now. 2021-04-01 14:45:51 +01:00
Athanasius
509a1f2c2e Rename mock_get_str() to mock_journaldir() 2021-04-01 14:45:51 +01:00
Athanasius
a325c62765 Generalise mock get_str() for re-use, and add asserts
* mock get_str() is now via a fixture so it can be re-used in more than
  one test, avoiding DRY issue.
* Some actual tests, in the form of asserts, added to
  test_journal_lock_init().
2021-04-01 14:45:51 +01:00
Athanasius
8612e772cf tests/journal_lock.py: Initial framework.
No actual test per se yet, but this runs with `pytest -k 'journal_lock'`
2021-04-01 14:45:51 +01:00
Athanasius
c43343742a tests: Move the config.py related files into tests/config.py/
In general I think this will keep things neater:

1. Create a directory inside tests/ named after the file the tests are
   for.
2. Put all files for that test inside this new directory.
2021-04-01 14:45:51 +01:00
A_D
ee4451560a added regression test 2021-04-01 14:45:50 +01:00
A_D
8a81caeb8b Ensured that we save and reload the config 2021-04-01 14:45:46 +01:00
A_D
18f4e49406 Final type annotations 2021-04-01 14:45:46 +01:00
A_D
640bda0d0e Disabled mypy in old_config 2021-04-01 14:45:46 +01:00
A_D
9fd1da1819 Added space workaround to test_list 2021-04-01 14:45:46 +01:00
A_D
f8bc7290fe Made sure we dont test with big ints on windows 2021-04-01 14:45:46 +01:00
A_D
2de8967424 Delete keys only once unless on linux 2021-04-01 14:45:46 +01:00
A_D
9c3de53a3b Added config tests 2021-04-01 14:45:45 +01:00