diff --git a/CHANGELOG.md b/CHANGELOG.md index c2e7c4e46dfc02627d48888f597543bfc6aab89f..f07769dba6a8d2d40798669de4cb704f15dd4e36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,5 +67,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Tests for NaN Double Values (see https://gitlab.com/caosdb/caosdb-server/issues/41) * Tests for name queries. [caosdb-server#51](https://gitlab.com/caosdb/caosdb-server/-/issues/51) +* Server-side scripting is more tolerant to Pandas warnings now. (https://gitlab.indiscale.com/caosdb/src/caosdb-pyinttest/-/issues/21) ### Security (in case of vulnerabilities) diff --git a/README.md b/README.md index b12924bf47af681eba61ed9eb3e9ac22642adc98..8ba5ca8d295f6ee3e594f1faa130cdd25f65d5e2 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,17 @@ CaosDB project. be found elsewhere): - The CaosDB server must have debugging enabled. - The database should be empty. + - There should be a symlink named `debug-scripting-bin` inside the `custom` profile directory, + which points to the `resources` directory here in the pyinttest repository. You can create a + symlink like that with the following command (adapt paths to match your setting): + `custom$ ln -s ../../../../caosdb-pyinttest/resources debug-scripting-bin` - Modify `pycaosdb.ini.template` and save it as `pycaosdb.ini`, taking care of the following points: - Certificates must be valid and be specified in `pycaosdb.ini`. - Server-side scripting paths must be given, otherwise server-side scripting will be omitted. + - The local path `test_server_side_scripting.bin_dir.local` should point to a + `linkahead-server/scripting/bin` somwhere. + - The remote path `test_server_side_scripting.bin_dir.server` should probably be something like + `/opt/caosdb/git/caosdb-server/scripting/bin-debug`. - Paths for the file tests must exist, or be creatable by the testing script and the server. - Run the tests with `pytest` or `pytest-3` (depending on your system). - If you want to run just a single test, you can also select a single test file: diff --git a/tests/test_server_side_scripting.py b/tests/test_server_side_scripting.py index 2bb5ba38f9d1c26b0c74d5ae93b533183b273721..1ad258ea335a1ab7a35d7ab2b1a5880bfb0c56de 100644 --- a/tests/test_server_side_scripting.py +++ b/tests/test_server_side_scripting.py @@ -70,6 +70,28 @@ def clean_database(): d.delete() +def assert_stderr(stderr) -> None: + """Assert that ``stderr`` is either None or contains only the pyarrow deprecation warning. + +This can probably removed with Pandas 3.0, to be replaced by ``assert stderr is None``. + +Parameters +---------- +stderr + The object to be tested. + """ + if stderr is None: + return + assert isinstance(stderr, str) + assert stderr.split(sep="\n", maxsplit=1)[1] == """Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0), +(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries) +but was not found to be installed on your system. +If this would cause problems for you, +please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466 + + i = __import__(m)""" + + def setup_function(function): clean_database() @@ -148,7 +170,7 @@ def test_call_ok(): xml = etree.parse(r) assert xml.xpath("/Response/script/call")[0].text == "ok" assert xml.xpath("/Response/script/stdout")[0].text == "ok" - assert xml.xpath("/Response/script/stderr")[0].text is None + assert_stderr(xml.xpath("/Response/script/stderr")[0].text) assert xml.xpath("/Response/script/@code")[0] == "0" @@ -178,7 +200,7 @@ def test_run_server_side_script_with_file_as_positional_param(): exit="123", query="COUNT ENTITY TestRT", files={"-p2": "test_file.txt"}) - assert response.stderr is None + assert_stderr(response.stderr) assert response.code == 123 assert response.call == ('administration/diagnostics.py ' '--exit=123 --query=COUNT ENTITY TestRT ' @@ -203,7 +225,7 @@ def test_run_server_side_script_with_additional_file(): exit="123", query="COUNT ENTITY TestRT", files={"dummykey": "test_file.txt"}) - assert response.stderr is None + assert_stderr(response.stderr) assert response.code == 123 assert response.call == ('administration/diagnostics.py ' '--exit=123 --query=COUNT ENTITY TestRT ' @@ -250,7 +272,7 @@ def test_diagnostics_basic(): "with code 123.") assert xml.xpath("/Response/script/call")[0].text.startswith( "administration/diagnostics.py") - assert xml.xpath("/Response/script/stderr")[0].text is None + assert_stderr(xml.xpath("/Response/script/stderr")[0].text) def test_diagnostics_with_file_upload(): @@ -293,7 +315,7 @@ def test_diagnostics_with_file_upload(): "with code 0.") assert xml.xpath("/Response/script/call")[0].text.startswith( "administration/diagnostics.py") - assert xml.xpath("/Response/script/stderr")[0].text is None + assert_stderr(xml.xpath("/Response/script/stderr")[0].text) @mark.local_server @@ -403,7 +425,7 @@ def test_anonymous_script_calling_success(): assert xml.xpath("/Response/UserInfo/Roles/Role")[0].text == "anonymous" assert xml.xpath("/Response/script/call")[0].text == "ok_anonymous" assert xml.xpath("/Response/script/stdout")[0].text == "ok_anonymous" - assert xml.xpath("/Response/script/stderr")[0].text is None + assert_stderr(xml.xpath("/Response/script/stderr")[0].text) assert xml.xpath("/Response/script/@code")[0] == "0"