Merge ~txiao/charm-thruk-agent:pytest_fixture into charm-thruk-agent:master

Proposed by Tianqi Xiao
Status: Merged
Approved by: Eric Chen
Approved revision: f0f2f98ab28e034ab530f21719cfbc7e103a1a02
Merged at revision: 35e2239ba87a020c0d463190d2b6ec0e898a66f6
Proposed branch: ~txiao/charm-thruk-agent:pytest_fixture
Merge into: charm-thruk-agent:master
Diff against target: 168 lines (+16/-16)
3 files modified
metadata.yaml (+0/-1)
tests/functional/conftest.py (+12/-11)
tests/functional/test_deploy.py (+4/-4)
Reviewer Review Type Date Requested Status
Eric Chen Approve
BootStack Reviewers Pending
Review via email: mp+427862@code.launchpad.net

Commit message

Update pytest fixtures to fix LP#1983398

Description of the change

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Eric Chen (eric-chen) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 35e2239ba87a020c0d463190d2b6ec0e898a66f6

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/metadata.yaml b/metadata.yaml
2index 8d9a16c..efe1f2e 100644
3--- a/metadata.yaml
4+++ b/metadata.yaml
5@@ -6,7 +6,6 @@ description: |
6 tags:
7 - ops, monitoring
8 series:
9- - trusty
10 - xenial
11 - bionic
12 subordinate: true
13diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py
14index c536318..04ca92d 100644
15--- a/tests/functional/conftest.py
16+++ b/tests/functional/conftest.py
17@@ -12,6 +12,7 @@ from juju.errors import JujuError
18 from juju.model import Model
19
20 import pytest
21+import pytest_asyncio
22
23
24 STAT_FILE = "python3 -c \"import json; import os; s=os.stat('%s'); print(json.dumps({'uid': s.st_uid, 'gid': s.st_gid, 'mode': oct(s.st_mode), 'size': s.st_size}))\"" # noqa: E501
25@@ -28,7 +29,7 @@ def event_loop(request):
26 asyncio.set_event_loop(None)
27
28
29-@pytest.fixture(scope="module")
30+@pytest_asyncio.fixture(scope="module")
31 async def controller():
32 """Connect to the current controller."""
33 controller = Controller()
34@@ -37,7 +38,7 @@ async def controller():
35 await controller.disconnect()
36
37
38-@pytest.fixture(scope="module")
39+@pytest_asyncio.fixture(scope="module")
40 async def model(controller):
41 """Create a model that lives only for the duration of the test."""
42 model_name = "functest-{}".format(uuid.uuid4())
43@@ -51,7 +52,7 @@ async def model(controller):
44 await asyncio.sleep(1)
45
46
47-@pytest.fixture(scope="module")
48+@pytest_asyncio.fixture(scope="module")
49 async def current_model():
50 """Return the current model, does not create or destroy it."""
51 model = Model()
52@@ -60,7 +61,7 @@ async def current_model():
53 await model.disconnect()
54
55
56-@pytest.fixture
57+@pytest_asyncio.fixture
58 async def get_app(model):
59 """Return the application requested.""" # noqa:D202
60
61@@ -73,7 +74,7 @@ async def get_app(model):
62 return _get_app
63
64
65-@pytest.fixture
66+@pytest_asyncio.fixture
67 async def get_unit(model):
68 """Return the requested <app_name>/<unit_number> unit.""" # noqa:D202
69
70@@ -87,7 +88,7 @@ async def get_unit(model):
71 return _get_unit
72
73
74-@pytest.fixture
75+@pytest_asyncio.fixture
76 async def get_entity(model, get_unit, get_app):
77 """Return a unit or an application.""" # noqa:D202
78
79@@ -103,7 +104,7 @@ async def get_entity(model, get_unit, get_app):
80 return _get_entity
81
82
83-@pytest.fixture
84+@pytest_asyncio.fixture
85 async def run_command(get_unit):
86 """Run a command on a unit.
87
88@@ -119,7 +120,7 @@ async def run_command(get_unit):
89 return _run_command
90
91
92-@pytest.fixture
93+@pytest_asyncio.fixture
94 async def file_stat(run_command):
95 """Run stat on a file.
96
97@@ -135,7 +136,7 @@ async def file_stat(run_command):
98 return _file_stat
99
100
101-@pytest.fixture
102+@pytest_asyncio.fixture
103 async def file_contents(run_command):
104 """Return the contents of a file.
105
106@@ -151,7 +152,7 @@ async def file_contents(run_command):
107 return _file_contents
108
109
110-@pytest.fixture
111+@pytest_asyncio.fixture
112 async def reconfigure_app(get_app, model):
113 """Apply a different config to the requested app.""" # noqa:D202
114
115@@ -168,7 +169,7 @@ async def reconfigure_app(get_app, model):
116 return _reconfigure_app
117
118
119-@pytest.fixture
120+@pytest_asyncio.fixture
121 async def create_group(run_command):
122 """Create the UNIX group specified.""" # noqa:D202
123
124diff --git a/tests/functional/test_deploy.py b/tests/functional/test_deploy.py
125index 362b1ba..8642b0f 100644
126--- a/tests/functional/test_deploy.py
127+++ b/tests/functional/test_deploy.py
128@@ -4,6 +4,7 @@
129 import os
130
131 import pytest
132+import pytest_asyncio
133
134 import requests
135
136@@ -12,7 +13,6 @@ pytestmark = pytest.mark.asyncio
137 CHARM_BUILD_DIR = os.getenv("CHARM_BUILD_DIR", "..").rstrip("/")
138
139 SERIES = [
140- "trusty",
141 "xenial",
142 "bionic",
143 ]
144@@ -23,13 +23,13 @@ SERIES = [
145 ############
146
147
148-@pytest.fixture(scope="module", params=SERIES)
149+@pytest_asyncio.fixture(scope="module", params=SERIES)
150 def series(request):
151 """Return ubuntu version (i.e. xenial) in use in the test."""
152 return request.param
153
154
155-@pytest.fixture(scope="module")
156+@pytest_asyncio.fixture(scope="module")
157 async def deploy_app(model, series):
158 """Return application of the charm under test."""
159 app_name = "thruk-agent-{}".format(series)
160@@ -61,7 +61,7 @@ async def deploy_app(model, series):
161 yield thruk_agent_app
162
163
164-@pytest.fixture(scope="module")
165+@pytest_asyncio.fixture(scope="module")
166 async def unit(deploy_app):
167 """Return the thruk_agent unit we've deployed."""
168 return deploy_app.units[0]

Subscribers

People subscribed via source and target branches

to all changes: