1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 17:12:21 +03:00

2958 Commits

Author SHA1 Message Date
Athanasius
3a80d77997 Contributing.md: We use pytest and a particular file layout for tests. 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
f53dcd92e5 Fix small typo in JournalLock.set_path_from_journaldir() docstring 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
Athanasius
bfb7780efc Version to 4.2.0-beta1 to distinguish Python 3.8 builds
* I don't want to be checking something against 4.1.x releases when my
  last build was with Python 3.8.

# Conflicts:
#	config.py
2021-04-01 14:45:51 +01:00
Athanasius
5a38537294 docs: General update for main now using Python 3.9 & misc
* Extend EDCD copyright into 2021 here as well.
* Recommend *against* any attempt at making plugins also work with
  Python 2.7.
* setup.py no longer writes appcast files.  Mention
  edmarketconnector.xml enclosure instead for the url= bit.
* DRY about location of log files, just point to appropriate wiki link.
2021-04-01 14:45:51 +01:00
A_D
557e88bc44 removed extra check 2021-04-01 14:45:51 +01:00
A_D
b7c20facdd Fix spurious modules or ships was None
Nothing other than /shipyard actually returns the modules and ships
data, so checking for it anywhere other than that automatically is just
asking for extra log noise and nothing else.
2021-04-01 14:45:51 +01:00
Athanasius
99cbbf1cf8 Releasing.md: .pre-commit-config.yaml may need python version updating also. 2021-04-01 14:45:51 +01:00
Athanasius
bbb99eff2c Releasing.md: Update .python-version as needed. 2021-04-01 14:45:51 +01:00
Athanasius
a40091c36c Add .python-version file
At the very least `pyenv` uses this as a signal for the version of
Python that should be used.  See:

	<https://github.com/pyenv/pyenv#choosing-the-python-version>
2021-04-01 14:45:51 +01:00
Athanasius
c0bf09d974 setup.py: Fix whitespace before comments 2021-04-01 14:45:51 +01:00
Athanasius
8a3176c67d setup.py: Fix win32 OPTIONS formatting 2021-04-01 14:45:51 +01:00
Athanasius
732cfa1192 journal_lock: No need for exc_info=True on logger.exception() 2021-04-01 14:45:51 +01:00
Athanasius
bc33bf1b19 Attempt to get develop back to code state before rebase on main. 2021-04-01 14:45:51 +01:00
dependabot[bot]
7fc5144121 Bump isort from 5.7.0 to 5.8.0
Bumps [isort](https://github.com/pycqa/isort) from 5.7.0 to 5.8.0.
- [Release notes](https://github.com/pycqa/isort/releases)
- [Changelog](https://github.com/PyCQA/isort/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/pycqa/isort/compare/5.7.0...5.8.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 14:45:51 +01:00
dependabot[bot]
cc49a53556 Bump flake8-docstrings from 1.5.0 to 1.6.0
Bumps [flake8-docstrings](https://gitlab.com/pycqa/flake8-docstrings) from 1.5.0 to 1.6.0.
- [Release notes](https://gitlab.com/pycqa/flake8-docstrings/tags)
- [Changelog](https://gitlab.com/pycqa/flake8-docstrings/blob/master/HISTORY.rst)
- [Commits](https://gitlab.com/pycqa/flake8-docstrings/compare/1.5.0...1.6.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 14:45:51 +01:00
dependabot[bot]
383776882d Bump flake8-comprehensions from 3.3.1 to 3.4.0
Bumps [flake8-comprehensions](https://github.com/adamchainz/flake8-comprehensions) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/adamchainz/flake8-comprehensions/releases)
- [Changelog](https://github.com/adamchainz/flake8-comprehensions/blob/main/HISTORY.rst)
- [Commits](https://github.com/adamchainz/flake8-comprehensions/compare/3.3.1...3.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 14:45:51 +01:00
Athanasius
73dadca308 Add 'wheel' to requirements-dev.txt to avoid warnings 2021-04-01 14:45:51 +01:00
dependabot[bot]
9634c914c3 Bump autopep8 from 1.5.5 to 1.5.6
Bumps [autopep8](https://github.com/hhatto/autopep8) from 1.5.5 to 1.5.6.
- [Release notes](https://github.com/hhatto/autopep8/releases)
- [Commits](https://github.com/hhatto/autopep8/compare/v1.5.5...v1.5.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 14:45:51 +01:00
Athanasius
d8fb17df9f plugins/eddn: Add paranoia about data in is_horizons()
A damaged station has `"modules": []`, so trips over modules.values().
2021-04-01 14:45:51 +01:00
Athanasius
bc7767c5ce Also wrap as dict(data) in dump_capi_data() 2021-04-01 14:45:51 +01:00
A_D
e475ad6659 Ensured that CAPIData objects are JSON Serialisable
While it isnt directly an issue in main (right now), the fix applies
here forward, so we may as well do it here and not deal with a headache
later.
2021-04-01 14:45:51 +01:00
Athanasius
740da49ce1 Add similar extra logging for localhost handler
* This also adjusts the logging in Session.auth_callback() because it
  can be called from either protocol.  Saying 'edmc://' there is
  misleading.
2021-04-01 14:45:51 +01:00
Athanasius
baa86b4fbf Add extra logging for Frontier Auth, especially via edmc:// 2021-04-01 14:45:51 +01:00
Athanasius
74afcb085a JournalLock: Catch when journal_dir is None
* If it's None then set journal_dir_path to None as well.  Setting '' or
  nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
  JournalLockResult.ALREADY_LOCKED.
2021-04-01 14:45:51 +01:00
dependabot[bot]
831981f383 Bump py2exe from 0.10.2.1 to 0.10.3.0
Bumps [py2exe](https://github.com/py2exe/py2exe) from 0.10.2.1 to 0.10.3.0.
- [Release notes](https://github.com/py2exe/py2exe/releases)
- [Changelog](https://github.com/py2exe/py2exe/blob/master/ChangeLog)
- [Commits](https://github.com/py2exe/py2exe/compare/v0.10.2.1...v0.10.3.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 14:45:51 +01:00
dependabot[bot]
34876f28a2 Bump flake8 from 3.8.4 to 3.9.0
Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.8.4 to 3.9.0.
- [Release notes](https://gitlab.com/pycqa/flake8/tags)
- [Commits](https://gitlab.com/pycqa/flake8/compare/3.8.4...3.9.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-01 14:45:51 +01:00
Athanasius
87c88b80ea Slightly more paranoia in that NSCFArray check 2021-04-01 14:45:50 +01:00
Athanasius
6a4ab10cd4 Add comment about the __NSCFArray issue 2021-04-01 14:45:50 +01:00
Athanasius
1c269e9f4b Change darwin __raw_get() check for list to check it's not the OTHERS
On darwin this comes back with the type `__NSCFArray`, which I can't
find the definition of (in order to test against it).  So instead let's
check that `res` is not-None, and not one of `str` or `int`, because
then it should be (meant to be) `list`.

Yes, this is weird given the pre-rewrite code is:

```python
        def get(self, key: str) -> Union[None, list, str]:
            """Look up a string configuration value."""
            val = self.settings.get(key)
            if val is None:
                return None

            elif isinstance(val, str):
                return str(val)

            elif isinstance(val, list):
                return list(val)  # make writeable

            else:
                return None
```
But maybe something changed since 3.43 was tested and built.
2021-04-01 14:45:50 +01:00
Athanasius
0f83e5b035 macos config: Respect suppress argument to config.delete()
Else the blind deletion of the shipyard key at startup causes a fatal
exception.
2021-04-01 14:45:50 +01:00
Athanasius
e777727658 Change JournalLock.obtain_lock() return to an Enum.
This way we can tell the difference between:

1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
   read-write.

Case 3 is currently also returned if the configured journal directory
doesn't exist.  This will be the case on any MacOS system that never had
the game running.  Likely given the OS hasn't been supported for the
game in years now.

# Conflicts:
#	EDMarketConnector.py
2021-04-01 14:45:50 +01:00
A_D
60dd93a3de Fixed invalid type annotation 2021-04-01 14:45:50 +01:00
A_D
e4c0703142 fixed log wording 2021-04-01 14:45:50 +01:00
A_D
ee4451560a added regression test 2021-04-01 14:45:50 +01:00
A_D
f5575e5b8e Fixed broken suppress_call calls 2021-04-01 14:45:50 +01:00
A_D
7707c26d18 tiny mypy cleanup 2021-04-01 14:45:50 +01:00