From a12dc29b09d5f9b51731e46f5ced1dce8f52cbf2 Mon Sep 17 00:00:00 2001 From: Diego Rodriguez Date: Tue, 13 Oct 2020 15:14:20 +0200 Subject: [PATCH] tests: update to latest pytest-reana * 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. --- setup.py | 2 +- tests/test_views.py | 39 ++++++++++++++------------------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/setup.py b/setup.py index aa056ce2..51f6326c 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.8.0a1,<0.9.0", ] 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):