| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,12 +10,16 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | class TestContainer(_TestPodmanResource): | |
| 13 | - apply_actions = ["build", "create", "start", "stop", "remove"] | ||
| 14 | - | ||
| 15 | - @pytest.fixture | ||
| 13 | + @pytest.fixture(scope="class") | ||
| 16 | 14 | def cls(self): | |
| 17 | 15 | return Container | |
| 18 | 16 | ||
| 17 | + @pytest.fixture( | ||
| 18 | + scope="class", params=["build", "create", "start", "stop", "remove"] | ||
| 19 | + ) | ||
| 20 | + def action(self, request): | ||
| 21 | + return request.param | ||
| 22 | + | ||
| 19 | 23 | @pytest.mark.parametrize("rc,res", ([0, True], [1, False])) | |
| 20 | 24 | async def test_exists_yes(self, cls, rc, res): | |
| 21 | 25 | with patch.object(cls, "cmd"): | |
@@ -51,7 +55,6 @@ async def test_is_running_no_bc_dne(self, cls): | |||
| 51 | 55 | obj.cmd.return_value = AsyncMock(returncode=1) | |
| 52 | 56 | assert await obj.is_running() is False | |
| 53 | 57 | ||
| 54 | - @pytest.mark.parametrize("action", apply_actions) | ||
| 55 | 58 | async def test_empty_cmd_skips_action(self, cls, action): | |
| 56 | 59 | with patch.object(cls, "cmd"): | |
| 57 | 60 | obj = cls() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,12 +6,14 @@ | |||
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | 8 | class TestPodmanResource: | |
| 9 | - apply_actions = ["create", "remove"] | ||
| 10 | - | ||
| 11 | - @pytest.fixture | ||
| 9 | + @pytest.fixture(scope="class") | ||
| 12 | 10 | def cls(self): | |
| 13 | 11 | return PodmanResource | |
| 14 | 12 | ||
| 13 | + @pytest.fixture(scope="class", params=["create", "remove"]) | ||
| 14 | + def action(self, request): | ||
| 15 | + return request.param | ||
| 16 | + | ||
| 15 | 17 | def test_name(self, cls): | |
| 16 | 18 | obj = cls() | |
| 17 | 19 | assert obj.name == cls.__name__.lower() | |
@@ -31,13 +33,12 @@ def test_repr(self, cls): | |||
| 31 | 33 | obj = cls(name="foo") | |
| 32 | 34 | assert repr(obj) == f'{class_name}(name="foo")' | |
| 33 | 35 | ||
| 34 | - async def test_apply(self, cls): | ||
| 35 | - for action in self.apply_actions: | ||
| 36 | - with patch.object(cls, action): | ||
| 37 | - obj = cls() | ||
| 38 | - await obj.apply(action) | ||
| 39 | - method = getattr(obj, action) | ||
| 40 | - method.assert_awaited_once() | ||
| 36 | + async def test_apply(self, cls, action): | ||
| 37 | + with patch.object(cls, action): | ||
| 38 | + obj = cls() | ||
| 39 | + await obj.apply(action) | ||
| 40 | + method = getattr(obj, action) | ||
| 41 | + method.assert_awaited_once() | ||
| 41 | 42 | ||
| 42 | 43 | async def test_cmd(self, cls): | |
| 43 | 44 | with patch("ceph_devstack.resources.async_cmd") as m_async_cmd: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments