1242 Commits

Author SHA1 Message Date
Athanasius
f8d4f338fa Settings: Restore blank line 2022-12-21 17:28:48 +00:00
Athanasius
896eada0b9 Merge branch 'python3' of github.com:EDCD/EDDN into python3 2022-12-21 17:27:25 +00:00
Athanasius
69a1343bb9 requirements-dev: Bump all versions to latest 2022-12-21 17:02:55 +00:00
Athanasius
804b0f3bcd requirements.txt: Bump all to latest available on pypi
Specifically pyzmq==22.3.0 had no Python 3.11 versions, so tried to
build from source, but *that* ran into issues with that version.
2022-12-21 16:59:06 +00:00
Athanasius
59d5e2676a
requirements: Updated to pass 'safety' checks
* We do need to specify `wheel` version.
* We need to specify `webtest`, as at least one test uses it.
* Bumped the version of some modules as per `safety` report.
2022-11-14 11:51:05 +00:00
Athanasius
ff05f1978a
tests: Add slew of files, mostly for (no-)gameversion on each schema 2022-11-14 11:40:32 +00:00
Athanasius
13e5be66c0
tests/eddn_messages: Add some fcmaterials/1 (journal) examples
NB: They're just copies of FCMaterials.json files right now, not encapsulated
as EDDN messages.
2022-08-30 17:52:19 +01:00
Athanasius
4f611f8dbb
tests: Remove hard-coded test messages. Use the files, Luke. 2022-08-29 17:30:16 +01:00
Athanasius
6f60f88862
tests: Add test message directory/files 2022-08-29 17:23:55 +01:00
Athanasius
bee5fc4b6a
tests: Convert all existing tests to from-file eddn_message
* The "testing" `eddn_message_from_file()` got renamed to, and replaced,
  `eddn_message()`.
* All of the tests were updated to use this new form of the fixture.
* Next commit will add the directory containing those test files.
2022-08-29 17:22:33 +01:00
Athanasius
30bc05cf29
tests: Move to loading test messages from files
* Implement a new fixture `eddn_message_from_file()` for testing this.
  Eventually this will get renamed to `eddn_message()`.

* Files containing one message each go under `tests/eddn_message`, with
  sub-directories for `<schema>/<version>[/<event>]` and then the filename
  is the nature of that file in that context.

  Completely invalid files, i.e. not even valid JSON, can be placed in
  the top level of `tests/eddn_message`.

* Use this for the `parse_and_error_handle()` "valid journal/1 scan" test.
2022-08-29 17:08:03 +01:00
Athanasius
fa8952d0d5
tests: Comment out test_messages sections 2022-08-29 16:58:07 +01:00
Athanasius
3f5c2bff7f
tests: Gateway: Add commodity/3 test message & use against parse_and_error_handle() 2022-08-29 16:53:07 +01:00
Athanasius
e205b56b21
tests: Gateway.handle_upload: no softwareName 2022-08-29 16:31:55 +01:00
Athanasius
cf344848f6
tests: Gateway.handle_upload: outdated schema 2022-08-29 16:30:31 +01:00
Athanasius
b6c703fa64
tests: Gateway.handle_upload: invalid message 2022-08-29 16:30:08 +01:00
Athanasius
a23491f73f
tests: Rename Gateway.handle_upload() test & move bottle.response mock to conftest.py fixture
Gateway.handle_upload: Rename function to include 'valid'
2022-08-29 16:10:16 +01:00
Athanasius
cb60c229a2
tests: Gateway.handle_upload - valid plain message 2022-08-29 16:05:42 +01:00
Athanasius
b4deb19e6e
tests: Move fixtures to conftest.py, and use in all existing applicable tests 2022-08-29 16:04:18 +01:00
Athanasius
bc5f7e9059
Gateway: Factor out the guts of bottle /upload/ route for easier testing 2022-08-29 15:30:27 +01:00
Athanasius
5c0515e9c6
tests: Prevent invocation in root dir, point to src/
Because the code itself only runs properly from inside the `src/` directory,
you cannot run `pytest` from the root directory and have the tests work.

So, set things up such that running `pytest` in the root directory will
only run the one test, and have that test point out the user error.
2022-08-29 15:14:34 +01:00
Athanasius
0c42764614
mypy: Moved .mypy.ini into src/ as that's where it'll be used more 2022-08-19 17:28:51 +01:00
Athanasius
e15c8e28dd
tests/gateway/parse_and_error_handle: Switch to conftest 'plain_journal_scan_valid' 2022-08-19 17:27:48 +01:00
Athanasius
0fed222074
tests/conftest: Fix up whitespace 2022-08-19 17:27:25 +01:00
Athanasius
73cdcc4c60
tests: Move 'plain_no_softwarename' message into conftest.py 2022-08-19 17:21:59 +01:00
Athanasius
4b6f22d9fd
tests: Move 'plain_outdated_schema' message into conftest.py 2022-08-19 17:19:56 +01:00
Athanasius
795480f097
tests/Gateway/parse_and_error_handle: Remove stray blank lines 2022-08-19 17:16:01 +01:00
Athanasius
eff5cedc2b
tests/Gateway/parse_and_error_handle: Working with single eddn.Gateway import
Unfortunately the `eddn_gateway()` fixture needs to be `module` scope, and
that means you can't use it with anything that uses a fixture that utilises
`monkeypatch`, because that's `function` scope.

So, back to directly appending to `sys.path`.
2022-08-19 17:13:10 +01:00
Athanasius
660dad4ff0
tests/conftest: Add 'invalid_json' message 2022-08-19 17:12:35 +01:00
Athanasius
6f17b937e1
tests/Gateway/parse_and_error_handle: Mostly fix flake8/mypy
Now it only complains about the multi-line strings for the test messages.

But those are about to move to the conftest.py dictionary.
2022-08-19 16:39:52 +01:00
Athanasius
9d9b38227f
tests/gateway/get_decompressed_message: 'plain_message' test working 2022-08-19 16:29:54 +01:00
Athanasius
e28ab45be4
Gateway: Pass headers and body into get_decompressed_message()
This makes it easier to write unit tests for this function, not having to
somehow mock up the bottle request/body stuff.
2022-08-19 16:27:22 +01:00
Athanasius
580160b95b
Relay: Add TRACE logging & use in key places
* Define our own TRACE logging level ('deeper' than DEBUG).
* Define `.trace()` method to use it.
* `logger.trace(...)` for duplicate or 'sent to Listeners' messages.

NB: mypy is still unhappy about Logger.trace, despite attempting the same
   workaround asin EDMC.  Hence the `  # type: ignore` on uses.
2022-08-19 16:25:30 +01:00
Athanasius
58c68ec17e
tests/Gateway/post_upload: Fix assert
* dc_msg is a webtest object, so need to explicitly check its `body`.
* And that `body` is bytes, not str, so test against `b'OK'`.
2022-08-19 15:53:15 +01:00
Athanasius
00fed9b36a
Gateway: Split some of main() into setup_bottle_app()
* This *should* facilitate some easier testing.
2022-08-19 15:13:33 +01:00
Athanasius
8a5bd46c33
tests/config: Gateway settings file
* Currently sets TLS cert/key files to `""` so as to be TLS-free.
2022-08-19 15:08:21 +01:00
Athanasius
6b339e3b11
tests/gateway/post_upload: Use webtest.TestApp for functional tests 2022-08-19 15:07:24 +01:00
Athanasius
30282ba95e
tests/conftest: pytest top-level configuration, mostly Fixtures
* `eddn_message()` fixture, set up to return a method when used, such that
  *that* can be called with a key to look up the approproiate test message.
* `test_messages` dictionary to support that.
2022-08-19 15:01:43 +01:00
Athanasius
87c79a3427
tests: Gateway: parse_and_error_handle: Valid journal/scan message 2022-08-18 17:55:27 +01:00
Athanasius
ba43199a5d
tests: Gateway: parse_and_error_handle: No softwareName 2022-08-18 17:54:50 +01:00
Athanasius
ddf9f3524f
tests: Gateway: parse_and_error_handle: Two tests to get started
This is Athanasius feeling out how best to add tests to this ancient code.

* Test that eddn.Gateway.parse_and_error_handle() returns the correct error
  string for:
  - Invalid JSON being passed in.
  - An outdated schema being cited.
2022-08-18 17:23:08 +01:00
Athanasius
76251cfd30
Settings: Correct comment typos about reverse proxy setup 2022-08-18 16:20:51 +01:00
Athanasius
af9089ccee
Tweak Gateway, Monitor, Relay startup logging 2022-08-18 16:19:27 +01:00
Athanasius
5365d5efd6
Bouncer: Remove defunct form-encoded processing
And as a result, no need for `import urlparse`
2022-08-18 16:14:25 +01:00
Athanasius
1f991e7c44
Gateway: Remove un-necessary import urlparse 2022-08-18 16:13:59 +01:00
Athanasius
1384241f13
Fix "are you running this correctly?" check to utilise pathlib
As it was this only worked on systems with `/`-delimited path components.

So use `pathlib.Path.as_posix()` to ensure it *is* in that format.
2022-08-18 15:20:22 +01:00
Athanasius
98603273cc
requirements.txt: Add strict-rfc3339==0.7 2022-08-18 15:20:21 +01:00
Athanasius
2310d9cb46
Relay: Add 'are you running this correctly?' check 2022-08-18 15:20:21 +01:00
Athanasius
86cfed0ec5
Monitor: Add 'are you running this correctly?' check 2022-08-18 15:20:21 +01:00
Athanasius
3f024f965c
Bouncer: Add 'are you running this correctly?' check 2022-08-18 15:20:21 +01:00