From d942f52eebc74d5f07a27753d4dbee28a704a05d Mon Sep 17 00:00:00 2001 From: "Bruno P. Kinoshita" Date: Wed, 16 Oct 2019 12:00:43 +1300 Subject: [PATCH] Add docs for fixtures in CONTRIBUTING.md --- CONTRIBUTING.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cfced3c8..fda9d36f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,6 +97,35 @@ and other collections of tests for different components. When writing a new test, there should usually be a test of similar functionality already written and related tests should be added nearby. -When in doubt, feel free to ask. -TODO: describe some details about fixtures, etc. +The fixtures live in `jupyterhub/tests/conftest.py`. There are +fixtures that can be used for JupyterHub components, such as: + +- `app`: an instance of JupyterHub with mocked parts +- `auth_state_enabled`: enables persisting auth_state (like authentication tokens) +- `db`: a sqlite in-memory DB session +- `io_loop`: a Tornado event loop +- `event_loop`: a new asyncio event loop +- `user`: creates a new temporary user +- `admin_user`: creates a new temporary admin user +- single user servers + - `cleanup_after`: allows cleanup of single user servers between tests +- mocked service + - `MockServiceSpawner`: a spawner that mocks services for testing with a short poll interval + - `mockservice`: mocked service with no external service url + - `mockservice_url`: mocked service with a url to test external services + +And fixtures to add functionality or spawning behavior: + +- `admin_access`: grants admin access +- `no_patience`: sets slow-spawning timeouts to zero +- `slow_spawn`: enables the SlowSpawner (a spawner that takes a few seconds to start) +- `never_spawn`: enables the NeverSpawner (a spawner that will never start) +- `bad_spawn`: enables the BadSpawner (a spawner that fails immediately) +- `slow_bad_spawn`: enables the SlowBadSpawner (a spawner that fails after a short delay) + +To read more about fixtures check out the +[pytest docs](https://docs.pytest.org/en/latest/fixture.html) +for how to use the existing fixtures, and how to create new ones. + +When in doubt, feel free to ask.