Skip to content

Commit fa95c88

Browse files
Fix unit tests (#889)
Leftover after reverting hard-coded charm version in #866 Force merge to unblock unit test for followup merges.
1 parent f0f52a4 commit fa95c88

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pytest = "^8.3.5"
5555
pytest-asyncio = "*"
5656
parameterized = "^0.9.0"
5757
jsonschema = "^4.23.0"
58+
tomli-w = "^1.2.0"
5859

5960
[tool.poetry.group.integration]
6061
optional = true

tests/unit/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# See LICENSE file for licensing details.
44
import pathlib
55
import platform
6+
import shutil
67
from unittest.mock import PropertyMock
78

89
import pytest
910
import tomli
11+
import tomli_w
1012
from charms.tempo_coordinator_k8s.v0.charm_tracing import charm_tracing_disabled
1113

1214

@@ -48,3 +50,18 @@ def unit_status_lower_priority(self, *, workload_is_running=True):
4850
@pytest.fixture(autouse=True)
4951
def patch(monkeypatch):
5052
monkeypatch.setattr("charm_refresh.Machines", _MockRefresh)
53+
54+
# Add charm version to refresh_versions.toml
55+
path = pathlib.Path("refresh_versions.toml")
56+
backup = pathlib.Path("refresh_versions.toml.backup")
57+
shutil.copy(path, backup)
58+
with path.open("rb") as file:
59+
versions = tomli.load(file)
60+
versions["charm"] = "16/0.0.0"
61+
with path.open("wb") as file:
62+
tomli_w.dump(versions, file)
63+
64+
yield
65+
66+
path.unlink()
67+
shutil.move(backup, path)

0 commit comments

Comments
 (0)