Repository navigation
tests: automatically create test users on DCOR-dev - #1
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the DCOR-dev cleanup rework: users, circles, collections and datasets on DCOR-dev will be purged weekly, the
dcoraiduser will be removed, and theDCOR_API_KEYCI 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:DCOR_API_KEY, if settests/api_key, if the key is still validdcoraid.api.create_dcor_dev_user()(fullname "DCOR remote tester") and its key is stored intests/api_key(now in.gitignore)This uses
create_dcor_dev_user/is_valid_api_keyfrom DCOR-Aid (ref: deduplicate creation of DCOR-dev users DCOR-Aid#115). CI already installs DCOR-Aid frommain; 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=Truewould 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_datafailed with "DID NOT RAISE" (also onmasterwith 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 withmonkeypatchfirst. I checked that DCOR-dev itself is fine: from a fresh process, anonymous access to a private resource raisesDCORAccessError.README updated.
Test run
Run locally against dcor-dev without
DCOR_API_KEY(user created automatically): 25 passed.🤖 Generated with Claude Code