Skip to content

Commit

Permalink
test: add coverage to studio tests and app
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines authored and joanise committed Mar 28, 2023
1 parent 22de19b commit 0945336
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/studio-release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@ jobs:
pip install -r requirements.txt
pip install -r requirements/requirements.test.txt
pip install -e .
pip install coverage coveralls
- name: Ensure browser is installed
run: python -m playwright install --with-deps chromium
- name: Run tests
run: |
gunicorn --worker-class eventlet -w 1 g2p.app:APP --no-sendfile --bind 0.0.0.0:5000 --daemon
coverage run --include g2p/app.py --parallel-mode \
-m gunicorn --worker-class eventlet -w 1 g2p.app:APP --no-sendfile --bind 0.0.0.0:5000 --daemon
sleep 5
cd g2p/tests && python test_studio.py
python g2p/tests/test_studio.py
pkill coverage
sleep 5
coverage combine
coverage xml
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # too many upload errors to keep "true"
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ jobs:
pip install coverage coveralls
- name: Run tests
run: |
gunicorn --worker-class eventlet -w 1 g2p.app:APP --no-sendfile --bind 0.0.0.0:5000 --daemon
coverage run --omit g2p/app.py --omit 'g2p/tests/*' --parallel-mode \
-m gunicorn --worker-class eventlet -w 1 g2p.app:APP --no-sendfile --bind 0.0.0.0:5000 --daemon
sleep 5
coverage run run_tests.py dev
coverage run --omit g2p/app.py --omit 'g2p/tests/*' --parallel-mode run_tests.py dev
pkill coverage
sleep 5
coverage combine
coverage xml
if git status | grep -E 'static.*json|mapping.*pkl'; then echo 'g2p databases out of date, please run "g2p update" and commit the results.'; false; else echo OK; fi
- uses: codecov/codecov-action@v3
Expand Down
26 changes: 26 additions & 0 deletions g2p/tests/test_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ async def test_sanity(self):
async with async_playwright() as p:
browser = await p.chromium.launch(channel="chrome", headless=True)
page = await browser.new_page()
await page.goto(f"http://localhost:{self.port}/docs")
await page.wait_for_timeout(1000)
await page.goto(f"http://localhost:{self.port}")
await page.wait_for_timeout(1000)
input_el = page.locator("#input")
Expand All @@ -55,6 +57,30 @@ async def test_sanity(self):
self.assertEqual(input_text, "hello world")
await input_el.fill("")
await output_el.fill("")
await page.type("#input", "hello world")
await page.wait_for_timeout(1000)
radio_el = page.locator("#animated-radio")
await radio_el.click()
await page.wait_for_timeout(1000)

async def test_switch_langs(self):
async with async_playwright() as p:
browser = await p.chromium.launch(channel="chrome", headless=True)
page = await browser.new_page()
await page.goto(f"http://localhost:{self.port}")
await page.wait_for_timeout(1000)
in_lang_selector = page.locator("#input-langselect")
# Switch to a language
await in_lang_selector.select_option(value="alq")
await page.wait_for_timeout(1000)
settings_title = await page.text_content("#link-0")
self.assertEqual(settings_title, "Algonquin to IPA")
# Switch back to custom
await in_lang_selector.select_option(value="Custom")
await page.wait_for_timeout(1000)
settings_title = await page.text_content("#link-0")
self.assertEqual(settings_title, "Custom")
# FIXME: Test that the table works somewhere, somehow

async def test_langs(self):

Expand Down

0 comments on commit 0945336

Please sign in to comment.