Skip to content
Snippets Groups Projects
Commit d362a52a authored by I. Nüske's avatar I. Nüske
Browse files

Merge branch 'f-enh-fit-93-pylinkahead-separate-timeouts' into 'dev'

parents 7c8a480f 11709281
No related branches found
No related tags found
1 merge request!86Add test for https://gitlab.com/linkahead/linkahead-pylib/-/issues/127
Pipeline #60636 passed
...@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added (for new features) ### Added (for new features)
* Tests for [linkahead-pylib#127](https://gitlab.com/linkahead/linkahead-pylib/-/issues/127)
* Tests for [linkahead-server#280](https://gitlab.com/linkahead/linkahead-server/-/issues/280) * Tests for [linkahead-server#280](https://gitlab.com/linkahead/linkahead-server/-/issues/280)
* Test for [caosdb-pylib#119](https://gitlab.com/linkahead/linkahead-pylib/-/issues/119) * Test for [caosdb-pylib#119](https://gitlab.com/linkahead/linkahead-pylib/-/issues/119)
* Test for [caosdb-pylib#89](https://gitlab.com/linkahead/linkahead-pylib/-/issues/89) * Test for [caosdb-pylib#89](https://gitlab.com/linkahead/linkahead-pylib/-/issues/89)
......
...@@ -29,6 +29,7 @@ import os ...@@ -29,6 +29,7 @@ import os
import tempfile import tempfile
import time import time
import warnings import warnings
from pathlib import Path
import linkahead as db import linkahead as db
import linkahead.common.utils import linkahead.common.utils
...@@ -196,3 +197,44 @@ def test_gitlab_com_120(): ...@@ -196,3 +197,44 @@ def test_gitlab_com_120():
rt1_retrieved.update() rt1_retrieved.update()
# The update and addition of a new property must not change this, either. # The update and addition of a new property must not change this, either.
assert len(rt1_retrieved.get_property(rt2.name).properties) == 0 assert len(rt1_retrieved.get_property(rt2.name).properties) == 0
def test_gitlab_com_127():
"""
Test that the timeout option in pylinkahead.ini accepts separate
connect/read timeouts and timeout None.
See https://gitlab.com/linkahead/linkahead-pylib/-/issues/127 and
https://gitlab.indiscale.com/caosdb/customers/f-fit/management/-/issues/93
"""
# Setup paths and save previous timeout
base_dir = Path(__file__).parent.parent
temp_pylinkahead_path = base_dir/'.pyla-temp-test.ini'
temp_pylinkahead_path.unlink(True)
prev_timeout = None
if db.get_config().has_option('Connection', 'timeout'):
prev_timeout = db.get_config().get('Connection', 'timeout')
# Parse various timeout strings and check successful connect
valid_timeout_strings = ["timeout = None", "timeout=null",
"timeout = (4, 40)", "timeout=(4,4)",
"timeout = (4, None)", "timeout= ( null , 4 )"]
for timeout_string in valid_timeout_strings:
try:
# Create temporary config with timeout option
with open(temp_pylinkahead_path, "x") as temp_pylinkahead:
temp_pylinkahead.write('[Connection]\n')
temp_pylinkahead.write(timeout_string)
# Parse temporary config and check successful connect
db.get_config().read(str(temp_pylinkahead_path))
db.configure_connection()
assert 'Connection to' in str(db.Info())
finally:
# Delete temporary config
temp_pylinkahead_path.unlink()
# Reset configuration
db.get_config().remove_option('Connection', 'timeout')
if prev_timeout is not None:
db.get_config().set('Connection', 'timeout', prev_timeout)
db.configure_connection()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment