Skip to content

Commit 2661f84

Browse files
committed
Tests: auto-patch to avoid loading user/site configs
1 parent e8bcb50 commit 2661f84

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

cylc/uiserver/tests/conftest.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@
1414
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
"""Test code and fixtures."""
1616

17-
from getpass import getuser
1817
import inspect
1918
import logging
2019
from pathlib import Path
2120
from shutil import rmtree
22-
from socket import gethostname
2321
from tempfile import TemporaryDirectory
2422
from uuid import uuid4
2523

2624
import pytest
27-
from tornado.web import HTTPError
2825
from traitlets.config import Config
2926
import zmq
3027

@@ -47,6 +44,7 @@
4744
from cylc.flow.parsec.config import ParsecConfig
4845
from cylc.flow.parsec.validate import cylc_config_validate
4946

47+
5048
class AsyncClientFixture(WorkflowRuntimeClient):
5149
pattern = zmq.REQ
5250
host = ''
@@ -223,7 +221,7 @@ def mock_authentication_yossarian(monkeypatch):
223221
def jp_server_config(jp_template_dir):
224222
"""Config to turn the CylcUIServer extension on.
225223
226-
Auto-loading, add as an argument in the test function to activate.
224+
Overrides jupyter server fixture of the same name.
227225
"""
228226
config = {
229227
"ServerApp": {
@@ -235,12 +233,9 @@ def jp_server_config(jp_template_dir):
235233
return config
236234

237235

238-
@pytest.fixture
239-
def patch_conf_files(monkeypatch):
240-
"""Auto-patches the CylcUIServer to prevent it loading config files.
241-
242-
Auto-loading, add as an argument in the test function to activate.
243-
"""
236+
@pytest.fixture(autouse=True)
237+
def patch_conf_files(monkeypatch: pytest.MonkeyPatch):
238+
"""Auto-patches the CylcUIServer to prevent it loading config files."""
244239
monkeypatch.setattr(
245240
'cylc.uiserver.app.CylcUIServer.config_file_paths', []
246241
)
@@ -364,6 +359,7 @@ def workflow_run_dir(request):
364359
if not request.session.testsfailed:
365360
rmtree(run_dir)
366361

362+
367363
@pytest.fixture
368364
def mock_glbl_cfg(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
369365
"""A Pytest fixture for fiddling global config values.

cylc/uiserver/tests/test_auth.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
@pytest.mark.integration
2525
@pytest.mark.usefixtures("mock_authentication_yossarian")
26-
async def test_cylc_handler(patch_conf_files, jp_fetch):
26+
async def test_cylc_handler(jp_fetch):
2727
"""The Cylc endpoints have been added and work."""
2828
resp = await jp_fetch(
2929
'cylc', 'userprofile', method='GET'
@@ -60,7 +60,6 @@ async def test_cylc_handler(patch_conf_files, jp_fetch):
6060
]
6161
)
6262
async def test_authorised_and_authenticated(
63-
patch_conf_files,
6463
jp_fetch,
6564
endpoint,
6665
code,
@@ -95,7 +94,6 @@ async def test_authorised_and_authenticated(
9594
]
9695
)
9796
async def test_unauthorised(
98-
patch_conf_files,
9997
jp_fetch,
10098
endpoint,
10199
code,

0 commit comments

Comments
 (0)