Skip to content

Commit 61d0b4e

Browse files
Sonny BakkerSonnyBA
Sonny Bakker
authored andcommitted
[#197] add documentation for creating cassettes
1 parent b885671 commit 61d0b4e

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

docs/development/index.rst

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. _development_index:
2+
3+
Development
4+
============
5+
6+
**Open Klant** is open-source software. We'd love to have you
7+
contribute!
8+
9+
.. toctree::
10+
:maxdepth: 1
11+
:caption: Further reading
12+
13+
migration

docs/development/migration.rst

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.. _migration_index:
2+
3+
Migration
4+
=========
5+
6+
Users of Open Klant version ``1.0.0`` willing to migrate to version ``2.0.0`` or higher
7+
can make use of the ``migrate_to_v2`` management command. This command **only** migrates
8+
``Klant`` instances from version ``1.0.0``. The command expects two URLs; a URL for the
9+
Open Klant instance of version ``1.0.0.``and a URL for version ``2.0.0``. The command
10+
also expects a ``ACCESS_TOKEN`` environment variable to be set, to authenticate to
11+
the Open Klant ``1.0.0`` instance. For the ``2.0.0`` instance a dummy token will be
12+
created.
13+
14+
For this migration, tests are written using VCR, which records the (relevant)
15+
outgoing requests to cassette files. Whenever tests need to be updated, consider
16+
re-recording the corresponding cassettes.
17+
18+
To re-record tests, a separate docker compose file is available to run a
19+
version ``1.0.0`` Open Klant instance next to the ``StaticLiveServer`` (which
20+
sets up a live server) which runs version ``2.0.0``. The `web` container from the
21+
docker compose setup should load the corresponding fixture which reside in the
22+
``migration/fixtures`` folder. A typical workflow, to re-record cassettes,
23+
could look like the following:
24+
25+
.. code-block:: bash
26+
27+
# Start the docker compose setup
28+
$ docker compose up --detach
29+
30+
# Load a fixture for a certain test
31+
$ docker compose exec -it web \
32+
./src/manage.py loaddata migration/credentials migration/test_digitaal_adres
33+
34+
# Run the corresponding test
35+
$ ./src/manage.py test test openklant.tests.test_migrate.MigrateTestCase.test_digitaal_adres
36+
37+
# Stop and destroy the containers (to start with a clean slate on the next run)
38+
$ docker compose down
39+
40+
41+
After running the test a cassette should be created (with the test name as filename)
42+
in the ``migration/cassettes`` folder.
43+
44+
Note that the docker compose setup, with its fixtures are only needed to (re)create
45+
cassettes for VCR. The migration tests can be ran without the docker compose setup.
46+
47+
Some tests require custom responses, for example to retrieve the ``subjectIdentificatie``
48+
when a ``subject`` URL is supplied. For these cases a ``test_server.py`` file is added
49+
that can be modified as needed to create a response for a cassette.

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ Open Klant `is`_ and only uses open source.
2828
:hidden:
2929

3030
installation/index
31+
development/index

0 commit comments

Comments
 (0)