FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sdk-python/tests_integ/conftest.py at main · polytech-dev/sdk-python · GitHub
polytech-dev
/
sdk-python
Public
forked from
strands-agents/harness-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sdk-python
/
tests_integ
/
conftest.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (63 loc) · 2.26 KB
Breadcrumbs
sdk-python
/
tests_integ
/
conftest.py
Copy path
File metadata and controls
89 lines (63 loc) · 2.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import
json
import
logging
import
os
import
boto3
import
pytest
logger
=
logging
.
getLogger
(
__name__
)
def
pytest_sessionstart
(
session
):
_load_api_keys_from_secrets_manager
()
## Data
@
pytest
.
fixture
def
yellow_img
(
pytestconfig
):
path
=
pytestconfig
.
rootdir
/
"tests_integ/yellow.png"
with
open
(
path
,
"rb"
)
as
fp
:
return
fp
.
read
()
@
pytest
.
fixture
def
letter_pdf
(
pytestconfig
):
path
=
pytestconfig
.
rootdir
/
"tests_integ/letter.pdf"
with
open
(
path
,
"rb"
)
as
fp
:
return
fp
.
read
()
## Async
@
pytest
.
fixture
(
scope
=
"session"
)
def
agenerator
():
async
def
agenerator
(
items
):
for
item
in
items
:
yield
item
return
agenerator
@
pytest
.
fixture
(
scope
=
"session"
)
def
alist
():
async
def
alist
(
items
):
return
[
item
async
for
item
in
items
]
return
alist
## Models
def
_load_api_keys_from_secrets_manager
():
"""Load API keys as environment variables from AWS Secrets Manager."""
session
=
boto3
.
session
.
Session
()
client
=
session
.
client
(
service_name
=
"secretsmanager"
)
if
"STRANDS_TEST_API_KEYS_SECRET_NAME"
in
os
.
environ
:
try
:
secret_name
=
os
.
getenv
(
"STRANDS_TEST_API_KEYS_SECRET_NAME"
)
response
=
client
.
get_secret_value
(
SecretId
=
secret_name
)
if
"SecretString"
in
response
:
secret
=
json
.
loads
(
response
[
"SecretString"
])
for
key
,
value
in
secret
.
items
():
os
.
environ
[
f"
{
key
.
upper
()
}
_API_KEY"
]
=
str
(
value
)
except
Exception
as
e
:
logger
.
warning
(
"Error retrieving secret"
,
e
)
"""
Validate that required environment variables are set when running in GitHub Actions.
This prevents tests from being unintentionally skipped due to missing credentials.
"""
if
os
.
environ
.
get
(
"GITHUB_ACTIONS"
)
!=
"true"
:
logger
.
warning
(
"Tests running outside GitHub Actions, skipping required provider validation"
)
return
required_providers
=
{
"ANTHROPIC_API_KEY"
,
"COHERE_API_KEY"
,
"MISTRAL_API_KEY"
,
"OPENAI_API_KEY"
,
"WRITER_API_KEY"
,
}
for
provider
in
required_providers
:
if
provider
not
in
os
.
environ
or
not
os
.
environ
[
provider
]:
raise
ValueError
(
f"Missing required environment variables for
{
provider
}
"
)
Back
|
FazBrowse Home
|
New Git URL