Skip to content

Commit

Permalink
Feature/add tests (#20)
Browse files Browse the repository at this point in the history
* add e2e tests for start and create commands

* fix ci

* fix mypy

* increase maximum try for server to be up
  • Loading branch information
mde-pach authored Mar 3, 2024
1 parent 77d44b8 commit a3f1ef3
Show file tree
Hide file tree
Showing 20 changed files with 601 additions and 235 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: "3.12"
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
Expand All @@ -41,17 +41,17 @@ jobs:
- name: Install dev dependencies
run: poetry install --with=dev --no-root
- name: Ruff
run: poetry run ruff check blitz/
run: poetry run ruff check blitz/ tests/
- name: Mypy
run: poetry run mypy blitz/
run: poetry run mypy blitz/ tests/
test:
needs: lint
strategy:
fail-fast: true
matrix:
os: [ "ubuntu-latest", "macos-latest" ]
os: ["ubuntu-latest", "macos-latest"]
# python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
python-version: [ "3.12" ]
python-version: ["3.12"]
runs-on: ${{ matrix.os }}
steps:
#----------------------------------------------
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
run: poetry install --with=dev --no-interaction
#----------------------------------------------
# add matrix specifics and run test suite
#----------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions blitz/cli/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# from .commands.swagger import list_routes
from .commands.swagger import list_routes
from .commands.start import start_blitz
from .commands.list import list_blitz_app
import typer

from .commands.create import create_blitz_app
from .commands.list import list_blitz_app
from .commands.release import release_blitz

import typer
from .commands.start import start_blitz
from .commands.swagger import list_routes

app = typer.Typer()
app.command(name="create")(create_blitz_app)
Expand Down
9 changes: 5 additions & 4 deletions blitz/cli/commands/create.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from pathlib import Path
from typing import Annotated, Optional
from rich import prompt, print
from blitz.models.blitz.file import BlitzFile
import yaml
from blitz.models.blitz.config import BlitzAppConfig

import typer
import yaml
from rich import print, prompt

from blitz.models.blitz.config import BlitzAppConfig
from blitz.models.blitz.file import BlitzFile
from blitz.models.blitz.resource import BlitzResourceConfig


Expand Down
20 changes: 9 additions & 11 deletions blitz/cli/commands/start.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import contextlib
import time
from semver import Version
import typer
import os
import uvicorn

import time
from pathlib import Path
from typing import Annotated, Optional

import typer
import uvicorn
from semver import Version
from uvicorn.supervisors import ChangeReload

from blitz import __version__
from blitz.api import create_blitz_api
from blitz.cli.utils import print_version
from blitz.core import BlitzCore

from blitz.settings import get_settings
from blitz.cli.errors import (
BlitzAppNotFoundError,
BlitzAppVersionNotFoundError,
MissingBlitzAppNameError,
)

from blitz import __version__
from blitz.cli.utils import print_version
from blitz.core import BlitzCore
from blitz.settings import get_settings


def start_blitz(
Expand Down
2 changes: 1 addition & 1 deletion blitz/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import enum
from functools import lru_cache
import os
from functools import lru_cache

from pydantic_settings import BaseSettings

Expand Down
8 changes: 4 additions & 4 deletions blitz/ui/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Generic, Protocol, Self, TypeVar, cast, overload

from nicegui import ui
from nicegui.element import Element

from blitz.ui.blitz_ui import BlitzUI, get_blitz_ui


Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(
render: bool | None = None,
**kwargs: Any,
) -> None:
self._ng: Element
self._ng: V
self.props = props
self.classes = classes
self.blitz_ui: BlitzUI
Expand Down Expand Up @@ -81,11 +81,11 @@ def refresh(self, *args: Any, **kwargs: Any) -> None:
self.render.refresh(*args, **kwargs) # type: ignore

@property
def ng(self) -> Element:
def ng(self) -> V:
return self._ng

@ng.setter
def ng(self, value: Element) -> None:
def ng(self, value: V) -> None:
self._ng = value

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion blitz/ui/components/element/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def render(self) -> None:
self.ng = ui.element(tag=self.tag, _client=self._client).props(self.props).classes(self.classes)


class IFrame(BaseElement): # type: ignore
class IFrame(BaseElement):
"""
IFrame element.
Expand Down
Loading

0 comments on commit a3f1ef3

Please sign in to comment.