Skip to content

Conversation

@ethho
Copy link
Contributor

@ethho 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"),
)

Copy link
Contributor Author

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
Copy link
Contributor Author

@ethho ethho Dec 14, 2023

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
"""

Copy link
Contributor Author

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.

@ethho ethho requested a review from A-Baji December 14, 2023 22:31
@ethho ethho marked this pull request as ready for review December 14, 2023 22:31
@ethho
Copy link
Contributor Author

ethho commented Dec 15, 2023

Merging into dev-tests. Please include review as part of #1142 instead.

@ethho ethho merged commit 03db252 into datajoint:dev-tests Dec 15, 2023
ethho added a commit to ethho/datajoint-python that referenced this pull request Dec 15, 2023
Clean up modules that were migrated in
PRs: datajoint#1136, 1137, 1138, 1139, 1140
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.

1 participant