Created
January 23, 2026 03:57
-
-
Save T-X/d263d8950f98eb3ef751f34d86dfbae9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uv run pytest -v -s tests/integration <─(Fri,Jan23)─┘ | |
| ==================================================== test session starts ===================================================== | |
| platform linux -- Python 3.13.11, pytest-9.0.2, pluggy-1.6.0 -- /home/linus/dev-priv/net/mesh/census-exporter/.venv/bin/python | |
| cachedir: .pytest_cache | |
| rootdir: /home/linus/dev-priv/net/mesh/census-exporter | |
| configfile: pyproject.toml | |
| plugins: pytest_httpserver-1.1.3 | |
| collected 4 items | |
| tests/integration/test_census_exporter.py::test_read_meshviewer_resource PASSED | |
| tests/integration/test_census_exporter.py::test_main PASSED | |
| tests/integration/test_census_exporter.py::test_fixed_main FAILED | |
| tests/integration/test_census_exporter.py::test_fixed_main_duplicates FAILED | |
| ========================================================== FAILURES ========================================================== | |
| ______________________________________________________ test_fixed_main _______________________________________________________ | |
| httpserver = <HTTPServer host=localhost port=37445> | |
| meshviewer_data = {'links': [{'source': '02ac75ba8299', 'source_addr': '02:81:b6:9a:7d:6c', 'source_tq': 1, 'target': 'e0286d900f46', .....ch': 'stable', 'enabled': True}, 'clients': 1, 'clients_other': 0, ...}, ...], 'timestamp': '2026-01-21T15:39:29+0100'} | |
| def test_fixed_main(httpserver: HTTPServer, meshviewer_data: dict) -> None: | |
| """Verify the program counts right. | |
| Spawn a webserver with a meshviewer.json and feed the exporter a matching | |
| communities.json. | |
| Check that the meshviewer.json is read just once and is evaluated properly. | |
| """ | |
| runner = CliRunner() | |
| output_filename = "test_output.prom" | |
| httpserver.expect_oneshot_request("/meshviewer.json").respond_with_json( | |
| meshviewer_data, | |
| ) | |
| with runner.isolated_filesystem(): | |
| with Path("communities.json").open("w") as f: | |
| json_str = json.dumps( | |
| {"Demotown": [httpserver.url_for("/meshviewer.json")]}, | |
| ) | |
| f.write(json_str) | |
| result = runner.invoke(main, [output_filename]) | |
| assert result.exit_code == 0 | |
| > assert "format=meshviewer" in result.output | |
| E AssertionError: assert 'format=meshviewer' in '\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mProcessing \x1b[0m \x1b[36mformat\x1b[0m=\x1b[35mmeshviewer\x1b[0m \x1b[36murl\x1b[0m=\x1b[35mhttp://localhost:37445/meshviewer.json\x1b[0m\n\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mSummary \x1b[0m \x1b[36mduplicate\x1b[0m=\x1b[35m0\x1b[0m \x1b[36munique\x1b[0m=\x1b[35m801\x1b[0m\n' | |
| E + where '\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mProcessing \x1b[0m \x1b[36mformat\x1b[0m=\x1b[35mmeshviewer\x1b[0m \x1b[36murl\x1b[0m=\x1b[35mhttp://localhost:37445/meshviewer.json\x1b[0m\n\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mSummary \x1b[0m \x1b[36mduplicate\x1b[0m=\x1b[35m0\x1b[0m \x1b[36munique\x1b[0m=\x1b[35m801\x1b[0m\n' = <Result okay>.output | |
| tests/integration/test_census_exporter.py:77: AssertionError | |
| ----------------------------------------------------- Captured log call ------------------------------------------------------ | |
| INFO werkzeug:_internal.py:97 127.0.0.1 - - [23/Jan/2026 04:56:02] "GET /meshviewer.json HTTP/1.1" 200 - | |
| _________________________________________________ test_fixed_main_duplicates _________________________________________________ | |
| httpserver = <HTTPServer host=localhost port=37445> | |
| meshviewer_data = {'links': [{'source': '02ac75ba8299', 'source_addr': '02:81:b6:9a:7d:6c', 'source_tq': 1, 'target': 'e0286d900f46', .....ch': 'stable', 'enabled': True}, 'clients': 1, 'clients_other': 0, ...}, ...], 'timestamp': '2026-01-21T15:39:29+0100'} | |
| def test_fixed_main_duplicates(httpserver: HTTPServer, meshviewer_data: dict) -> None: | |
| """Verify the program counts right. | |
| Spawn a webserver with a meshviewer.json and feed the exporter a matching | |
| communities.json. | |
| Check that the meshviewer.json is read just once and is evaluated properly. | |
| """ | |
| runner = CliRunner() | |
| output_filename = "test_output.prom" | |
| httpserver.expect_oneshot_request("/meshviewer.json").respond_with_json( | |
| meshviewer_data, | |
| ) | |
| httpserver.expect_oneshot_request("/meshviewer2.json").respond_with_json( | |
| meshviewer_data, | |
| ) | |
| with runner.isolated_filesystem(): | |
| with Path("communities.json").open("w") as f: | |
| json_str = json.dumps( | |
| { | |
| "Demotown": [httpserver.url_for("/meshviewer.json")], | |
| "Duplicatetown": [httpserver.url_for("/meshviewer2.json")], | |
| }, | |
| ) | |
| f.write(json_str) | |
| result = runner.invoke(main, [output_filename]) | |
| assert result.exit_code == 0 | |
| > assert "format=meshviewer" in result.output | |
| E AssertionError: assert 'format=meshviewer' in '\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mProcessing \x1b[0m \x1b[36mformat\x1b[0m=\x1b[35mmeshviewer\x1b[0m \x1b[36murl\x1b[0m=\x1b[35mhttp://localhost:37445/meshviewer.json\x1b[0m\n\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mProcessing \x1b[0m \x1b[36mformat\x1b[0m=\x1b[35mmeshviewer\x1b[0m \x1b[36murl\x1b[0m=\x1b[35mhttp://localhost:37445/meshviewer2.json\x1b[0m\n\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mSummary \x1b[0m \x1b[36mduplicate\x1b[0m=\x1b[35m1602\x1b[0m \x1b[36munique\x1b[0m=\x1b[35m801\x1b[0m\n' | |
| E + where '\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mProcessing \x1b[0m \x1b[36mformat\x1b[0m=\x1b[35mmeshviewer\x1b[0m \x1b[36murl\x1b[0m=\x1b[35mhttp://localhost:37445/meshviewer.json\x1b[0m\n\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mProcessing \x1b[0m \x1b[36mformat\x1b[0m=\x1b[35mmeshviewer\x1b[0m \x1b[36murl\x1b[0m=\x1b[35mhttp://localhost:37445/meshviewer2.json\x1b[0m\n\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1mSummary \x1b[0m \x1b[36mduplicate\x1b[0m=\x1b[35m1602\x1b[0m \x1b[36munique\x1b[0m=\x1b[35m801\x1b[0m\n' = <Result okay>.output | |
| tests/integration/test_census_exporter.py:123: AssertionError | |
| ----------------------------------------------------- Captured log call ------------------------------------------------------ | |
| INFO werkzeug:_internal.py:97 127.0.0.1 - - [23/Jan/2026 04:56:02] "GET /meshviewer.json HTTP/1.1" 200 - | |
| INFO werkzeug:_internal.py:97 127.0.0.1 - - [23/Jan/2026 04:56:02] "GET /meshviewer2.json HTTP/1.1" 200 - | |
| ================================================== short test summary info =================================================== | |
| FAILED tests/integration/test_census_exporter.py::test_fixed_main - AssertionError: assert 'format=meshviewer' in '\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1... | |
| FAILED tests/integration/test_census_exporter.py::test_fixed_main_duplicates - AssertionError: assert 'format=meshviewer' in '\x1b[2m2026-01-23 04:56:02\x1b[0m [\x1b[32m\x1b[1minfo \x1b[0m] \x1b[1... | |
| ================================================ 2 failed, 2 passed in 0.77s ================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment