-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependencies
- Loading branch information
Showing
102 changed files
with
3,487 additions
and
969 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM python:3.8 | ||
FROM --platform=linux/amd64 python:3.8 | ||
|
||
ENV POETRY_VERSION=1.6.1 \ | ||
POETRY_NO_INTERACTION=1 \ | ||
|
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
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import pytest | ||
|
||
from nicegui.testing import User | ||
|
||
from . import main | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
pytest_plugins = ['nicegui.testing.plugin'] | ||
|
||
|
||
@pytest.mark.module_under_test(main) | ||
async def test_login_logoff(user: User) -> None: | ||
await user.open('/') | ||
user.find('Username').type('user1') | ||
user.find('Password').type('pass1') | ||
user.find('Log in').click() | ||
await user.should_see('Hello user1!') | ||
user.find('logout').click() | ||
await user.should_see('Log in') | ||
|
||
|
||
@pytest.mark.module_under_test(main) | ||
async def test_wrong_password(user: User) -> None: | ||
await user.open('/') | ||
user.find('Username').type('user1') | ||
user.find('Password').type('wrong').trigger('keydown.enter') | ||
await user.should_see('Wrong username or password') | ||
|
||
|
||
@pytest.mark.module_under_test(main) | ||
async def test_subpage_access(user: User) -> None: | ||
await user.open('/subpage') | ||
await user.should_see('Log in') | ||
user.find('Username').type('user1') | ||
user.find('Password').type('pass1').trigger('keydown.enter') | ||
await user.should_see('This is a sub page.') |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Callable | ||
|
||
import pytest | ||
|
||
from nicegui import ui | ||
from nicegui.testing import User | ||
|
||
from . import main | ||
|
||
pytest_plugins = ['nicegui.testing.plugin'] | ||
|
||
|
||
@pytest.mark.module_under_test(main) | ||
async def test_basic_startup_appearance(user: User) -> None: | ||
"""Test basic appearance of the chat app.""" | ||
await user.open('/') | ||
await user.should_see('simple chat app') | ||
await user.should_see('https://robohash.org/') | ||
await user.should_see('message') | ||
await user.should_see('No messages yet') | ||
|
||
|
||
@pytest.mark.module_under_test(main) | ||
async def test_sending_messages(create_user: Callable[[], User]) -> None: | ||
"""Test sending messages from two different screens.""" | ||
userA = create_user() | ||
userB = create_user() | ||
|
||
await userA.open('/') | ||
userA.find(ui.input).type('Hello from screen A!').trigger('keydown.enter') | ||
await userA.should_see('Hello from screen A!') | ||
await userA.should_see('message') | ||
|
||
await userB.open('/') | ||
await userB.should_see('Hello from screen A!') | ||
userB.find(ui.input).type('Hello from screen B!').trigger('keydown.enter') | ||
await userB.should_see('message') | ||
|
||
await userA.should_see('Hello from screen A!') | ||
await userA.should_see('Hello from screen B!') |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from nicegui import Client, ui | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
|
||
def startup() -> None: | ||
@ui.page('/') | ||
def main_page() -> None: | ||
ui.markdown('Try running `pytest` on this project!') | ||
ui.button('Click me', on_click=lambda: ui.notify('Button clicked!')) | ||
ui.link('go to subpage', '/subpage') | ||
|
||
@ui.page('/subpage') | ||
def sub_page() -> None: | ||
ui.markdown('This is a subpage') | ||
|
||
@ui.page('/with_connected') | ||
async def with_connected(client: Client) -> None: | ||
ui.markdown('This is an async connection demo') | ||
await client.connected() | ||
ui.markdown('Connected!') |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env python3 | ||
from app.startup import startup | ||
|
||
from nicegui import app, ui | ||
|
||
app.on_startup(startup) | ||
|
||
ui.run() |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
asyncio_mode = auto |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nicegui | ||
pytest-asyncio | ||
pytest-selenium |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import Generator | ||
|
||
import pytest | ||
from app.startup import startup | ||
|
||
from nicegui.testing import Screen, User | ||
|
||
pytest_plugins = ['nicegui.testing.plugin'] | ||
|
||
|
||
@pytest.fixture | ||
def user(user: User) -> Generator[User, None, None]: | ||
startup() | ||
yield user | ||
|
||
|
||
@pytest.fixture | ||
def screen(screen: Screen) -> Generator[Screen, None, None]: | ||
startup() | ||
yield screen |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from nicegui.testing import Screen | ||
|
||
# pylint: disable=missing-function-docstring | ||
|
||
|
||
def test_markdown_message(screen: Screen) -> None: | ||
screen.open('/') | ||
screen.should_contain('Try running') | ||
|
||
|
||
def test_button_click(screen: Screen) -> None: | ||
screen.open('/') | ||
screen.click('Click me') | ||
screen.should_contain('Button clicked!') | ||
|
||
|
||
def test_sub_page(screen: Screen) -> None: | ||
screen.open('/subpage') | ||
screen.should_contain('This is a subpage') | ||
|
||
|
||
def test_with_connected(screen: Screen) -> None: | ||
screen.open('/with_connected') | ||
screen.should_contain('This is an async connection demo') | ||
screen.should_contain('Connected!') | ||
|
||
|
||
def test_navigation(screen: Screen) -> None: | ||
screen.open('/') | ||
screen.click('go to subpage') | ||
screen.should_contain('This is a subpage') |
Oops, something went wrong.