Skip to content

Commit

Permalink
simple end-to-end test
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc committed Sep 25, 2024
1 parent b057ace commit b536518
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- name: Install dev dependencies
run: pip install -r requirements-dev.txt

- name: Install browsers
run: playwright install

- name: Test
run: coverage run -m pytest -v

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
pre-commit install
playwright install
```

Now install the application itself and run it:
Expand Down
8 changes: 4 additions & 4 deletions dp_creator_ii/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

from shiny import App, ui, reactive, render

config_path = Path(__file__).parent / "config.json"
config = json.loads(config_path.read_text())
config_path.unlink()


def dataset_panel():
return ui.nav_panel(
Expand Down Expand Up @@ -48,6 +44,10 @@ def results_panel():


def server(input, output, session):
config_path = Path(__file__).parent / "config.json"
config = json.loads(config_path.read_text())
config_path.unlink()

csv_path = reactive.value(config["csv_path"])
unit_of_privacy = reactive.value(config["unit_of_privacy"])

Expand Down
13 changes: 13 additions & 0 deletions dp_creator_ii/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from shiny.run import ShinyAppProc
from playwright.sync_api import Page, expect
from shiny.pytest import create_app_fixture


app = create_app_fixture("../app.py")


# TODO: Why is incomplete coverage reported here?
def test_app(page: Page, app: ShinyAppProc): # pragma: no cover
page.goto(app.url)
expect(page).to_have_title("DP Creator II")
expect(page.locator("body")).to_contain_text("TODO: Pick dataset")
1 change: 1 addition & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pre-commit

# Testing:
pytest
pytest-playwright
mypy
coverage

Expand Down
22 changes: 21 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ flit==3.9.0
# via -r requirements-dev.in
flit-core==3.9.0
# via flit
greenlet==3.0.3
# via playwright
h11==0.14.0
# via uvicorn
htmltools==0.5.3
Expand Down Expand Up @@ -200,6 +202,8 @@ platformdirs==4.3.6
# black
# jupyter-core
# virtualenv
playwright==1.47.0
# via pytest-playwright
pluggy==1.5.0
# via pytest
polars==1.1.0
Expand All @@ -221,6 +225,8 @@ pyarrow==17.0.0
# via opendp
pycodestyle==2.12.1
# via flake8
pyee==12.0.0
# via playwright
pyflakes==3.2.0
# via flake8
pygments==2.18.0
Expand All @@ -232,13 +238,22 @@ pyproject-hooks==1.1.0
# build
# pip-tools
pytest==8.3.3
# via
# -r requirements-dev.in
# pytest-base-url
# pytest-playwright
pytest-base-url==2.1.0
# via pytest-playwright
pytest-playwright==0.5.2
# via -r requirements-dev.in
python-dateutil==2.9.0.post0
# via
# jupyter-client
# shinywidgets
python-multipart==0.0.9
# via shiny
python-slugify==8.0.4
# via pytest-playwright
pyyaml==6.0.2
# via
# jupytext
Expand All @@ -256,7 +271,9 @@ referencing==0.35.1
# jsonschema
# jsonschema-specifications
requests==2.32.3
# via flit
# via
# flit
# pytest-base-url
rpds-py==0.20.0
# via
# jsonschema
Expand Down Expand Up @@ -286,6 +303,8 @@ stack-data==0.6.3
# via ipython
starlette==0.38.5
# via shiny
text-unidecode==1.3
# via python-slugify
threadpoolctl==3.5.0
# via scikit-learn
tinycss2==1.3.0
Expand All @@ -312,6 +331,7 @@ typing-extensions==4.12.2
# via
# htmltools
# mypy
# pyee
# shiny
uc-micro-py==1.0.3
# via linkify-it-py
Expand Down

0 comments on commit b536518

Please sign in to comment.