From dcb13d15567358927551ef96cd2049cb081219ca Mon Sep 17 00:00:00 2001 From: Diego Rodriguez Date: Tue, 13 Oct 2020 15:14:20 +0200 Subject: [PATCH] tests: configure SHARED_VOLUME_PATH in Travis * 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. --- .travis.yml | 4 ++- reana_workflow_controller/consumer.py | 1 + reana_workflow_controller/rest/utils.py | 1 + setup.py | 2 +- tests/test_views.py | 39 +++++++++---------------- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30670c0e..c4ea3c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 /tmp/reana + - SHARED_VOLUME_PATH=/tmp/reana ./run-tests.sh after_success: - coveralls diff --git a/reana_workflow_controller/consumer.py b/reana_workflow_controller/consumer.py index 7ee60fe9..b997191e 100644 --- a/reana_workflow_controller/consumer.py +++ b/reana_workflow_controller/consumer.py @@ -12,6 +12,7 @@ import json import logging +import traceback import uuid from datetime import datetime diff --git a/reana_workflow_controller/rest/utils.py b/reana_workflow_controller/rest/utils.py index b1a74fb6..7a01b99c 100644 --- a/reana_workflow_controller/rest/utils.py +++ b/reana_workflow_controller/rest/utils.py @@ -13,6 +13,7 @@ import os import pprint import subprocess +import traceback from collections import OrderedDict from datetime import datetime from functools import wraps diff --git a/setup.py b/setup.py index aa056ce2..1d36944e 100644 --- a/setup.py +++ b/setup.py @@ -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 = { diff --git a/tests/test_views.py b/tests/test_views.py index 8d39c766..10918751 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -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: @@ -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( @@ -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):