Skip to content

Commit befa4f2

Browse files
committed
add tests
1 parent b508b3c commit befa4f2

34 files changed

+3999
-211
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 110 deletions
This file was deleted.

.github/workflows/test_review.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Test Cylc Review
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- master
9+
- '*.*.x'
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
FORCE_COLOR: 2
17+
18+
defaults:
19+
run:
20+
shell: bash -c "exec $CONDA_PREFIX/bin/bash -elo pipefail {0}"
21+
22+
jobs:
23+
test:
24+
runs-on: ${{ matrix.os }}
25+
timeout-minutes: 15
26+
strategy:
27+
fail-fast: false
28+
matrix:
29+
os: ['ubuntu-latest']
30+
python-version: ['3.12']
31+
env:
32+
PYTEST_ADDOPTS: --cov --color=yes
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v5
37+
38+
- name: Patch DNS
39+
uses: cylc/release-actions/patch-dns@v1
40+
41+
- name: Install System Dependencies
42+
uses: mamba-org/setup-micromamba@v2
43+
with:
44+
cache-environment: true
45+
post-cleanup: 'all'
46+
environment-name: cylc-uiserver
47+
create-args: >-
48+
python=${{ matrix.python-version }}
49+
pip
50+
bash
51+
coreutils
52+
53+
- name: install cylc-flow
54+
uses: cylc/release-actions/install-cylc-components@v1
55+
with:
56+
cylc_flow: true
57+
cylc_flow_opts: ''
58+
59+
- name: install cylc-uiserver
60+
run: pip install -e .[all]
61+
62+
- name: Functional Tests
63+
run: |
64+
CONF_PATH="$HOME/.cylc/flow/8"
65+
mkdir -p "$CONF_PATH"
66+
touch "$CONF_PATH/global.cylc"
67+
ln -s "$CONF_PATH/global.cylc" "$CONF_PATH/global-tests.cylc"
68+
69+
cat >> "$CONF_PATH/global.cylc" <<__HERE__
70+
[platforms]
71+
[[_local_background_indep_tcp]]
72+
hosts = localhost
73+
install target = localhost
74+
ssh command = ssh -oBatchMode=yes -oConnectTimeout=8 -oStrictHostKeyChecking=no
75+
__HERE__
76+
77+
# Check that Cylc Review is ready to run
78+
cylc review --help || exit 1
79+
80+
./etc/bin/run-functional-tests

cylc/uiserver/jupyter_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525
from cylc.uiserver.app import USER_CONF_ROOT
2626
from cylc.uiserver.authorise import CylcAuthorizer
27-
from cylc.uiserver.ws import get_review_service
27+
from cylc.uiserver.ws import get_review_service_config
2828

2929

3030
# the command the hub should spawn (i.e. the cylc uiserver itself)
@@ -108,4 +108,4 @@
108108

109109

110110
# Setup Cylc Review
111-
c.JupyterHub.services = [get_review_service()]
111+
c.JupyterHub.services = [get_review_service_config()]

cylc/uiserver/review.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
For 'cylc review start', if 'PORT' is not specified, port 8080 is used."""
2424

2525
import cherrypy
26+
import contextlib
2627
from fnmatch import fnmatch
2728
from glob import glob
2829
import jinja2
@@ -40,15 +41,12 @@
4041
import traceback
4142
from urllib.parse import quote
4243

43-
from cylc.flow.hostuserutil import get_host
44-
from cylc.uiserver.review_dao import CylcReviewDAO
45-
from cylc.flow.task_state import (
46-
TASK_STATUSES_ORDERED,
47-
)
4844
from cylc.flow import __version__ as CYLC_VERSION
49-
from cylc.uiserver.ws import get_util_home
50-
from cylc.uiserver.review_dao import TASK_STATUS_GROUPS
45+
from cylc.flow.hostuserutil import get_host
46+
from cylc.flow.task_state import TASK_STATUSES_ORDERED
5147
from cylc.flow.workflow_files import WorkflowFiles
48+
from cylc.uiserver.review_dao import TASK_STATUS_GROUPS, CylcReviewDAO
49+
from cylc.uiserver.ws import get_util_home
5250

5351

5452
# Cylc 7 Task states.
@@ -69,7 +67,7 @@
6967
]
7068

7169

72-
class CylcReviewService(object):
70+
class CylcReviewService:
7371
"""'Cylc Review Service."""
7472

7573
NS = "cylc"
@@ -509,14 +507,12 @@ def suites(
509507
item = os.path.relpath(dirpath, user_suite_dir_root)
510508
if not any(fnmatch(item, glob_) for glob_ in name_globs):
511509
continue
512-
try:
510+
with contextlib.suppress(OSError):
513511
data["entries"].append({
514512
"name": str(item),
515513
"info": {},
516514
"last_activity_time": (
517515
self.get_last_activity_time(user, item))})
518-
except OSError:
519-
pass
520516

521517
if order == "name_asc":
522518
data["entries"].sort(key=lambda entry: entry["name"])
@@ -542,14 +538,14 @@ def suites(
542538
rosie_suite_info = os.path.join(user_suite_dir, "rose-suite.info")
543539
if os.path.isfile(rosie_suite_info):
544540
rosie_info = {}
545-
try:
546-
for line in open(rosie_suite_info, 'r').readlines():
541+
with contextlib.suppress(IOError):
542+
for line in open( # noqa: SIM115
543+
rosie_suite_info, 'r'
544+
).readlines():
547545
if not line.strip().startswith('#') and '=' in line:
548546
rosie_key, rosie_val = line.strip().split("=", 1)
549547
if rosie_key in ("project", "title"):
550548
rosie_info[rosie_key] = rosie_val
551-
except IOError:
552-
pass
553549
entry["info"].update(rosie_info)
554550

555551
data["time"] = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime())
@@ -600,7 +596,7 @@ def get_file(self, user, suite, path, path_in_tar=None, mode=None):
600596
text = handle.read()
601597
else:
602598
f_size = os.stat(f_name).st_size
603-
if open(f_name).read(2) == "#!":
599+
if open(f_name).read(2) == "#!": # noqa: SIM115
604600
mime = self.MIME_TEXT_PLAIN
605601
else:
606602
mime = mimetypes.guess_type(quote(f_name))[0]
@@ -614,7 +610,7 @@ def get_file(self, user, suite, path, path_in_tar=None, mode=None):
614610
):
615611
cherrypy.response.headers["Content-Type"] = mime
616612
return cherrypy.lib.static.serve_file(f_name, mime)
617-
text = open(f_name).read()
613+
text = open(f_name).read() # noqa: SIM115
618614
try:
619615
text = str(text)
620616
if mode in [None, "text"]:

0 commit comments

Comments
 (0)