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

TST: test_gitlab_com_127 does not depend on test profile anymore

parent 29856480
No related branches found
No related tags found
1 merge request!86Add test for https://gitlab.com/linkahead/linkahead-pylib/-/issues/127
Pipeline #58763 passed
...@@ -207,20 +207,10 @@ def test_gitlab_com_127(): ...@@ -207,20 +207,10 @@ def test_gitlab_com_127():
See https://gitlab.com/linkahead/linkahead-pylib/-/issues/127 and See https://gitlab.com/linkahead/linkahead-pylib/-/issues/127 and
https://gitlab.indiscale.com/caosdb/customers/f-fit/management/-/issues/93 https://gitlab.indiscale.com/caosdb/customers/f-fit/management/-/issues/93
""" """
# Find test profile config # Setup paths
test_profile_path = Path(__file__).parent.parent/'test_profile' base_dir = Path(__file__).parent.parent
pylinkahead_paths = list(test_profile_path.rglob('.pylinkahead.ini')) temp_pylinkahead_path = base_dir/'.pyla-temp-test.ini'
if len(pylinkahead_paths) != 1:
pytest.fail("Could not find correct config path")
pylinkahead_path = pylinkahead_paths[0]
temp_pylinkahead_path = pylinkahead_paths[0].parent/'.pyla-temp-test.ini'
temp_pylinkahead_path.unlink(True) temp_pylinkahead_path.unlink(True)
# Filter test profile content
pylinkahead_content = []
with open(pylinkahead_path, "r") as pylinkahead:
for line in pylinkahead:
if not 'timeout' in line:
pylinkahead_content.append(line)
# Parse various timeout strings and check successful connect # Parse various timeout strings and check successful connect
valid_timeout_strings = ["timeout = None", "timeout=null", valid_timeout_strings = ["timeout = None", "timeout=null",
...@@ -229,8 +219,7 @@ def test_gitlab_com_127(): ...@@ -229,8 +219,7 @@ def test_gitlab_com_127():
try: try:
# Create temporary config with timeout option # Create temporary config with timeout option
with open(temp_pylinkahead_path, "x") as temp_pylinkahead: with open(temp_pylinkahead_path, "x") as temp_pylinkahead:
for line in pylinkahead_content: temp_pylinkahead.write('[Connection]\n')
temp_pylinkahead.write(line)
temp_pylinkahead.write(timeout_string) temp_pylinkahead.write(timeout_string)
# Parse temporary config and check successful connect # Parse temporary config and check successful connect
db.get_config().read(str(temp_pylinkahead_path)) db.get_config().read(str(temp_pylinkahead_path))
...@@ -242,5 +231,4 @@ def test_gitlab_com_127(): ...@@ -242,5 +231,4 @@ def test_gitlab_com_127():
# Reset configuration # Reset configuration
db.get_config().remove_option('Connection', 'timeout') db.get_config().remove_option('Connection', 'timeout')
db.get_config().read(str(pylinkahead_path))
db.configure_connection() db.configure_connection()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment