codemie-test-harness 0.1.146__py3-none-any.whl → 0.1.147__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of codemie-test-harness might be problematic. Click here for more details.
- codemie_test_harness/tests/conftest.py +7 -7
- codemie_test_harness/tests/utils/env_utils.py +125 -0
- {codemie_test_harness-0.1.146.dist-info → codemie_test_harness-0.1.147.dist-info}/METADATA +2 -2
- {codemie_test_harness-0.1.146.dist-info → codemie_test_harness-0.1.147.dist-info}/RECORD +6 -5
- {codemie_test_harness-0.1.146.dist-info → codemie_test_harness-0.1.147.dist-info}/WHEEL +0 -0
- {codemie_test_harness-0.1.146.dist-info → codemie_test_harness-0.1.147.dist-info}/entry_points.txt +0 -0
|
@@ -64,13 +64,15 @@ def pytest_configure(config):
|
|
|
64
64
|
"""
|
|
65
65
|
from codemie_test_harness.cli.runner import resolve_tests_path_and_root
|
|
66
66
|
from codemie_test_harness.tests.utils.aws_parameters_store import AwsParameterStore
|
|
67
|
+
from codemie_test_harness.tests.utils.env_utils import EnvManager
|
|
67
68
|
|
|
68
69
|
# Resolve the root directory and .env file path
|
|
69
70
|
_, root_dir = resolve_tests_path_and_root()
|
|
70
71
|
env_file_path = Path(root_dir) / ".env"
|
|
71
72
|
|
|
72
73
|
# Load initial .env file
|
|
73
|
-
|
|
74
|
+
if env_file_path.exists():
|
|
75
|
+
load_dotenv(env_file_path)
|
|
74
76
|
|
|
75
77
|
# Check if AWS credentials are available for parameter store
|
|
76
78
|
if os.getenv("AWS_ACCESS_KEY") and os.getenv("AWS_SECRET_KEY"):
|
|
@@ -85,12 +87,10 @@ def pytest_configure(config):
|
|
|
85
87
|
f"/codemie/autotests/dotenv/{os.getenv('ENV')}"
|
|
86
88
|
)
|
|
87
89
|
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
# Reload .env file with AWS parameters
|
|
93
|
-
load_dotenv(env_file_path)
|
|
90
|
+
# Safely update .env file with new content
|
|
91
|
+
EnvManager.update_env_file_safely(
|
|
92
|
+
env_file_path=env_file_path, new_content=dotenv, clear_old_vars=True
|
|
93
|
+
)
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
def pytest_unconfigure(config):
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utility functions for managing environment variables and dotenv files with caching prevention.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import time
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from dotenv import load_dotenv
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class EnvManager:
|
|
12
|
+
"""
|
|
13
|
+
Manages environment variables with proper caching prevention.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def clear_env_vars_from_file(env_file_path: Path) -> None:
|
|
18
|
+
"""
|
|
19
|
+
Clear environment variables that exist in the specified .env file from os.environ.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
env_file_path: Path to the .env file
|
|
23
|
+
"""
|
|
24
|
+
if not env_file_path.exists():
|
|
25
|
+
return
|
|
26
|
+
|
|
27
|
+
with open(env_file_path, "r") as f:
|
|
28
|
+
content = f.read()
|
|
29
|
+
|
|
30
|
+
for line in content.splitlines():
|
|
31
|
+
line = line.strip()
|
|
32
|
+
if line and "=" in line and not line.startswith("#"):
|
|
33
|
+
key = line.split("=", 1)[0].strip()
|
|
34
|
+
os.environ.pop(key, None)
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def write_env_file_safely(env_file_path: Path, content: str) -> None:
|
|
38
|
+
"""
|
|
39
|
+
Write content to .env file with proper flushing and sync.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
env_file_path: Path to the .env file
|
|
43
|
+
content: Content to write
|
|
44
|
+
"""
|
|
45
|
+
# Ensure parent directory exists
|
|
46
|
+
env_file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
47
|
+
|
|
48
|
+
# Write with proper flushing
|
|
49
|
+
with open(env_file_path, "w", encoding="utf-8") as file:
|
|
50
|
+
file.write(content)
|
|
51
|
+
file.flush()
|
|
52
|
+
os.fsync(file.fileno())
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def load_env_with_retry(
|
|
56
|
+
env_file_path: Path,
|
|
57
|
+
max_retries: int = 3,
|
|
58
|
+
retry_delay: float = 0.1,
|
|
59
|
+
override: bool = True,
|
|
60
|
+
) -> bool:
|
|
61
|
+
"""
|
|
62
|
+
Load .env file with retry mechanism to handle caching issues.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
env_file_path: Path to the .env file
|
|
66
|
+
max_retries: Maximum number of retry attempts
|
|
67
|
+
retry_delay: Delay between retries in seconds
|
|
68
|
+
override: Whether to override existing environment variables
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
bool: True if successfully loaded, False otherwise
|
|
72
|
+
"""
|
|
73
|
+
for attempt in range(max_retries):
|
|
74
|
+
try:
|
|
75
|
+
# Small delay to ensure file system consistency
|
|
76
|
+
if attempt > 0:
|
|
77
|
+
time.sleep(retry_delay)
|
|
78
|
+
|
|
79
|
+
# Verify file exists and is readable
|
|
80
|
+
if not env_file_path.exists():
|
|
81
|
+
raise FileNotFoundError(f".env file not found: {env_file_path}")
|
|
82
|
+
|
|
83
|
+
# Read file content to verify it's accessible
|
|
84
|
+
with open(env_file_path, "r") as f:
|
|
85
|
+
content = f.read()
|
|
86
|
+
|
|
87
|
+
if not content.strip():
|
|
88
|
+
raise ValueError("Empty .env file")
|
|
89
|
+
|
|
90
|
+
# Load environment variables
|
|
91
|
+
success = load_dotenv(env_file_path, override=override)
|
|
92
|
+
|
|
93
|
+
if success:
|
|
94
|
+
return True
|
|
95
|
+
|
|
96
|
+
except Exception as e:
|
|
97
|
+
if attempt == max_retries - 1:
|
|
98
|
+
raise Exception(
|
|
99
|
+
f"Failed to load .env file after {max_retries} attempts: {e}"
|
|
100
|
+
)
|
|
101
|
+
continue
|
|
102
|
+
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
@staticmethod
|
|
106
|
+
def update_env_file_safely(
|
|
107
|
+
env_file_path: Path, new_content: str, clear_old_vars: bool = True
|
|
108
|
+
) -> None:
|
|
109
|
+
"""
|
|
110
|
+
Safely update .env file with new content, handling caching issues.
|
|
111
|
+
|
|
112
|
+
Args:
|
|
113
|
+
env_file_path: Path to the .env file
|
|
114
|
+
new_content: New content to write
|
|
115
|
+
clear_old_vars: Whether to clear old environment variables
|
|
116
|
+
"""
|
|
117
|
+
# Clear old environment variables if requested
|
|
118
|
+
if clear_old_vars:
|
|
119
|
+
EnvManager.clear_env_vars_from_file(env_file_path)
|
|
120
|
+
|
|
121
|
+
# Write new content safely
|
|
122
|
+
EnvManager.write_env_file_safely(env_file_path, new_content)
|
|
123
|
+
|
|
124
|
+
# Load new environment variables with retry
|
|
125
|
+
EnvManager.load_env_with_retry(env_file_path, override=True)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: codemie-test-harness
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.147
|
|
4
4
|
Summary: Autotest for CodeMie backend and UI
|
|
5
5
|
Author: Anton Yeromin
|
|
6
6
|
Author-email: anton_yeromin@epam.com
|
|
@@ -13,7 +13,7 @@ Requires-Dist: aws-assume-role-lib (>=2.10.0,<3.0.0)
|
|
|
13
13
|
Requires-Dist: boto3 (>=1.39.8,<2.0.0)
|
|
14
14
|
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
15
15
|
Requires-Dist: codemie-plugins (>=0.1.123,<0.2.0)
|
|
16
|
-
Requires-Dist: codemie-sdk-python (==0.1.
|
|
16
|
+
Requires-Dist: codemie-sdk-python (==0.1.147)
|
|
17
17
|
Requires-Dist: pytest (>=8.4.1,<9.0.0)
|
|
18
18
|
Requires-Dist: pytest-playwright (>=0.7.0,<0.8.0)
|
|
19
19
|
Requires-Dist: pytest-reportportal (>=5.5.2,<6.0.0)
|
|
@@ -55,7 +55,7 @@ codemie_test_harness/tests/assistant/tools/servicenow/__init__.py,sha256=47DEQpj
|
|
|
55
55
|
codemie_test_harness/tests/assistant/tools/servicenow/test_servicenow_tools.py,sha256=JV_n6COaCsd0_rxQBJvvLZfPdo8BsCbG8Ti-UpzFvfQ,644
|
|
56
56
|
codemie_test_harness/tests/assistant/tools/vcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
57
|
codemie_test_harness/tests/assistant/tools/vcs/test_assistant_with_vcs_tools.py,sha256=5-QybLWmYSqHG4Sqr-IN-vNcStV4skSwCJQN44Nfats,922
|
|
58
|
-
codemie_test_harness/tests/conftest.py,sha256=
|
|
58
|
+
codemie_test_harness/tests/conftest.py,sha256=QPqNG47RE7tqzqMW21VMlEeijY2q9PYQNwbTauDkTmY,28638
|
|
59
59
|
codemie_test_harness/tests/conversations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
60
|
codemie_test_harness/tests/conversations/test_conversations_endpoints.py,sha256=SQraRVrjjE4mYTs4EuGzMrO96DuOuKTiYQ4ZRBhHx70,3913
|
|
61
61
|
codemie_test_harness/tests/e2e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -217,6 +217,7 @@ codemie_test_harness/tests/utils/client_factory.py,sha256=Yyg2iXe7g7fIfIUbOH8z_8
|
|
|
217
217
|
codemie_test_harness/tests/utils/constants.py,sha256=lb6mgLjt0GM85Khs18rL1jnE9ILx8L811ykNhpF6IDA,1111
|
|
218
218
|
codemie_test_harness/tests/utils/conversation_utils.py,sha256=SWj6TBWOQoX5Yh6Wk63yHQFveRXgK1mpLb3PUKAa57A,648
|
|
219
219
|
codemie_test_harness/tests/utils/datasource_utils.py,sha256=-_HZfW_UufSUVkSUCVq4jMlq9MCcKtMhzD6iBtadzmk,12502
|
|
220
|
+
codemie_test_harness/tests/utils/env_utils.py,sha256=9tyVgxKfYqdtSoo9dRTScOZWjAUm82_65JjaKggcwCg,3999
|
|
220
221
|
codemie_test_harness/tests/utils/file_utils.py,sha256=hY-kwnyzvtd1BQif8r5NhvRTGfpKLmQKyRsq1Tuflhg,585
|
|
221
222
|
codemie_test_harness/tests/utils/gitbud_utils.py,sha256=UJ3RbhPSjHQSdos6S6zTR9iZULrBDJXoXq9cbjFH7bo,7829
|
|
222
223
|
codemie_test_harness/tests/utils/http_utils.py,sha256=wjhttibzzNhleKzWgWC01Q0Y5sV9scu-Ski-qgJPd-Q,4179
|
|
@@ -326,7 +327,7 @@ codemie_test_harness/tests/workflow/virtual_assistant_tools/servicenow/__init__.
|
|
|
326
327
|
codemie_test_harness/tests/workflow/virtual_assistant_tools/servicenow/test_workflow_with_servicenow_tools.py,sha256=Cxe5Yuy9JE_IEsnQOThpVIZQqpfLuHfDkF6JwLngDc8,890
|
|
327
328
|
codemie_test_harness/tests/workflow/virtual_assistant_tools/vcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
328
329
|
codemie_test_harness/tests/workflow/virtual_assistant_tools/vcs/test_workflow_with_vcs_tools.py,sha256=tm0NvUf_UtzLPTYJWykYpsNoxoVs-Eh80guDmRwImwg,1106
|
|
329
|
-
codemie_test_harness-0.1.
|
|
330
|
-
codemie_test_harness-0.1.
|
|
331
|
-
codemie_test_harness-0.1.
|
|
332
|
-
codemie_test_harness-0.1.
|
|
330
|
+
codemie_test_harness-0.1.147.dist-info/METADATA,sha256=p7qB5ZcTZmcvbvhjgT0nucOvVLqFQRZV54T2v0GCy68,8998
|
|
331
|
+
codemie_test_harness-0.1.147.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
332
|
+
codemie_test_harness-0.1.147.dist-info/entry_points.txt,sha256=n98t-EOM5M1mnMl_j2X4siyeO9zr0WD9a5LF7JyElIM,73
|
|
333
|
+
codemie_test_harness-0.1.147.dist-info/RECORD,,
|
|
File without changes
|
{codemie_test_harness-0.1.146.dist-info → codemie_test_harness-0.1.147.dist-info}/entry_points.txt
RENAMED
|
File without changes
|