Permalink
Browse files

New make_app_client() pattern

Because next version of pytest discourages calling fixture factories as functions
  • Loading branch information...
simonw committed Nov 20, 2018
1 parent 5e3a432 commit 3de8fac1d322cbab6c8c55899e0e8511b36337d0
Showing with 22 additions and 16 deletions.
  1. +12 −8 tests/fixtures.py
  2. +5 −4 tests/test_api.py
  3. +5 −4 tests/test_html.py
@@ -23,8 +23,7 @@ def get(self, path, allow_redirects=True):
)
@pytest.fixture(scope="session")
def app_client(
def make_app_client(
sql_time_limit_ms=None,
max_returned_rows=None,
cors=False,
@@ -61,38 +60,43 @@ def app_client(
yield client
@pytest.fixture(scope="session")
def app_client(**kwargs):
yield from make_app_client(**kwargs)
@pytest.fixture(scope='session')
def app_client_shorter_time_limit():
yield from app_client(20)
yield from make_app_client(20)
@pytest.fixture(scope='session')
def app_client_returned_rows_matches_page_size():
yield from app_client(max_returned_rows=50)
yield from make_app_client(max_returned_rows=50)
@pytest.fixture(scope='session')
def app_client_larger_cache_size():
yield from app_client(config={
yield from make_app_client(config={
'cache_size_kb': 2500,
})
@pytest.fixture(scope='session')
def app_client_csv_max_mb_one():
yield from app_client(config={
yield from make_app_client(config={
'max_csv_mb': 1,
})
@pytest.fixture(scope="session")
def app_client_with_dot():
yield from app_client(filename="fixtures.dot.db")
yield from make_app_client(filename="fixtures.dot.db")
@pytest.fixture(scope='session')
def app_client_with_cors():
yield from app_client(cors=True)
yield from make_app_client(cors=True)
def generate_compound_rows(num):
@@ -6,6 +6,7 @@
app_client_with_dot,
generate_compound_rows,
generate_sortable_rows,
make_app_client,
METADATA,
)
import pytest
@@ -435,7 +436,7 @@ def test_invalid_custom_sql(app_client):
def test_allow_sql_off():
for client in app_client(config={
for client in make_app_client(config={
'allow_sql': False,
}):
assert 400 == client.get(
@@ -1179,7 +1180,7 @@ def test_suggested_facets(app_client):
def test_allow_facet_off():
for client in app_client(config={
for client in make_app_client(config={
'allow_facet': False,
}):
assert 400 == client.get(
@@ -1192,7 +1193,7 @@ def test_allow_facet_off():
def test_suggest_facets_off():
for client in app_client(config={
for client in make_app_client(config={
'suggest_facets': False,
}):
# Now suggested_facets should be []
@@ -1304,7 +1305,7 @@ def test_config_cache_size(app_client_larger_cache_size):
def test_config_force_https_urls():
for client in app_client(config={"force_https_urls": True}):
for client in make_app_client(config={"force_https_urls": True}):
response = client.get("/fixtures/facetable.json?_size=3&_facet=state")
assert response.json["next_url"].startswith("https://")
assert response.json["facet_results"]["state"]["results"][0][
@@ -2,6 +2,7 @@
from .fixtures import ( # noqa
app_client,
app_client_shorter_time_limit,
make_app_client,
)
import pytest
import re
@@ -65,7 +66,7 @@ def test_row_strange_table_name(app_client):
def test_table_cell_truncation():
for client in app_client(config={
for client in make_app_client(config={
"truncate_cells_html": 5,
}):
response = client.get("/fixtures/facetable")
@@ -84,7 +85,7 @@ def test_table_cell_truncation():
def test_row_page_does_not_truncate():
for client in app_client(config={
for client in make_app_client(config={
"truncate_cells_html": 5,
}):
response = client.get("/fixtures/facetable/1")
@@ -690,7 +691,7 @@ def test_allow_download_on(app_client):
def test_allow_download_off():
for client in app_client(config={
for client in make_app_client(config={
'allow_download': False,
}):
response = client.get(
@@ -720,7 +721,7 @@ def test_allow_sql_on(app_client):
def test_allow_sql_off():
for client in app_client(config={
for client in make_app_client(config={
'allow_sql': False,
}):
response = client.get(

0 comments on commit 3de8fac

Please sign in to comment.