Skip to content

Commit cf38a92

Browse files
ajclyallgiuseppe-steduto
authored andcommitted
feat(gherkin): add gherkin parser for workflow testing (#464)
Closes #463 Co-Authored-By: Giuseppe Steduto <giuseppe@steduto.it>
1 parent 3f08c0a commit cf38a92

18 files changed

Lines changed: 1512 additions & 0 deletions

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The list of contributors in alphabetical order:
44

55
- [Adelina Lintuluoto](https://orcid.org/0000-0002-0726-1452)
66
- [Agisilaos Kounelis](https://orcid.org/0000-0001-9312-3189)
7+
- [Alastair Lyall](https://orcid.org/0009-0000-4955-8935)
78
- [Audrius Mecionis](https://orcid.org/0000-0002-3759-1663)
89
- [Bruno Rosendo](https://orcid.org/0000-0002-0923-3148)
910
- [Burt Holzman](https://orcid.org/0000-0001-5235-6314)

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ recursive-include docs *.txt
2323
recursive-include reana_commons *.json
2424
recursive-include reana_commons *.py
2525
recursive-include tests *.py
26+
recursive-include tests *.feature
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# This file is part of REANA.
4+
# Copyright (C) 2019, 2021 CERN.
5+
#
6+
# REANA is free software; you can redistribute it and/or modify it
7+
# under the terms of the MIT License; see LICENSE file for more details.
8+
9+
"""REANA-Commons gherkin parser package."""
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# This file is part of REANA.
2+
# Copyright (C) 2024 CERN.
3+
#
4+
# REANA is free software; you can redistribute it and/or modify it
5+
# under the terms of the MIT License; see LICENSE file for more details.
6+
7+
8+
# This file provides primitives required for gherkin_parser/functions.py, allowing for different
9+
# implementations in both the client side (api calls) and server side (database access). This avoids
10+
# circular dependencies between reana-commons and reana-client.
11+
"""Base class for fetching data related to a workflow."""
12+
13+
from abc import ABC, abstractmethod
14+
15+
16+
class DataFetcherBase(ABC):
17+
"""Base class for fetching date related to a workflow."""
18+
19+
@abstractmethod
20+
def list_files(self, workflow, file_name=None, page=None, size=None, search=None):
21+
"""Return the list of files for a given workflow workspace.
22+
23+
:param workflow: name or id of the workflow.
24+
:param file_name: file name(s) (glob) to list.
25+
:param page: page number of returned file list.
26+
:param size: page size of returned file list.
27+
:param search: filter search results by parameters.
28+
:returns: a list of dictionaries that have the ``name``, ``size`` and
29+
``last-modified`` keys.
30+
"""
31+
pass
32+
33+
@abstractmethod
34+
def get_workflow_disk_usage(self, workflow, parameters):
35+
"""Display disk usage workflow.
36+
37+
:param workflow: name or id of the workflow.
38+
:param parameters: a dictionary to customize the response. It has the following
39+
(optional) keys:
40+
41+
- ``summarize``: a boolean value to indicate whether to summarize the response
42+
to include only the total workspace disk usage
43+
- ``search``: a string to filter the response by file name
44+
45+
:return: a dictionary containing the ``workflow_id``, ``workflow_name``, and the ``user`` ID, with
46+
a ``disk_usage_info`` keys that contains a list of dictionaries, each of one corresponding
47+
to a file, with the ``name`` and ``size`` keys.
48+
"""
49+
pass
50+
51+
@abstractmethod
52+
def get_workflow_logs(self, workflow, steps=None, page=None, size=None):
53+
"""Get logs from a workflow engine.
54+
55+
:param workflow: name or id of the workflow.
56+
:param steps: list of step names to get logs for.
57+
:param page: page number of returned log list.
58+
:param size: page size of returned log list.
59+
60+
:return: a dictionary with a ``logs`` key containing a JSON string that
61+
contains the requested logs.
62+
"""
63+
pass
64+
65+
@abstractmethod
66+
def get_workflow_status(self, workflow):
67+
"""Get status of previously created workflow.
68+
69+
:param workflow: name or id of the workflow.
70+
:return: a dictionary with the information about the workflow status.
71+
The dictionary has the following keys: ``id``, ``logs``, ``name``,
72+
``progress``, ``status``, ``user``.
73+
"""
74+
pass
75+
76+
@abstractmethod
77+
def get_workflow_specification(self, workflow):
78+
"""Get specification of previously created workflow.
79+
80+
:param workflow: name or id of the workflow.
81+
:returns: a dictionary that cointains two top-level keys: ``parameters``, and
82+
``specification`` (which contains a dictionary created from the workflow specification).
83+
"""
84+
pass
85+
86+
@abstractmethod
87+
def download_file(self, workflow, file_name):
88+
"""Download the requested file if it exists.
89+
90+
:param workflow: name or id of the workflow.
91+
:param file_name: file name or path to the file requested.
92+
:return: a tuple containing file binary content, filename and whether
93+
the returned file is a zip archive containing multiple files.
94+
"""
95+
pass
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is part of REANA.
2+
# Copyright (C) 2024 CERN.
3+
#
4+
# REANA is free software; you can redistribute it and/or modify it
5+
# under the terms of the MIT License; see LICENSE file for more details.
6+
"""Gherkin parser errors."""
7+
8+
9+
class StepDefinitionNotFound(Exception):
10+
"""The step definition was not found."""
11+
12+
pass
13+
14+
15+
class StepSkipped(Exception):
16+
"""The step was skipped."""
17+
18+
pass
19+
20+
21+
class FeatureFileError(Exception):
22+
"""The feature file is invalid."""
23+
24+
pass

0 commit comments

Comments
 (0)