mirror of
https://github.com/QuantEngines/fx_quant_engine.git
synced 2026-07-29 19:37:46 +00:00
21 lines
745 B
Python
21 lines
745 B
Python
import os
|
|
|
|
import pytest
|
|
|
|
from options_quant_engine.ingestion.credentials import load_credentials
|
|
|
|
|
|
def test_load_credentials_success(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("BREEZE_API_KEY", "k")
|
|
monkeypatch.setenv("BREEZE_API_SECRET", "s")
|
|
creds = load_credentials("BREEZE", required=["API_KEY", "API_SECRET"])
|
|
assert creds.get("api_key") == "k"
|
|
assert creds.get("api_secret") == "s"
|
|
|
|
|
|
def test_load_credentials_missing_required(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.delenv("ZERODHA_API_KEY", raising=False)
|
|
monkeypatch.delenv("ZERODHA_ACCESS_TOKEN", raising=False)
|
|
with pytest.raises(RuntimeError):
|
|
load_credentials("ZERODHA", required=["API_KEY", "ACCESS_TOKEN"])
|