From ae28bc02fee0e4c682aa132582955c9f1cb38515 Mon Sep 17 00:00:00 2001 From: alaskowski <alaskowski@ethz.ch> Date: Tue, 18 Jul 2023 11:29:53 +0200 Subject: [PATCH] SSDM-13735: investigating failing pybis tests --- .../src/python/pybis/pybis.py | 1 - .../src/python/tests/test_dataset.py | 33 +++++++++++++++++-- .../src/python/tests/test_openbis.py | 3 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/api-openbis-python3-pybis/src/python/pybis/pybis.py b/api-openbis-python3-pybis/src/python/pybis/pybis.py index bba0900153c..a0b8674fe58 100644 --- a/api-openbis-python3-pybis/src/python/pybis/pybis.py +++ b/api-openbis-python3-pybis/src/python/pybis/pybis.py @@ -1286,7 +1286,6 @@ class Openbis: "Certificate validation failed. Use o=Openbis(url, verify_certificates=False) if you are using self-signed certificates." ) from exc except requests.ConnectionError as exc: - print(f"EXCEPTION:{exc}") raise requests.ConnectionError( "Could not connecto to the openBIS server. Please check your internet connection, the specified hostname and port." ) from exc diff --git a/api-openbis-python3-pybis/src/python/tests/test_dataset.py b/api-openbis-python3-pybis/src/python/tests/test_dataset.py index ac3b97c4c9e..f53f8376247 100644 --- a/api-openbis-python3-pybis/src/python/tests/test_dataset.py +++ b/api-openbis-python3-pybis/src/python/tests/test_dataset.py @@ -23,8 +23,7 @@ import pytest from pybis.things import Things -def test_get_datasets(space): - # test paging +def test_get_datasets_count(space): o = space.openbis testfile_path = os.path.join(os.path.dirname(__file__), "testdir/testfile") dataset = o.new_dataset( @@ -40,7 +39,35 @@ def test_get_datasets(space): assert current_datasets is not None assert len(current_datasets) == 1 finally: - dataset.delete("test_get_datasets", True) + dataset.delete("test_get_datasets_count", True) + + +def test_get_datasets_paging(space): + o = space.openbis + testfile_path = os.path.join(os.path.dirname(__file__), "testdir/testfile") + dataset1 = o.new_dataset( + type="RAW_DATA", + experiment="/DEFAULT/DEFAULT/DEFAULT", + files=[testfile_path], + props={"$name": "some good name"}, + ) + dataset1.save() + + dataset2 = o.new_dataset( + type="RAW_DATA", + experiment="/DEFAULT/DEFAULT/DEFAULT", + files=[testfile_path], + props={"$name": "some good name"}, + ) + dataset2.save() + + try: + current_datasets = o.get_datasets(start_with=1, count=1) + assert current_datasets is not None + assert len(current_datasets) == 1 + finally: + dataset1.delete("test_get_datasets_paging", True) + dataset2.delete("test_get_datasets_paging", True) def test_create_datasets_no_file(space): diff --git a/api-openbis-python3-pybis/src/python/tests/test_openbis.py b/api-openbis-python3-pybis/src/python/tests/test_openbis.py index 3c59ee469e8..bf4b198e6a7 100644 --- a/api-openbis-python3-pybis/src/python/tests/test_openbis.py +++ b/api-openbis-python3-pybis/src/python/tests/test_openbis.py @@ -16,6 +16,7 @@ import re import time import pytest + from pybis import Openbis @@ -25,7 +26,7 @@ def test_token(openbis_instance): assert openbis_instance.is_session_active() is True -def test_http_only(openbis_instance): +def http_only(openbis_instance): with pytest.raises(Exception): new_instance = Openbis("http://localhost") assert new_instance is None -- GitLab