-
Notifications
You must be signed in to change notification settings - Fork 92
PLAT-166: Migrate test_schema #1136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ethho
commented
Dec 14, 2023
- cp to tests
- nose2pytest test_schema
- Add db_creds_test fixture
- First pass at migrating test_schema
- Mock schema_empty module
- Move call to spawn_missing_classes to test
| user=os.getenv("DJ_TEST_USER", "datajoint"), | ||
| password=os.getenv("DJ_TEST_PASSWORD", "datajoint"), | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another part of the move towards putting these credentials in fixtures.
| for k, v in namespace_dict.items(): | ||
| setattr(module, k, v) | ||
|
|
||
| return module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an interesting problem. In tests_old/schema_empty.py, spawn_missing_classes relies on the schema.schema (called the schema_any fixture in new tests) being activated on import. Because this is now in the schema_any fixture, we weren't able to create schema_empty.schema the same way in the pytest suite (in pytest, the value of the fixture is only available after everything's been imported). Instead, I used the types.ModuleType to mock a module that mimics the same behavior in tests_old/schema_empty.py.
| definition = """ | ||
| type: varchar(32) # type of cell | ||
| """ | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit inconsistent in the way we add Cell to test_schema, but this is exactly the way it was written in the old tests, so I'm just going to leave it.
|
Merging into |
Clean up modules that were migrated in PRs: datajoint#1136, 1137, 1138, 1139, 1140