test: fail when a file in `src/dkit/data/` is not registered in `DATASETS`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 80/100
Research direction
Start with tests/test_data.py and core/data.py, especially data.load() and its importlib.resources usage. Add a test comparing the packaged *.json filenames without extensions against data.DATASETS, reporting names missing from either side, and checking for duplicate registrations. Run the targeted data tests, then verify the test fails with an unregistered file and with a registered name lacking a file; remove the dummy file afterward.
Written by the indexing model from the issue text.
Description
core/data.py has a list DATASETS, and the data tests (tests/test_data.py) run for every name in it: the file loads, and it has a source and a valid last_verified date. But nothing checks the other direction. If someone adds src/dkit/data/new_file.json and forgets to add "new_file" to DATASETS, every test stays green and the file is never checked for provenance.
CI only counts the JSON files in the wheel, and that number is bumped by hand, so it does not catch this either.
What to do
Add a test to tests/test_data.py that compares the files that actually exist with the registered names:
- List the
*.jsonfiles in thedkit.datapackage folder (useimportlib.resources, likedata.load()does, so it also works for an installed package). - Assert that the set of file names (without
.json) equalsset(data.DATASETS). - The failure message should say which names are missing on which side, so the contributor knows what to fix.
DATASETSshould also contain no duplicates (one more assertion).
Acceptance criteria
- The test fails if you add a dummy
src/dkit/data/zzz.jsonwithout registering it, and fails if you add"zzz"toDATASETSwithout a file. Please say in the PR description that you tried both (and removed the dummy file again). - 100% line and branch coverage,
ruff checkandruff format --checkclean. - No change to the data files or to the CI file count, no CHANGELOG entry needed (tests only).
Please comment on this issue before you start (see CONTRIBUTING.md). AI-assisted contributions are welcome, please mention it in the PR description.
- Dominant language
- Python
- Stars
- 1
- Forks
- 7
- Avg merge
- 5h 5m
- Merged PRs (30d)
- 30
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Bytewave1/dkit
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
enhancement good first issue new command
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
enhancement good first issue new command
Difficulty 3/5 1-2 days Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
enhancement new command
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
Similar issues
-
Context/namespace resources fail in-cluster: "Invalid kube-config file. No configuration found."Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug documentation
Difficulty 1/5 Under an hour Newbie friendliness 88/100
awslabs/visual-asset-management-system#880 ·
Maintainers usually reply within 1 day
-
netbox status: needs owner type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
netbox-community/netbox#23533 ·
Maintainers usually reply within 1 day
-
app: scripts status: backlog type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
netbox-community/netbox-scripts#68 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 91/100
marin-community/marin#10765 ·
Maintainers usually reply within 1 day