@@ -198,6 +198,15 @@ at a MariaDB/MySQL server where your database user may create databases
pytest --ignore=tests/test_update.py tests/
```
+The tests in `tests/rrs/` need the RRS app and are skipped without it.
+`docker/run-tests.sh` runs them in a second pass with `ENABLE_RRS=1`. To run
+them directly, add `'rrs'` to `INSTALLED_APPS` and build the test database from
+the models, since the RRS data migrations need the core layer to exist first:
+
+```sh
+pytest --nomigrations tests/rrs/
+```
+
`tests/test_dockersetup.py` tests the files `dockersetup.py` writes. It needs only
pytest and PyYAML, and is skipped inside the Docker image:
@@ -27,6 +27,10 @@ done
# Runs as root only to prepare the container: tests/test_update.py rewrites
# settings.py and bitbake writes its lock file next to it, the update scripts
# expect bitbake already fetched, and the tests commit to git and call tree.
+# The tests in tests/rrs/ need RRS, so a second pass runs them with
+# ENABLE_RRS=1. --nomigrations builds the tables from the models: the RRS
+# data migrations need the core layer to exist first (see README.rrs.md),
+# which an empty database lacks.
docker run --rm --network $NET -u root \
-e SECRET_KEY=ci-only \
-e GIT_AUTHOR_NAME=ci -e GIT_AUTHOR_EMAIL=ci@example.com \
@@ -40,4 +44,7 @@ docker run --rm --network $NET -u root \
su layers -s /bin/sh -c "set -e
git clone -q https://git.openembedded.org/bitbake /opt/workdir/https___git_openembedded_org_bitbake
pip3 install -q --user --no-warn-script-location -r /src/requirements-dev.txt
- python3 -m pytest -rfE -p no:cacheprovider tests/"'
+ python3 -m pytest -rfE -p no:cacheprovider tests/
+ export ENABLE_RRS=1
+ python3 manage.py makemigrations --check --dry-run rrs
+ python3 -m pytest -rfE -p no:cacheprovider --nomigrations tests/rrs/"'
new file mode 100644
@@ -0,0 +1,52 @@
+# layerindex-web - fixtures for the tests that need the RRS app
+#
+# Licensed under the MIT license, see COPYING.MIT for details
+#
+# SPDX-License-Identifier: MIT
+#
+# AI-generated, Claude Opus 5.5
+
+# RRS is optional (ENABLE_RRS=1 in docker/settings.py). Without it these tests
+# are not collected; docker/run-tests.sh runs them in a second pass with it.
+
+import datetime
+import types
+
+import pytest
+from django.conf import settings
+
+if 'rrs' not in settings.INSTALLED_APPS:
+ collect_ignore_glob = ['test_*.py']
+
+
+@pytest.fixture
+def rrs_plan(db):
+ """A maintenance plan "OE-Core" on the core layer's master branch, with
+ release 6.2 and its milestone M1 (October to December 2026)"""
+ from layerindex.models import Branch, LayerBranch, LayerItem
+ from rrs.models import (
+ Maintainer,
+ MaintenancePlan,
+ MaintenancePlanLayerBranch,
+ Milestone,
+ Release,
+ )
+
+ # Created by rrs/migrations/0001_initial.py, which --nomigrations skips
+ for name in ('No maintainer', 'All'):
+ Maintainer.objects.get_or_create(name=name)
+
+ branch, _ = Branch.objects.get_or_create(name='master', defaults={'bitbake_branch': 'master'})
+ layer = LayerItem.objects.create(name='openembedded-core', status='P', layer_type='A',
+ summary='Core metadata', description='Core metadata',
+ vcs_url='https://git.example.com/openembedded-core')
+ layerbranch = LayerBranch.objects.create(layer=layer, branch=branch)
+ plan = MaintenancePlan.objects.create(name='OE-Core')
+ MaintenancePlanLayerBranch.objects.create(plan=plan, layerbranch=layerbranch)
+ release = Release.objects.create(plan=plan, name='6.2', start_date=datetime.date(2026, 10, 1),
+ end_date=datetime.date(2027, 4, 30))
+ milestone = Milestone.objects.create(release=release, name='M1',
+ start_date=datetime.date(2026, 10, 1),
+ end_date=datetime.date(2026, 12, 31))
+ return types.SimpleNamespace(layerbranch=layerbranch, plan=plan, release=release,
+ milestone=milestone)
new file mode 100644
@@ -0,0 +1,52 @@
+# layerindex-web - smoke tests for the RRS pages
+#
+# Licensed under the MIT license, see COPYING.MIT for details
+#
+# SPDX-License-Identifier: MIT
+#
+# AI-generated, Claude Opus 5.5
+
+import datetime
+
+import pytest
+
+from rrs.models import RecipeSymbol, RecipeUpgrade
+
+PAGES = ['recipes', 'recipesreport', 'maintainers', 'stats']
+
+
+@pytest.fixture
+def busybox(rrs_plan):
+ symbol = RecipeSymbol.objects.create(layerbranch=rrs_plan.layerbranch, pn='busybox',
+ summary='Tiny versions of many common UNIX utilities')
+ date = datetime.datetime(2026, 11, 1) # USE_TZ is False
+ RecipeUpgrade.objects.create(recipesymbol=symbol, version='1.37.0', author_date=date,
+ commit_date=date, upgrade_type='U')
+ return symbol
+
+
+def test_front_page_redirects_to_the_recipe_list(client, rrs_plan):
+ response = client.get('/rrs/')
+ assert response.status_code == 302
+ assert response['Location'].startswith('/rrs/recipes/OE-Core/')
+
+
+@pytest.mark.parametrize('page', PAGES)
+def test_milestone_pages(client, busybox, page):
+ response = client.get(f'/rrs/{page}/OE-Core/6.2/M1/')
+ assert response.status_code == 200
+
+
+def test_recipe_list_shows_the_recipe(client, busybox):
+ response = client.get('/rrs/recipes/OE-Core/6.2/M1/')
+ assert [item.name for item in response.context['recipe_list']] == ['busybox']
+
+
+def test_recipe_detail(client, busybox):
+ response = client.get(f'/rrs/recipedetail/OE-Core/{busybox.pk}/')
+ assert response.status_code == 200
+ assert b'busybox' in response.content
+
+
+def test_unknown_milestone_is_404(client, rrs_plan):
+ assert client.get('/rrs/recipes/OE-Core/6.2/M9/').status_code == 404
RRS is optional, so its views had no tests: the test database is built without the app. Add tests/rrs/, collected only when RRS is installed, with a fixture for a maintenance plan and smoke tests for the RRS pages, and run it in a second pass with ENABLE_RRS=1. That pass builds the tables with --nomigrations, because the RRS data migrations need the core layer before they run (README.rrs.md), and checks that the RRS models have no changes missing a migration. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling <tim.orling@konsulko.com> --- README.devel.md | 9 +++++++ docker/run-tests.sh | 9 ++++++- tests/rrs/conftest.py | 52 +++++++++++++++++++++++++++++++++++++++++ tests/rrs/test_views.py | 52 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 tests/rrs/conftest.py create mode 100644 tests/rrs/test_views.py