canonical / opensearch-operator

OpenSearch operator
Apache License 2.0
12 stars 7 forks source link

[unit test] Move to a single framework: `pytest` and update secret mocking #188

Open phvalguima opened 9 months ago

phvalguima commented 9 months ago

We are using unittest as our main framework currently. However, as we move to data platform workflows, we can get a lot of advantages moving it to pytest instead.

One important point raised by @carlcsaposs-canonical is how can we parametrize juju versions for secret management: https://github.com/canonical/mysql-router-k8s-operator/blob/f2cbb11ba9c333563acbb9f9b1e159adbded15b6/tests/unit/conftest.py#L60-L63

When testing it with OpenSearch, I've got the following errors:

_________________________________________________________________________________ ERROR at setup of TestOpenSearchInternalData.test_data_has_0_app _________________________________________________________________________________
test_data_has_0_app does not support fixtures, maybe unittest.TestCase subclass?
Node id: tests/unit/lib/test_opensearch_secrets.py::TestOpenSearchInternalData::test_data_has_0_app
Function type: TestCaseFunction

Also, we must remove dependency: parameterized and unify it under pytest.mark.parametrize.

github-actions[bot] commented 9 months ago

https://warthogs.atlassian.net/browse/DPE-3614

carlcsaposs-canonical commented 9 months ago

Choice of unittest/pytest for unit tests, to me, seems independent of data-platform-workflows

For unit tests, data-platform-workflows doesn't care if unittest/pytest is used

(For integration tests, pytest works better with dpw. And, imo, there's value in having the same framework for unit & integration tests)