Skip to content

Commit

Permalink
Make default pods as an empty list
Browse files Browse the repository at this point in the history
  • Loading branch information
humrochagf committed Jan 6, 2024
1 parent cf41ac7 commit fdd8ccf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ from zoneinfo import ZoneInfo, ZoneInfoNotFoundError

from fastapi import APIRouter, HTTPException, status
from wheke import Pod, Wheke
from wheke.demo import demo_pod

router = APIRouter()

Expand All @@ -96,6 +97,7 @@ def clock(tz: str | None = None) -> dict:
my_pod = Pod("my-pod", router=router)

wheke = Wheke()
wheke.add_pod(demo_pod)
wheke.add_pod(my_pod)

app = wheke.create_app()
Expand Down
2 changes: 1 addition & 1 deletion src/wheke/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.1a10"
__version__ = "0.0.1a11"
2 changes: 1 addition & 1 deletion src/wheke/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Settings(BaseSettings):
project_name: str = "Wheke"

pods: list[str] = Field(default_factory=lambda: ["wheke.demo.demo_pod"])
pods: list[str] = Field(default_factory=list)

model_config = SettingsConfigDict(
env_prefix="wheke_", env_file=".env", env_file_encoding="utf-8"
Expand Down
2 changes: 2 additions & 0 deletions tests/example_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typer import Typer, echo

from wheke import Pod, Wheke, get_service
from wheke.demo import demo_pod
from wheke.service import aget_service

STATIC_PATH = Path(__file__).parent / "static"
Expand Down Expand Up @@ -72,4 +73,5 @@ def hello() -> None:
)

wheke = Wheke()
wheke.add_pod(demo_pod)
wheke.add_pod(test_pod)
18 changes: 13 additions & 5 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,23 @@ def test_create_app() -> None:
app = wheke.create_app()

assert type(app) is FastAPI
assert demo_pod in wheke.pods


def test_create_app_with_empty_pod() -> None:
def test_create_app_with_demo_pod_in_settings() -> None:
before_pods = settings.pods.copy()
settings.pods = []
settings.pods = ["wheke.demo.demo_pod"]

wheke = Wheke()

app = wheke.create_app()

assert type(app) is FastAPI
assert demo_pod in wheke.pods

settings.pods = before_pods


def test_create_app_with_empty_pod() -> None:
empty_pod = Pod("empty")
wheke = Wheke()
wheke.add_pod(empty_pod)
Expand All @@ -29,8 +39,6 @@ def test_create_app_with_empty_pod() -> None:
assert type(app) is FastAPI
assert wheke.pods == [empty_pod]

settings.pods = before_pods


def test_demo_pod(client: TestClient) -> None:
response = client.get("/")
Expand Down
2 changes: 0 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from wheke import Wheke
from wheke.__about__ import __version__
from wheke.__main__ import cli as main_cli
from wheke.demo import demo_pod

runner = CliRunner()

Expand All @@ -15,7 +14,6 @@ def test_create_cli() -> None:
app = wheke.create_cli()

assert type(app) is Typer
assert demo_pod in wheke.pods


def test_version() -> None:
Expand Down

0 comments on commit fdd8ccf

Please sign in to comment.