Skip to content

Commit

Permalink
tests: configure SHARED_VOLUME_PATH in Travis
Browse files Browse the repository at this point in the history
* Uses latest pytes-reana which allows configuring the
  `tmp_shared_volume_path` fixture through environment variable
  which is needed because of reanahub/reana-commons#217.

* Amends test according to latest changes.
  • Loading branch information
Diego Rodriguez committed Oct 13, 2020
1 parent c7a623d commit b6db250
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ install:
- travis_retry pip install -e .[all]

script:
- ./run-tests.sh
- pip install git+https://github.com:diegodelemos/pytest-reana@rc-217/configurable-shared-volume-path#egg=pytest_reana --force-reinstall # FIXME
- mkdir $HOME/reana
- SHARED_VOLUME_PATH=$HOME/reana ./run-tests.sh

after_success:
- coveralls
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
history = open("CHANGES.rst").read()

tests_require = [
"pytest-reana>=0.7.0.dev20200707,<0.8.0",
"pytest-reana>=0.7.0a1,<0.8.0", # FIXME
]

extras_require = {
Expand Down
39 changes: 14 additions & 25 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,6 @@ def test_get_workflow_diff(
sample_yadage_workflow_in_db,
sample_serial_workflow_in_db,
tmp_shared_volume_path,
sample_workflow_workspace,
):
"""Test set workflow status for unknown workflow."""
with app.test_client() as client:
Expand Down Expand Up @@ -1226,34 +1225,24 @@ def test_get_workspace_diff(
sample_yadage_workflow_in_db,
sample_serial_workflow_in_db,
tmp_shared_volume_path,
sample_workflow_workspace,
):
"""Test get workspace differences."""
# create the workspaces for the two workflows
workspace_path_a = next(
sample_workflow_workspace(str(sample_serial_workflow_in_db.workspace_path))
workspace_path_a = os.path.join(
tmp_shared_volume_path, sample_serial_workflow_in_db.workspace_path
)
workspace_path_b = next(
sample_workflow_workspace(str(sample_yadage_workflow_in_db.workspace_path))
workspace_path_b = os.path.join(
tmp_shared_volume_path, sample_yadage_workflow_in_db.workspace_path
)

sample_serial_workflow_in_db.get_workspace = lambda: str(
sample_serial_workflow_in_db.id_
)
sample_yadage_workflow_in_db.get_workspace = lambda: str(
sample_yadage_workflow_in_db.id_
)
# modify the contents in one file
with open(
os.path.join(
workspace_path_a,
"data",
"World_historical_and_predicted_populations_in_percentage.csv",
),
"a",
) as f:
f.write("An extra line")
f.flush()
# Create files that differ in one line
csv_line = "1,2,3,4"
file_name = "test.csv"
for index, workspace in enumerate([workspace_path_a, workspace_path_b]):
with open(os.path.join(workspace, file_name), "w",) as f:
f.write("# File {}".format(index))
f.write(os.linesep)
f.write(csv_line)
f.flush()
with app.test_client() as client:
res = client.get(
url_for(
Expand All @@ -1266,7 +1255,7 @@ def test_get_workspace_diff(
)
assert res.status_code == 200
response_data = json.loads(res.get_data(as_text=True))
assert "An extra line" in response_data["workspace_listing"]
assert "# File" in response_data["workspace_listing"]


def test_create_interactive_session(app, default_user, sample_serial_workflow_in_db):
Expand Down

0 comments on commit b6db250

Please sign in to comment.