covalent icon indicating copy to clipboard operation
covalent copied to clipboard

Lattice/electron module name conflict with lattice/electron function name when mocking

Open FyzHsn opened this issue 2 years ago • 0 comments

When writing unit tests for the electron module and mocking methods in the electron module, there is a namespace conflict. This conflict is because there is a function called electron inside the electron.py method. Moreover, the electron function is imported in the __init__.py file one level above.

When mocking a method, for example, mocker.patch("covalent._workflows.electron.Electron.as_transportable_dict"), the pytest fails since it tries to look for the attribute Electron.as_transportable_dict for the function electron inside the module rather than the module itself.

One solution was to rename lattice/electron.py -> _lattice/_electron.py. However, the only issue with this was the covalent_dispatcher_tests/_cli/migrate_test.py fails bcs the older version of Covalent used for the pickled files conflicts with the module renaming.

At the present moment, we're not ready to remove the migration support/tests yet.

Acceptance criteria:

  • [ ] Resolve the namespace conflict so that we can properly mock in the unit tests.

Note: If we either remove the migration support/tests or figure out a way so that the tests pass, we can move forward with the module renaming.

FyzHsn avatar Jan 30 '23 15:01 FyzHsn