Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
#78

Summary of changes:
- Fixed tests to match update library and ops.
- Modified tox.ini to ignore appropriate directories.
  • Loading branch information
Ivan Chvets committed Jan 4, 2023
1 parent a1fee0d commit 81152b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Initialize unit tests
#

"""Setup test environment for unit tests."""

import ops.testing

# enable simulation of container networking
ops.testing.SIMULATE_CAN_CONNECT = True
2 changes: 1 addition & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ def test_generate_config_hash(config, hash_salt, expected_hash, harness):
def test_prometheus_data_set(harness, mocker):
harness.set_leader(True)
harness.set_model_name("kubeflow")
harness.begin()

mock_net_get = mocker.patch("ops.testing._TestingModelBackend.network_get")
mocker.patch("ops.testing._TestingPebbleClient.list_files")
Expand All @@ -406,6 +405,7 @@ def test_prometheus_data_set(harness, mocker):
rel_id = harness.add_relation("metrics-endpoint", "otherapp")
harness.add_relation_unit(rel_id, "otherapp/0")
harness.update_relation_data(rel_id, "otherapp", {})
harness.begin()

assert json.loads(harness.get_relation_data(rel_id, harness.model.app.name)["scrape_jobs"])[0][
"static_configs"
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ description = Apply coding style standards to code
commands =
# uncomment the following line if this charm owns a lib
# codespell {[vars]lib_path}
codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \
--skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
--skip {toxinidir}/.mypy_cache \
--skip {toxinidir}/icon.svg --skip *.json.tmpl
codespell {toxinidir}/. --skip {toxinidir}/./.git --skip {toxinidir}/./.tox \
--skip {toxinidir}/./build --skip {toxinidir}/./lib --skip {toxinidir}/./venv \
--skip {toxinidir}/./.mypy_cache \
--skip {toxinidir}/./icon.svg --skip *.json.tmpl
# pflake8 wrapper supports config from pyproject.toml
pflake8 {[vars]all_path}
isort --check-only --diff {[vars]all_path}
Expand Down

0 comments on commit 81152b0

Please sign in to comment.