Skip to content

Commit 5affe97

Browse files
committed
Refactor test setup to load API keys from environment and ensure valid keys are configured before client creation
1 parent 0a29e7d commit 5affe97

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/quick_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
import json
55
from api.services.cevs_aggregator import compute_cevs_for_company
66
from flask import Flask
7-
from api.api_server import app as flask_app
7+
from api.api_server import app as flask_app, load_api_keys
88

99

1010
def test_global_edgar_endpoint_smoke(monkeypatch):
11-
# PERBAIKAN FINAL: Memuat daftar kunci valid ke dalam konfigurasi aplikasi
12-
# sebelum membuat test client.
11+
# Langkah 1: Atur konfigurasi dengan string kunci mentah dari environment
1312
flask_app.config['API_KEYS'] = os.getenv('API_KEYS')
13+
# Langkah 2 (KRITIS): Panggil kembali fungsi parsing untuk memperbarui daftar kunci yang valid
14+
load_api_keys(flask_app)
1415
client = flask_app.test_client()
1516

1617
api_key = os.getenv('TEST_API_KEY')

tests/test_global_routes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import pytest
99
from flask import Flask
10-
from api.api_server import app as flask_app
10+
from api.api_server import app as flask_app, load_api_keys
1111

1212

1313
class TestGlobalRoutes:
@@ -16,9 +16,10 @@ class TestGlobalRoutes:
1616
@pytest.fixture
1717
def client(self):
1818
"""Flask test client for making API requests."""
19-
# PERBAIKAN FINAL: Memuat daftar kunci valid ke dalam konfigurasi aplikasi
20-
# sebelum membuat test client.
19+
# Langkah 1: Atur konfigurasi dengan string kunci mentah dari environment
2120
flask_app.config['API_KEYS'] = os.getenv('API_KEYS')
21+
# Langkah 2 (KRITIS): Panggil kembali fungsi parsing untuk memperbarui daftar kunci yang valid
22+
load_api_keys(flask_app)
2223
return flask_app.test_client()
2324

2425
@pytest.fixture

0 commit comments

Comments
 (0)