From 407773c76e7ed0861fc1ae450c1a0fc66277bcaa Mon Sep 17 00:00:00 2001 From: Rob D'Aveta Date: Tue, 24 Sep 2024 09:50:29 -0400 Subject: [PATCH] changed proxy env variable names throughout and updated documentation --- .env.sample | 4 ++-- README.md | 2 +- ppp_connectors/broker.py | 4 ++-- tests/conftest.py | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 tests/conftest.py diff --git a/.env.sample b/.env.sample index 8dbc976..566eb0d 100644 --- a/.env.sample +++ b/.env.sample @@ -1,8 +1,8 @@ ################# # ENVIRONMENTAL # ################# -HTTP_PROXY= -HTTPS_PROXY= +PPP_HTTP_PROXY= +PPP_HTTPS_PROXY= VERIFY_SSL= ############ diff --git a/README.md b/README.md index 2f9f45c..081420b 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ A simple, lightweight set of connectors and functions to various APIs, controlle ## How to install 1. Install via pip to your environment: `pip install ppp-connectors` -2. Load the required environment variables into your environment. You can find these in `env.sample`. This library is intelligent enough to look for both a `.env` file or within your system's environment variables. \ No newline at end of file +2. Load the required environment variables into your environment. You can find these in `env.sample`. This library is intelligent enough to look for both a `.env` file _and_ within your system's environment variables, so you can do either option. \ No newline at end of file diff --git a/ppp_connectors/broker.py b/ppp_connectors/broker.py index cfea5c1..7e9128a 100644 --- a/ppp_connectors/broker.py +++ b/ppp_connectors/broker.py @@ -39,8 +39,8 @@ def make_request( check_required_env_vars(env_config, required_vars) proxies: Dict[str, Any] = { - 'http': env_config['HTTP_PROXY'] if 'HTTP_PROXY' in env_config else '', - 'https': env_config['HTTPS_PROXY'] if 'HTTPS_PROXY' in env_config else '' + 'http': env_config['PPP_HTTP_PROXY'] if 'PPP_HTTP_PROXY' in env_config else '', + 'https': env_config['PPP_HTTPS_PROXY'] if 'PPP_HTTPS_PROXY' in env_config else '' } verify: bool = False if 'VERIFY_SSL' in env_config and env_config['VERIFY_SSL'].lower() == 'false' else True diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..afd128d --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,14 @@ +import pytest +from dotenv import load_dotenv + +@pytest.fixture(scope="session", autouse=True) +def load_env(): + load_dotenv(".env.test") + +@pytest.fixture +def mock_env_vars(monkeypatch): + monkeypatch.setenv("HTTP_PROXY", "http://mock.proxy") + monkeypatch.setenv("HTTPS_PROXY", "https://mock.proxy") + monkeypatch.setenv("VERIFY_SSL", "False") + monkeypatch.setenv("SPYCLOUD_API_ATO_KEY", "mock_ato_key") + monkeypatch.setenv("SPYCLOUD_API_SIP_KEY", "mock_sip_key") \ No newline at end of file