Commit graph

22 commits

Author SHA1 Message Date
Denis Laxalde 4035f1a3da Add compat for old pytest in type hints 2023-10-13 11:45:39 +02:00
Denis Laxalde fabf3c142b Declare compatibility with click 7.1 or higher
We apparently, from the test suite, don't need version 8.x.
2023-10-13 11:45:39 +02:00
Denis Laxalde 903b83e211 Use fake HTTP server for the Patroni API in tests
We introduce a patroni_api fixture, defined in tests/conftest.py, which
sets up an HTTP server serving files in a temporary directory. The
server is itself defined by the PatroniAPI class; it has a 'routes()'
context manager method to be used in actual tests to setup expected
responses based on specified JSON files.

We set up some logging in order to improve debugging.

The direct advantage of this is that PatroniResource.rest_api() method
is now covered by the test suite.

Coverage before this commit:

  Name                        Stmts   Miss  Cover
  -----------------------------------------------
  check_patroni/__init__.py       3      0   100%
  check_patroni/cli.py          193     18    91%
  check_patroni/cluster.py      113      0   100%
  check_patroni/convert.py       23      5    78%
  check_patroni/node.py         146      1    99%
  check_patroni/types.py         50     23    54%
  -----------------------------------------------
  TOTAL                         528     47    91%

and after this commit:

  Name                        Stmts   Miss  Cover
  -----------------------------------------------
  check_patroni/__init__.py       3      0   100%
  check_patroni/cli.py          193     18    91%
  check_patroni/cluster.py      113      0   100%
  check_patroni/convert.py       23      5    78%
  check_patroni/node.py         146      1    99%
  check_patroni/types.py         50      9    82%
  -----------------------------------------------
  TOTAL                         528     33    94%

In actual test functions, we either invoke patroni_api.routes() to
configure which JSON file(s) should be served for each endpoint, or we
define dedicated fixtures (e.g. cluster_config_has_changed()) to
configure this for several test functions or the whole module.

The 'old_replica_state' parametrized fixture is used when needed to
adjust such fixtures, e.g. in cluster_has_replica_ok(), to modify the
JSON content using cluster_api_set_replica_running() (previously in
tests/tools.py, now in tests/__init__.py).

The dependency on pytest-mock is no longer needed.
2023-10-06 10:40:29 +02:00
Denis Laxalde ea92809cb3 Introduce a 'runner' test fixture
Instead of defining the CliRunner value in each test, we use a fixture.
The CliRunner is also configured with stdout and stderr separated
because mixing them will pose problem if we use stderr for other
purposes in tests, e.g. to emit log messages from a forth-coming HTTP
server.
2023-10-03 09:54:13 +02:00
benoit 68b230ccb2 Release 1.0.0 2023-08-28 12:09:16 +02:00
benoit fd801efa38 Revert_d39122d (move packaging to pyproject.toml)
This changes requiered python 3.7 which I overlooked at first. I would
like to be able to install the check any patroni server and Patroni
supports python 3.6.
2023-08-24 16:23:55 +02:00
benoit d39122dd07 Move packaging metadata into pyproject.toml 2023-08-22 11:18:27 +02:00
benoit 9cd80f5af8 Move from urllib3 to requests 2023-03-20 12:25:32 +01:00
benoit c18fa67a09 Tox updates, setup.py fixes and CONTRIBUTING.md 2022-07-13 16:04:49 +02:00
benoit b1398189a0 Release stuff 2022-07-12 15:50:06 +02:00
benoit 726c1903d8 Black run on the new version of setup.py 2022-07-11 16:31:53 +02:00
Benoit 43cc4ac118
Merge pull request #13 from blogh/few_fixes_before_ci
Few fixes before ci
2022-07-11 16:26:13 +02:00
benoit 64d87d505e Black run 2022-07-11 15:16:19 +02:00
Étienne BERSAC 0f511dc5cf
Hard code python package
Avoid embedding other package like tests.
2022-07-11 15:06:11 +02:00
Étienne BERSAC cd1461c66d
Move wheel as dev dependency 2022-07-11 15:03:17 +02:00
benoit 5448f546cf Pin the mypy version 2022-07-11 11:57:59 +02:00
benoit 9735be6904 fix flake8 complaints 2022-02-07 15:13:13 +01:00
benoit ec3b8f6806 Update setup.py and url in README 2022-02-07 11:09:46 +01:00
benoit 7258d5fd60 Try to fix install
* add info in README.md
* add wheel as a dependency for debian 10
2021-08-13 14:43:07 +02:00
benoit 1b96c0105c Fix setup.pi dependancy : attr 2021-08-13 14:02:13 +02:00
benoit 1e6adc6a1a First working version 2021-08-12 13:07:10 +02:00
benoit aa17162871 Initial commit 2021-07-02 12:37:03 +02:00