From 31d74a5da21785eb20bae171a0930b79de5085f6 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Mon, 21 Jan 2019 08:37:07 -0800 Subject: [PATCH 1/3] Add capybara to requirements-dev.txt --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 8790500..edefc89 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,3 +4,4 @@ pytest-cov==2.6.0 freezegun==0.3.11 coveralls==1.5.1 wheel==0.32.3 +capybara-py==0.1.6 From fd2322d4609646c5fa42b8d5a1281551c5400142 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Mon, 21 Jan 2019 08:37:34 -0800 Subject: [PATCH 2/3] Add capybara stuff to conftest.py --- tests/conftest.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index cd4000b..8c5987c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,6 +4,7 @@ """ from pathlib import Path +import capybara import pytest from trendlines import db @@ -12,6 +13,8 @@ from trendlines.orm import DataPoint from trendlines.orm import Metric +pytest_plugins = ["capybara.pytest_plugin"] + @pytest.fixture def app(): @@ -30,6 +33,8 @@ def app(): pass app = create_app() + capybara.app = app + capybara.default_max_wait_time = 5 # Since the `create_db` function modifies orm.db directly, we can simply # call it here. I guess *technically* what's happening is whatever From 537fad938299ee24047933b9834b1b45dd1d98d9 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Mon, 21 Jan 2019 08:37:54 -0800 Subject: [PATCH 3/3] Add a capybara test case to test_routes.py --- tests/test_routes.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_routes.py b/tests/test_routes.py index a0bc0a0..2a54737 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -11,6 +11,12 @@ def test_index(client): assert rv.status_code == 200 +@pytest.mark.xfail(reason="Need to figure out the AJAX testing.") +def test_index_with_data_(app, page, populated_db): + page.visit("/") + assert page.has_text("empty_metric") + + @pytest.mark.xfail(reason="Need to figure out the AJAX testing.") def test_index_with_data(client, populated_db): rv = client.get('/')