INTO-CPS-Association / DTaaS

:factory: :left_right_arrow: :busts_in_silhouette: Digital Twin as a Service
https://into-cps-association.github.io/DTaaS/
Other
116 stars 57 forks source link

[BUG] CLI Tests Fail #999

Open aryanpingle opened 1 month ago

aryanpingle commented 1 month ago

CLI Tests Fail

When running pytest --cov after the correct configuration has been set, the CLI tests still fail with an error:

======================================= short test summary info ======================================= 
FAILED tests/test_utils.py::test_import_yaml_users - AssertionError: assert {'environment...'users'], ...} == {'environment...'users'], ...}

due to a mismatch between the template users.local.yml and the expected YAML object - the template contains restart: 'unless-stopped' which does not exist in the expected object. The solution is to simply add this key-value pair to the expected object.

To Reproduce

After setting up your configuration, run the following:

$ cd cli
$ poetry shell
$ pytest --cov

Additional Notes

There are some low hanging fruits we can improve the developer experience with:

  1. Files generated by the tests (.coverage, compose.users.exp.yml, etc) are being emitted into the source directory, which pollutes the git workspace. Maybe they could be placed in something like .tmp that is gitignored?
  2. On a similar note, we can extend the current .gitignore with this Python gitignore template made by github, so auto-generated folders like __pycache__ don't get included.
  3. cli/DEVELOPER.md mentions:

    Before running all tests, remember to set the appropriate path in dtaas.toml. Also set this same path in the dictionary in test_utils.py, in the test_import_toml function.

    But test_import_toml simply tests the functionality of utils.importToml by reading dtaas.test.toml and NOT the main dtaas.toml file, so where/why should the path to the DTaaS directory be set?