Skip to content

tests: automatically create test users on DCOR-dev - #1

Merged
paulmueller merged 2 commits into
DCOR-dev:masterfrom
paulmueller-agent:tests-auto-user
Oct 22, 2026
Merged

paulmueller merged 2 commits into
DCOR-dev:masterfrom
paulmueller-agent:tests-auto-user

Conversation

@paulmueller-agent

Copy link
Copy Markdown

Part of the DCOR-dev cleanup rework: users, circles, collections and datasets on DCOR-dev will be purged weekly, the dcoraid user will be removed, and the DCOR_API_KEY CI secrets will go away. These tests must therefore work with users created on the fly.

Changes

  • Automatic test users (tests/helper.py): get_api_key() (cached per session) resolves the key in this order:

    1. DCOR_API_KEY, if set
    2. tests/api_key, if the key is still valid
    3. otherwise, a new user is created via dcoraid.api.create_dcor_dev_user() (fullname "DCOR remote tester") and its key is stored in tests/api_key (now in .gitignore)

    This uses create_dcor_dev_user/is_valid_api_key from DCOR-Aid (ref: deduplicate creation of DCOR-dev users DCOR-Aid#115). CI already installs DCOR-Aid from main; there's no PyPI release with these functions yet.

  • Per-user circle names: make_dataset_dict() used the test module name as circle name (e.g. test_dcserv). Circle names are unique, so with a new user per CI run, create_circle=True would fail with a name conflict once another user owns that circle. The default circle is now <user>-<module> (e.g. dcoraid-1a2b3-test-dcserv).

  • Test fix (separate commit): test_access_private_data failed with "DID NOT RAISE" (also on master with dclab 0.73.4). dclab remembers every API key used in a process (APIHandler.api_keys), so the "anonymous" access at the end of the test actually used the test user's key. The test now empties that list with monkeypatch first. I checked that DCOR-dev itself is fine: from a fresh process, anonymous access to a private resource raises DCORAccessError.

  • README updated.

Test run

Run locally against dcor-dev without DCOR_API_KEY (user created automatically): 25 passed.

🤖 Generated with Claude Code

Paul Müller and others added 2 commits October 22, 2026 12:49
dclab remembers all API keys used in a process (`APIHandler.api_keys`),
so the subsequent anonymous access in `test_access_private_data`
actually used the API key of the test user and did not raise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `get_api_key` uses `DCOR_API_KEY` if set; otherwise it uses the key
  in `tests/api_key` if it is still valid or creates a new user via
  `dcoraid.api.create_dcor_dev_user` and stores its key there
- prefix the default circle names with the name of the test user,
  because circle names are unique and test users are created on the fly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paulmueller
paulmueller merged commit 3ef77df into DCOR-dev:master Oct 22, 2026
1 check passed
@paulmueller-agent
paulmueller-agent deleted the tests-auto-user branch October 23, 2026 08:28
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