Skip to content

Commit a7dae6f

Browse files
Improve testing
1 parent c42a7f9 commit a7dae6f

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/auth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def get_jwks():
1313
if key not in settings.JWKS_CACHE:
1414
missing = True
1515
if not missing:
16-
print("Can used cached keys")
1716
return settings.JWKS_CACHE
1817
# Make a request to get the JWKS
1918
for key in settings.JWKS_URL:

tests/test_load.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
THREADS = 16
1818

1919

20-
def make_request():
21-
access_token, _ = get_tokens()
22-
23-
url = "http://localhost:80/analytics/"
20+
def make_request(token: str):
21+
url = "http://localhost:8000/analytics/"
2422
payload = json.dumps(
2523
{
2624
"product": random.randint(1, 10),
@@ -42,7 +40,7 @@ def make_request():
4240
)
4341
headers = {
4442
"Content-Type": "application/json",
45-
"Authorization": f"Bearer {access_token}",
43+
"Authorization": f"Bearer {token}",
4644
}
4745

4846
try:
@@ -56,8 +54,10 @@ def make_request():
5654

5755
def run_threads():
5856
with ThreadPoolExecutor(max_workers=THREADS) as executor:
57+
# Fetch token once to improve performance
58+
access_token, _ = get_tokens()
5959
for _ in range(NUMBER_OF_REQUESTS):
60-
executor.submit(make_request)
60+
executor.submit(make_request, access_token)
6161

6262

6363
def test_load():

0 commit comments

Comments
 (0)