Skip to content

Commit

Permalink
Update default for env param
Browse files Browse the repository at this point in the history
  • Loading branch information
itssimon committed Jan 18, 2024
1 parent 51679ed commit 53ca27a
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 34 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ app = FastAPI()
app.add_middleware(
ApitallyMiddleware,
client_id="your-client-id",
env="default", # or "dev", "prod" etc. (optional)
env="dev", # or "prod" etc.
)
```

Expand All @@ -92,7 +92,7 @@ app = Starlette(routes=[...])
app.add_middleware(
ApitallyMiddleware,
client_id="your-client-id",
env="default", # or "dev", "prod" etc. (optional)
env="dev", # or "prod" etc.
)
```

Expand All @@ -110,7 +110,7 @@ app = Flask(__name__)
app.wsgi_app = ApitallyMiddleware(
app,
client_id="your-client-id",
env="default", # or "dev", "prod" etc. (optional)
env="dev", # or "prod" etc.
)
```

Expand All @@ -129,7 +129,7 @@ MIDDLEWARE = [
]
APITALLY_MIDDLEWARE = {
"client_id": "your-client-id",
"env": "default", # or "dev", "prod" etc. (optional)
"env": "dev", # or "prod" etc.
}
```

Expand All @@ -148,7 +148,7 @@ MIDDLEWARE = [
]
APITALLY_MIDDLEWARE = {
"client_id": "your-client-id",
"env": "default", # or "dev", "prod" etc. (optional)
"env": "dev", # or "prod" etc.
}
```

Expand Down
2 changes: 1 addition & 1 deletion apitally/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, get_response: Callable[[HttpRequest], HttpResponse]) -> None:
def configure(
cls,
client_id: str,
env: str = "default",
env: str = "dev",
app_version: Optional[str] = None,
sync_api_keys: bool = False,
openapi_url: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion apitally/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(
self,
app: Flask,
client_id: str,
env: str = "default",
env: str = "dev",
app_version: Optional[str] = None,
sync_api_keys: bool = False,
openapi_url: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion apitally/starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(
self,
app: ASGIApp,
client_id: str,
env: str = "default",
env: str = "dev",
app_version: Optional[str] = None,
sync_api_keys: bool = False,
openapi_url: Optional[str] = "/openapi.json",
Expand Down
2 changes: 2 additions & 0 deletions tests/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "dev"
8 changes: 3 additions & 5 deletions tests/test_client_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
from pytest_httpx import HTTPXMock
from pytest_mock import MockerFixture

from .constants import CLIENT_ID, ENV


if TYPE_CHECKING:
from apitally.client.asyncio import ApitallyClient


CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "default"


@pytest.fixture(scope="module")
async def client(module_mocker: MockerFixture) -> ApitallyClient:
async def client() -> ApitallyClient:
from apitally.client.asyncio import ApitallyClient
from apitally.client.base import ApitallyKeyCacheBase

Expand Down
4 changes: 1 addition & 3 deletions tests/test_client_base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import pytest


CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "default"
from .constants import CLIENT_ID, ENV


def test_request_logger():
Expand Down
6 changes: 2 additions & 4 deletions tests/test_client_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
from pytest_mock import MockerFixture
from requests_mock import Mocker

from .constants import CLIENT_ID, ENV


if TYPE_CHECKING:
from apitally.client.threading import ApitallyClient


CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "default"


@pytest.fixture(scope="module")
def client() -> ApitallyClient:
from apitally.client.base import ApitallyKeyCacheBase
Expand Down
2 changes: 1 addition & 1 deletion tests/test_django_ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setup(module_mocker: MockerFixture) -> None:
],
APITALLY_MIDDLEWARE={
"client_id": "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9",
"env": "default",
"env": "dev",
"sync_api_keys": True,
"identify_consumer_callback": "tests.test_django_ninja.identify_consumer",
},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_django_rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def setup(module_mocker: MockerFixture) -> None:
],
APITALLY_MIDDLEWARE={
"client_id": "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9",
"env": "default",
"env": "dev",
},
)
django.setup()
Expand Down
6 changes: 2 additions & 4 deletions tests/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import pytest
from pytest_mock import MockerFixture

from .constants import CLIENT_ID, ENV


if find_spec("fastapi") is None:
pytest.skip("fastapi is not available", allow_module_level=True)
Expand All @@ -24,10 +26,6 @@
pass


CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "default"


@pytest.fixture(scope="module")
def app(module_mocker: MockerFixture) -> FastAPI:
from fastapi import Depends, FastAPI, Security
Expand Down
6 changes: 2 additions & 4 deletions tests/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import pytest
from pytest_mock import MockerFixture

from .constants import CLIENT_ID, ENV


if find_spec("flask") is None:
pytest.skip("flask is not available", allow_module_level=True)
Expand All @@ -16,10 +18,6 @@
from apitally.client.base import KeyRegistry


CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "default"


@pytest.fixture(scope="module")
def app(module_mocker: MockerFixture) -> Flask:
from flask import Flask
Expand Down
6 changes: 2 additions & 4 deletions tests/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from pytest import FixtureRequest
from pytest_mock import MockerFixture

from .constants import CLIENT_ID, ENV


if find_spec("starlette") is None:
pytest.skip("starlette is not available", allow_module_level=True)
Expand All @@ -17,10 +19,6 @@
from apitally.client.base import KeyRegistry


CLIENT_ID = "76b5cb91-a0a4-4ea0-a894-57d2b9fcb2c9"
ENV = "default"


@pytest.fixture(
scope="module",
params=["starlette", "fastapi"] if find_spec("fastapi") is not None else ["starlette"],
Expand Down

0 comments on commit 53ca27a

Please sign in to comment.