Skip to content

Coverage updates post django6 - #616

Open
terjekv wants to merge 24 commits into
masterfrom
coverage_updates_post_django6
Open

terjekv wants to merge 24 commits into
masterfrom
coverage_updates_post_django6

Conversation

@terjekv

@terjekv terjekv commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

Coverage work after the last set of major changes.

@coveralls

coveralls commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 99.992% (+2.3%) from 97.697% — coverage_updates_post_django6 into master

@terjekv
terjekv force-pushed the coverage_updates_post_django6 branch from a54d524 to 71cdb61 Compare July 4, 2026 13:51
@terjekv
terjekv changed the base branch from master to dependency-updates-2026-07-04 July 4, 2026 13:51
@terjekv
terjekv force-pushed the coverage_updates_post_django6 branch 2 times, most recently from e6bb54b to b40cc13 Compare July 4, 2026 14:09
@terjekv
terjekv changed the base branch from dependency-updates-2026-07-04 to master July 4, 2026 14:09
@terjekv
terjekv marked this pull request as ready for review July 4, 2026 14:18
@terjekv
terjekv force-pushed the coverage_updates_post_django6 branch 2 times, most recently from 6f10b23 to 3f68405 Compare July 28, 2026 13:38
terjekv added a commit that referenced this pull request Jul 29, 2026
## Summary

- Preserve the pre-#628 field order for `NetworkSerializer` and `NetGroupRegexPermissionSerializer`.
- Retain the explicit `network` and `range` fields required for OpenAPI generation.
- Restore `mreg.api.views.LIBRARIES_TO_REPORT` as a compatibility alias.
- Ensure mreg-cli tests the image built for the current pull request.
- Add regression tests for both serializer orders and the compatibility alias.

## Root cause

### Serializer field ordering

PR #628 explicitly declared two custom model fields so drf-spectacular could describe them:

```python
NetworkSerializer.network = serializers.CharField()
NetGroupRegexPermissionSerializer.range = serializers.CharField()
```

Combined with `fields = "__all__"`, DRF moved those fields earlier in the serialized output.

`NetworkSerializer` changed from:

```text
id, excluded_ranges, policy, communities, created_at, updated_at, network, ...
```

to:

```text
id, network, excluded_ranges, policy, communities, created_at, updated_at, ...
```

`NetGroupRegexPermissionSerializer` changed from:

```text
id, created_at, updated_at, group, range, regex, labels
```

to:

```text
id, range, created_at, updated_at, group, regex, labels
```

Although JSON object order is not semantically significant, mreg-cli’s recorded-output tests compare it, and stable serialization avoids unnecessary changes for existing consumers.

Both serializers now use explicit field tuples in their previous order while retaining the explicit custom fields required for OpenAPI generation.

### Renamed constant

PR #628 moved the reported-library constant from `mreg.api.views` to `mreg.api.serializers` and renamed it to `REPORTED_LIBRARY_VERSION_FIELDS`.

In-flight pull requests created before #628, including #616, still import `LIBRARIES_TO_REPORT` from `mreg.api.views`. The previous name is retained as an alias:

```python
LIBRARIES_TO_REPORT = REPORTED_LIBRARY_VERSION_FIELDS
```

This keeps older branches compatible without duplicating the value.

### Incorrect image used by mreg-cli

The container workflow tagged the newly built PR image locally as:

```text
ghcr.io/unioslo/mreg:latest
```

However, the mreg-cli integration script defaults to:

```text
ghcr.io/unioslo/mreg:master
```

The integration job could therefore test the published registry image instead of the image built for the current pull request.
terjekv and others added 19 commits July 29, 2026 13:24
Run uv run tox -r
  uv run tox -r
  shell: /usr/bin/bash -e {0}
  env:
    UV_FROZEN: 1
    UV_CACHE_DIR: /home/runner/work/_temp/setup-uv-cache
    MREG_DB_PASSWORD: postgres
python312-django52: venv> .venv/bin/uv venv -p /home/runner/work/mreg/mreg/.venv/bin/python --allow-existing --python-preference system .tox/python312-django52
python312-django52: uv-sync> uv sync --locked --python-preference system --no-default-groups --group ci --group dev -p /home/runner/work/mreg/mreg/.venv/bin/python
error: the argument '--locked' cannot be used with '--frozen'

Usage: uv sync --locked --no-default-groups --group <GROUP> --python <PYTHON> --cache-dir <CACHE_DIR>

For more information, try '--help'.
python312-django52: exit 2 (0.01 seconds) /home/runner/work/mreg/mreg> uv sync --locked --python-preference system --no-default-groups --group ci --group dev -p /home/runner/work/mreg/mreg/.venv/bin/python pid=3242
python312-django52: FAIL ✖ in 0.09 seconds
python312-django60: venv> .venv/bin/uv venv -p /home/runner/work/mreg/mreg/.venv/bin/python --allow-existing --python-preference system .tox/python312-django60
python312-django60: uv-sync> uv sync --locked --python-preference system --no-default-groups --group ci --group dev -p /home/runner/work/mreg/mreg/.venv/bin/python
error: the argument '--locked' cannot be used with '--frozen'

Usage: uv sync --locked --no-default-groups --group <GROUP> --python <PYTHON> --cache-dir <CACHE_DIR>

For more information, try '--help'.
python312-django60: exit 2 (0.01 seconds) /home/runner/work/mreg/mreg> uv sync --locked --python-preference system --no-default-groups --group ci --group dev -p /home/runner/work/mreg/mreg/.venv/bin/python pid=3250
  python312-django52: FAIL code 2 (0.09 seconds)
  python312-django60: FAIL code 2 (0.05 seconds)
  evaluation failed :( (0.18 seconds)
With the move to a newer Django, we can finally use the built-in support for parallel testing.

The effect is rather profound:

```
$ source .venv/bin/activate && source .env && coverage run manage.py test --parallel
Found 884 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
System check identified no issues (0 silenced).
.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................s.............................................................................................................................................................................................................................................................................................................................................s................................................................
----------------------------------------------------------------------
Ran 884 tests in 54.608s

OK (skipped=2)
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
```
@terjekv
terjekv force-pushed the coverage_updates_post_django6 branch from 3f68405 to 6acf831 Compare July 29, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants