Skip to content

Commit 2376b04

Browse files
authored
Merge pull request #100 from cseptesting/88-test-coverage
Improved unit and e2e tests for panel viewer
2 parents b5cdb3f + c11ee49 commit 2376b04

File tree

5 files changed

+386
-1
lines changed

5 files changed

+386
-1
lines changed

floatcsep/commands/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def view(config: str, **kwargs) -> None:
159159
exp.stage_models()
160160
exp.set_tree()
161161
log.info(f"Creating Panel App")
162-
run_app(experiment=exp)
162+
run_app(experiment=exp, **kwargs)
163163

164164

165165
def reproduce(config: str, **kwargs) -> None:

floatcsep/postprocess/panel/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def run_app(
1212
address: str = "localhost",
1313
show: bool = True,
1414
title: Optional[str] = None,
15+
start: bool = True,
16+
**kwargs,
1517
) -> None:
1618
pn.extension()
1719

@@ -31,4 +33,6 @@ def run_app(
3133
show=show,
3234
title=title or manifest.name,
3335
static_dirs={"artifacts": str(artifacts_dir)},
36+
start=start,
37+
**kwargs
3438
)

floatcsep/postprocess/panel/views/cats.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,14 @@ def _load_csep_catalog_from_manifest(manifest: Manifest):
8686
if not path:
8787
return None
8888

89+
app_root = Path(getattr(manifest, "app_root", "."))
8990
path_obj = Path(path)
9091

92+
if not path_obj.is_absolute():
93+
path_obj = (app_root / path_obj).resolve()
94+
else:
95+
path_obj = path_obj.resolve()
96+
9197
try:
9298
if path_obj.suffix.lower() == ".json":
9399
try:

tests/e2e/test_data.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def repr_evaluation(cfg_file):
4242
def get_eval_dist(self):
4343
pass
4444

45+
@staticmethod
46+
def view_dashboard(cfg_file):
47+
main.view(cfg_file, show=True, start=False)
48+
4549

4650
@patch("floatcsep.commands.main.plot_forecasts")
4751
@patch("floatcsep.commands.main.plot_catalogs")
@@ -123,3 +127,24 @@ def test_case_f(self, *args):
123127
cfg = self.get_rerunpath("f")
124128
self.repr_evaluation(cfg)
125129
self.assertEqual(1, 1)
130+
131+
132+
@patch("floatcsep.commands.main.plot_forecasts")
133+
@patch("floatcsep.commands.main.plot_catalogs")
134+
@patch("floatcsep.commands.main.plot_custom")
135+
@patch("floatcsep.commands.main.generate_report")
136+
class ViewExamples(DataTest):
137+
def test_case_c(self, *args):
138+
cfg = self.get_rerunpath("c")
139+
self.view_dashboard(cfg)
140+
self.assertEqual(1, 1)
141+
142+
def test_case_f(self, *args):
143+
cfg = self.get_rerunpath("f")
144+
self.view_dashboard(cfg)
145+
self.assertEqual(1, 1)
146+
147+
def test_case_g(self, *args):
148+
cfg = self.get_rerunpath("g")
149+
self.view_dashboard(cfg)
150+
self.assertEqual(1, 1)

0 commit comments

Comments
 (0)