-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
526 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,12 @@ FROM python:3.12.2-slim | |
|
||
LABEL maintainer="Henry Zhu <[email protected]>" | ||
|
||
COPY requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
|
||
COPY . . | ||
|
||
RUN pip install --upgrade pip \ | ||
&& pip install poetry | ||
RUN poetry config virtualenvs.create false \ | ||
&& poetry install --no-interaction --no-ansi --without dev | ||
|
||
CMD ["sh", "start.sh", "prd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,53 @@ | ||
from nicegui import ui | ||
import datetime | ||
from nicegui.testing import Screen | ||
|
||
from beaverhabits.configs import settings | ||
from beaverhabits.frontend.add_page import add_page_ui | ||
from beaverhabits.frontend.habit_page import habit_page_ui | ||
from beaverhabits.frontend.index_page import index_page_ui | ||
from beaverhabits.utils import dummy_days | ||
from beaverhabits.views import ( | ||
get_or_create_session_habit_list, | ||
dummy_habit_list, | ||
) | ||
|
||
# Test cases: | ||
# https://github.com/zauberzeug/nicegui/tree/main/tests | ||
|
||
|
||
def test_hello(): | ||
assert "Hello" == "Hello" | ||
def dummy_today(): | ||
return datetime.date(2024, 5, 1) | ||
|
||
|
||
def test_demo_page(screen: Screen) -> None: | ||
@ui.page("/demo") | ||
async def index_page() -> None: | ||
days = dummy_days(settings.INDEX_HABIT_ITEM_COUNT) | ||
habit_list = get_or_create_session_habit_list(days) | ||
index_page_ui(habit_list) | ||
def dummy_days(count): | ||
today = dummy_today() | ||
return [today - datetime.timedelta(days=i) for i in reversed(range(count))] | ||
|
||
|
||
def test_index_page(screen: Screen) -> None: | ||
days = dummy_days(7) | ||
habits = dummy_habit_list(days) | ||
|
||
index_page_ui(days, habits) | ||
|
||
screen.open("/", timeout=60) | ||
screen.should_contain("Habits") | ||
|
||
|
||
def test_add_page(screen: Screen) -> None: | ||
days = dummy_days(7) | ||
habits = dummy_habit_list(days) | ||
|
||
add_page_ui(habits) | ||
|
||
screen.open("/", timeout=60) | ||
screen.should_contain("Habits") | ||
|
||
|
||
def test_habit_detail_page(screen: Screen) -> None: | ||
days = dummy_days(7) | ||
today = days[-1] | ||
habits = dummy_habit_list(days) | ||
habit = habits.habits[0] | ||
|
||
habit_page_ui(today, habit) | ||
|
||
screen.open("/", timeout=60) | ||
screen.should_contain("Demo") | ||
screen.should_contain("Order pizz") |