Skip to content

Commit

Permalink
add conftest with has_secrets fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasgameiroborges committed Apr 22, 2024
1 parent c27f6b1 commit 6ed4250
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 12 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import pytest
from unittest.mock import PropertyMock

# 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
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

0 comments on commit 6ed4250

Please sign in to comment.