Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DPE-4068] Finish test migration from unittest to pytest + enable/disable secrets in every test #451

Merged
merged 8 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
from unittest.mock import PropertyMock

import pytest


# This causes every test defined in this file to run 2 times, each with
# charm.JujuVersion.has_secrets set as True or as False
@pytest.fixture(params=[True, False], autouse=True)
def _has_secrets(request, monkeypatch):
monkeypatch.setattr("charm.JujuVersion.has_secrets", PropertyMock(return_value=request.param))
return request.param
1,381 changes: 704 additions & 677 deletions tests/unit/test_backups.py

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ def harness():
harness.cleanup()


# This causes every test defined in this file to run 2 times, each with
# charm.JujuVersion.has_secrets set as True or as False
@pytest.fixture(params=[True, False], autouse=True)
def _has_secrets(request, monkeypatch):
monkeypatch.setattr("charm.JujuVersion.has_secrets", PropertyMock(return_value=request.param))
return request.param


@patch_network_get(private_address="1.1.1.1")
def test_on_install(harness):
with patch("charm.subprocess.check_call") as _check_call, patch(
Expand Down
Loading
Loading