mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Renamed test_tables.db to fixtures.db in unit tests
This commit is contained in:
parent
ed631e690b
commit
0357774c94
6 changed files with 139 additions and 139 deletions
|
|
@ -25,7 +25,7 @@ class TestClient:
|
|||
@pytest.fixture(scope='session')
|
||||
def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
filepath = os.path.join(tmpdir, 'test_tables.db')
|
||||
filepath = os.path.join(tmpdir, 'fixtures.db')
|
||||
conn = sqlite3.connect(filepath)
|
||||
conn.executescript(TABLES)
|
||||
os.chdir(os.path.dirname(filepath))
|
||||
|
|
@ -105,7 +105,7 @@ METADATA = {
|
|||
'source': 'Source',
|
||||
'source_url': 'http://www.example.com/source',
|
||||
'databases': {
|
||||
'test_tables': {
|
||||
'fixtures': {
|
||||
'description': 'Test tables description',
|
||||
'tables': {
|
||||
'simple_primary_key': {
|
||||
|
|
|
|||
|
|
@ -14,16 +14,16 @@ import urllib
|
|||
def test_homepage(app_client):
|
||||
response = app_client.get('/.json')
|
||||
assert response.status == 200
|
||||
assert response.json.keys() == {'test_tables': 0}.keys()
|
||||
d = response.json['test_tables']
|
||||
assert d['name'] == 'test_tables'
|
||||
assert response.json.keys() == {'fixtures': 0}.keys()
|
||||
d = response.json['fixtures']
|
||||
assert d['name'] == 'fixtures'
|
||||
assert d['tables_count'] == 17
|
||||
|
||||
|
||||
def test_database_page(app_client):
|
||||
response = app_client.get('/test_tables.json')
|
||||
response = app_client.get('/fixtures.json')
|
||||
data = response.json
|
||||
assert 'test_tables' == data['database']
|
||||
assert 'fixtures' == data['database']
|
||||
assert [{
|
||||
'columns': ['content'],
|
||||
'name': '123_starts_with_digits',
|
||||
|
|
@ -313,7 +313,7 @@ def test_database_page(app_client):
|
|||
|
||||
def test_custom_sql(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables.json?sql=select+content+from+simple_primary_key&_shape=objects'
|
||||
'/fixtures.json?sql=select+content+from+simple_primary_key&_shape=objects'
|
||||
)
|
||||
data = response.json
|
||||
assert {
|
||||
|
|
@ -326,13 +326,13 @@ def test_custom_sql(app_client):
|
|||
{'content': ''}
|
||||
] == data['rows']
|
||||
assert ['content'] == data['columns']
|
||||
assert 'test_tables' == data['database']
|
||||
assert 'fixtures' == data['database']
|
||||
assert not data['truncated']
|
||||
|
||||
|
||||
def test_sql_time_limit(app_client_shorter_time_limit):
|
||||
response = app_client_shorter_time_limit.get(
|
||||
'/test_tables.json?sql=select+sleep(0.5)'
|
||||
'/fixtures.json?sql=select+sleep(0.5)'
|
||||
)
|
||||
assert 400 == response.status
|
||||
assert 'SQL Interrupted' == response.json['title']
|
||||
|
|
@ -340,11 +340,11 @@ def test_sql_time_limit(app_client_shorter_time_limit):
|
|||
|
||||
def test_custom_sql_time_limit(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables.json?sql=select+sleep(0.01)'
|
||||
'/fixtures.json?sql=select+sleep(0.01)'
|
||||
)
|
||||
assert 200 == response.status
|
||||
response = app_client.get(
|
||||
'/test_tables.json?sql=select+sleep(0.01)&_timelimit=5'
|
||||
'/fixtures.json?sql=select+sleep(0.01)&_timelimit=5'
|
||||
)
|
||||
assert 400 == response.status
|
||||
assert 'SQL Interrupted' == response.json['title']
|
||||
|
|
@ -352,7 +352,7 @@ def test_custom_sql_time_limit(app_client):
|
|||
|
||||
def test_invalid_custom_sql(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables.json?sql=.schema'
|
||||
'/fixtures.json?sql=.schema'
|
||||
)
|
||||
assert response.status == 400
|
||||
assert response.json['ok'] is False
|
||||
|
|
@ -364,12 +364,12 @@ def test_allow_sql_off():
|
|||
'allow_sql': False,
|
||||
}):
|
||||
assert 400 == client.get(
|
||||
"/test_tables.json?sql=select+sleep(0.01)"
|
||||
"/fixtures.json?sql=select+sleep(0.01)"
|
||||
).status
|
||||
|
||||
|
||||
def test_table_json(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key.json?_shape=objects')
|
||||
response = app_client.get('/fixtures/simple_primary_key.json?_shape=objects')
|
||||
assert response.status == 200
|
||||
data = response.json
|
||||
assert data['query']['sql'] == 'select * from simple_primary_key order by id limit 51'
|
||||
|
|
@ -392,12 +392,12 @@ def test_table_not_exists_json(app_client):
|
|||
'error': 'Table not found: blah',
|
||||
'status': 404,
|
||||
'title': None,
|
||||
} == app_client.get('/test_tables/blah.json').json
|
||||
} == app_client.get('/fixtures/blah.json').json
|
||||
|
||||
|
||||
def test_jsono_redirects_to_shape_objects(app_client):
|
||||
response_1 = app_client.get(
|
||||
'/test_tables/simple_primary_key.jsono',
|
||||
'/fixtures/simple_primary_key.jsono',
|
||||
allow_redirects=False
|
||||
)
|
||||
response = app_client.get(
|
||||
|
|
@ -410,7 +410,7 @@ def test_jsono_redirects_to_shape_objects(app_client):
|
|||
|
||||
def test_table_shape_arrays(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/simple_primary_key.json?_shape=arrays'
|
||||
'/fixtures/simple_primary_key.json?_shape=arrays'
|
||||
)
|
||||
assert [
|
||||
['1', 'hello'],
|
||||
|
|
@ -421,7 +421,7 @@ def test_table_shape_arrays(app_client):
|
|||
|
||||
def test_table_shape_arrayfirst(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables.json?' + urllib.parse.urlencode({
|
||||
'/fixtures.json?' + urllib.parse.urlencode({
|
||||
'sql': 'select content from simple_primary_key order by id',
|
||||
'_shape': 'arrayfirst'
|
||||
})
|
||||
|
|
@ -431,7 +431,7 @@ def test_table_shape_arrayfirst(app_client):
|
|||
|
||||
def test_table_shape_objects(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/simple_primary_key.json?_shape=objects'
|
||||
'/fixtures/simple_primary_key.json?_shape=objects'
|
||||
)
|
||||
assert [{
|
||||
'id': '1',
|
||||
|
|
@ -447,7 +447,7 @@ def test_table_shape_objects(app_client):
|
|||
|
||||
def test_table_shape_array(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/simple_primary_key.json?_shape=array'
|
||||
'/fixtures/simple_primary_key.json?_shape=array'
|
||||
)
|
||||
assert [{
|
||||
'id': '1',
|
||||
|
|
@ -463,7 +463,7 @@ def test_table_shape_array(app_client):
|
|||
|
||||
def test_table_shape_invalid(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/simple_primary_key.json?_shape=invalid'
|
||||
'/fixtures/simple_primary_key.json?_shape=invalid'
|
||||
)
|
||||
assert {
|
||||
'ok': False,
|
||||
|
|
@ -475,7 +475,7 @@ def test_table_shape_invalid(app_client):
|
|||
|
||||
def test_table_shape_object(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/simple_primary_key.json?_shape=object'
|
||||
'/fixtures/simple_primary_key.json?_shape=object'
|
||||
)
|
||||
assert {
|
||||
'1': {
|
||||
|
|
@ -495,7 +495,7 @@ def test_table_shape_object(app_client):
|
|||
|
||||
def test_table_shape_object_compound_primary_Key(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/compound_primary_key.json?_shape=object'
|
||||
'/fixtures/compound_primary_key.json?_shape=object'
|
||||
)
|
||||
assert {
|
||||
'a,b': {
|
||||
|
|
@ -507,7 +507,7 @@ def test_table_shape_object_compound_primary_Key(app_client):
|
|||
|
||||
|
||||
def test_table_with_slashes_in_name(app_client):
|
||||
response = app_client.get('/test_tables/table%2Fwith%2Fslashes.csv?_shape=objects&_format=json')
|
||||
response = app_client.get('/fixtures/table%2Fwith%2Fslashes.csv?_shape=objects&_format=json')
|
||||
assert response.status == 200
|
||||
data = response.json
|
||||
assert data['rows'] == [{
|
||||
|
|
@ -517,7 +517,7 @@ def test_table_with_slashes_in_name(app_client):
|
|||
|
||||
|
||||
def test_table_with_reserved_word_name(app_client):
|
||||
response = app_client.get('/test_tables/select.json?_shape=objects')
|
||||
response = app_client.get('/fixtures/select.json?_shape=objects')
|
||||
assert response.status == 200
|
||||
data = response.json
|
||||
assert data['rows'] == [{
|
||||
|
|
@ -529,14 +529,14 @@ def test_table_with_reserved_word_name(app_client):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('path,expected_rows,expected_pages', [
|
||||
('/test_tables/no_primary_key.json', 201, 5),
|
||||
('/test_tables/paginated_view.json', 201, 5),
|
||||
('/test_tables/no_primary_key.json?_size=25', 201, 9),
|
||||
('/test_tables/paginated_view.json?_size=25', 201, 9),
|
||||
('/test_tables/paginated_view.json?_size=max', 201, 3),
|
||||
('/test_tables/123_starts_with_digits.json', 0, 1),
|
||||
('/fixtures/no_primary_key.json', 201, 5),
|
||||
('/fixtures/paginated_view.json', 201, 5),
|
||||
('/fixtures/no_primary_key.json?_size=25', 201, 9),
|
||||
('/fixtures/paginated_view.json?_size=25', 201, 9),
|
||||
('/fixtures/paginated_view.json?_size=max', 201, 3),
|
||||
('/fixtures/123_starts_with_digits.json', 0, 1),
|
||||
# Ensure faceting doesn't break pagination:
|
||||
('/test_tables/compound_three_primary_keys.json?_facet=pk1', 1001, 21),
|
||||
('/fixtures/compound_three_primary_keys.json?_facet=pk1', 1001, 21),
|
||||
])
|
||||
def test_paginate_tables_and_views(app_client, path, expected_rows, expected_pages):
|
||||
fetched = []
|
||||
|
|
@ -559,9 +559,9 @@ def test_paginate_tables_and_views(app_client, path, expected_rows, expected_pag
|
|||
|
||||
|
||||
@pytest.mark.parametrize('path,expected_error', [
|
||||
('/test_tables/no_primary_key.json?_size=-4', '_size must be a positive integer'),
|
||||
('/test_tables/no_primary_key.json?_size=dog', '_size must be a positive integer'),
|
||||
('/test_tables/no_primary_key.json?_size=1001', '_size must be <= 100'),
|
||||
('/fixtures/no_primary_key.json?_size=-4', '_size must be a positive integer'),
|
||||
('/fixtures/no_primary_key.json?_size=dog', '_size must be a positive integer'),
|
||||
('/fixtures/no_primary_key.json?_size=1001', '_size must be <= 100'),
|
||||
])
|
||||
def test_validate_page_size(app_client, path, expected_error):
|
||||
response = app_client.get(path)
|
||||
|
|
@ -571,7 +571,7 @@ def test_validate_page_size(app_client, path, expected_error):
|
|||
|
||||
def test_page_size_zero(app_client):
|
||||
"For _size=0 we return the counts, empty rows and no continuation token"
|
||||
response = app_client.get('/test_tables/no_primary_key.json?_size=0')
|
||||
response = app_client.get('/fixtures/no_primary_key.json?_size=0')
|
||||
assert 200 == response.status
|
||||
assert [] == response.json['rows']
|
||||
assert 201 == response.json['table_rows_count']
|
||||
|
|
@ -582,7 +582,7 @@ def test_page_size_zero(app_client):
|
|||
|
||||
def test_paginate_compound_keys(app_client):
|
||||
fetched = []
|
||||
path = '/test_tables/compound_three_primary_keys.json?_shape=objects'
|
||||
path = '/fixtures/compound_three_primary_keys.json?_shape=objects'
|
||||
page = 0
|
||||
while path:
|
||||
page += 1
|
||||
|
|
@ -600,7 +600,7 @@ def test_paginate_compound_keys(app_client):
|
|||
|
||||
def test_paginate_compound_keys_with_extra_filters(app_client):
|
||||
fetched = []
|
||||
path = '/test_tables/compound_three_primary_keys.json?content__contains=d&_shape=objects'
|
||||
path = '/fixtures/compound_three_primary_keys.json?content__contains=d&_shape=objects'
|
||||
page = 0
|
||||
while path:
|
||||
page += 1
|
||||
|
|
@ -640,7 +640,7 @@ def test_paginate_compound_keys_with_extra_filters(app_client):
|
|||
('_sort=text', lambda row: row['text'], 'sorted by text'),
|
||||
])
|
||||
def test_sortable(app_client, query_string, sort_key, human_description_en):
|
||||
path = '/test_tables/sortable.json?_shape=objects&{}'.format(query_string)
|
||||
path = '/fixtures/sortable.json?_shape=objects&{}'.format(query_string)
|
||||
fetched = []
|
||||
page = 0
|
||||
while path:
|
||||
|
|
@ -662,7 +662,7 @@ def test_sortable(app_client, query_string, sort_key, human_description_en):
|
|||
|
||||
def test_sortable_and_filtered(app_client):
|
||||
path = (
|
||||
'/test_tables/sortable.json'
|
||||
'/fixtures/sortable.json'
|
||||
'?content__contains=d&_sort_desc=sortable&_shape=objects'
|
||||
)
|
||||
response = app_client.get(path)
|
||||
|
|
@ -685,44 +685,44 @@ def test_sortable_and_filtered(app_client):
|
|||
|
||||
def test_sortable_argument_errors(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/sortable.json?_sort=badcolumn'
|
||||
'/fixtures/sortable.json?_sort=badcolumn'
|
||||
)
|
||||
assert 'Cannot sort table by badcolumn' == response.json['error']
|
||||
response = app_client.get(
|
||||
'/test_tables/sortable.json?_sort_desc=badcolumn2'
|
||||
'/fixtures/sortable.json?_sort_desc=badcolumn2'
|
||||
)
|
||||
assert 'Cannot sort table by badcolumn2' == response.json['error']
|
||||
response = app_client.get(
|
||||
'/test_tables/sortable.json?_sort=sortable_with_nulls&_sort_desc=sortable'
|
||||
'/fixtures/sortable.json?_sort=sortable_with_nulls&_sort_desc=sortable'
|
||||
)
|
||||
assert 'Cannot use _sort and _sort_desc at the same time' == response.json['error']
|
||||
|
||||
|
||||
def test_sortable_columns_metadata(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/sortable.json?_sort=content'
|
||||
'/fixtures/sortable.json?_sort=content'
|
||||
)
|
||||
assert 'Cannot sort table by content' == response.json['error']
|
||||
# no_primary_key has ALL sort options disabled
|
||||
for column in ('content', 'a', 'b', 'c'):
|
||||
response = app_client.get(
|
||||
'/test_tables/sortable.json?_sort={}'.format(column)
|
||||
'/fixtures/sortable.json?_sort={}'.format(column)
|
||||
)
|
||||
assert 'Cannot sort table by {}'.format(column) == response.json['error']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('path,expected_rows', [
|
||||
('/test_tables/searchable.json?_search=dog', [
|
||||
('/fixtures/searchable.json?_search=dog', [
|
||||
[1, 'barry cat', 'terry dog', 'panther'],
|
||||
[2, 'terry dog', 'sara weasel', 'puma'],
|
||||
]),
|
||||
('/test_tables/searchable.json?_search=weasel', [
|
||||
('/fixtures/searchable.json?_search=weasel', [
|
||||
[2, 'terry dog', 'sara weasel', 'puma'],
|
||||
]),
|
||||
('/test_tables/searchable.json?_search_text2=dog', [
|
||||
('/fixtures/searchable.json?_search_text2=dog', [
|
||||
[1, 'barry cat', 'terry dog', 'panther'],
|
||||
]),
|
||||
('/test_tables/searchable.json?_search_name%20with%20.%20and%20spaces=panther', [
|
||||
('/fixtures/searchable.json?_search_name%20with%20.%20and%20spaces=panther', [
|
||||
[1, 'barry cat', 'terry dog', 'panther'],
|
||||
]),
|
||||
])
|
||||
|
|
@ -733,7 +733,7 @@ def test_searchable(app_client, path, expected_rows):
|
|||
|
||||
def test_searchable_invalid_column(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/searchable.json?_search_invalid=x'
|
||||
'/fixtures/searchable.json?_search_invalid=x'
|
||||
)
|
||||
assert 400 == response.status
|
||||
assert {
|
||||
|
|
@ -745,17 +745,17 @@ def test_searchable_invalid_column(app_client):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('path,expected_rows', [
|
||||
('/test_tables/simple_primary_key.json?content=hello', [
|
||||
('/fixtures/simple_primary_key.json?content=hello', [
|
||||
['1', 'hello'],
|
||||
]),
|
||||
('/test_tables/simple_primary_key.json?content__contains=o', [
|
||||
('/fixtures/simple_primary_key.json?content__contains=o', [
|
||||
['1', 'hello'],
|
||||
['2', 'world'],
|
||||
]),
|
||||
('/test_tables/simple_primary_key.json?content__exact=', [
|
||||
('/fixtures/simple_primary_key.json?content__exact=', [
|
||||
['3', ''],
|
||||
]),
|
||||
('/test_tables/simple_primary_key.json?content__not=world', [
|
||||
('/fixtures/simple_primary_key.json?content__not=world', [
|
||||
['1', 'hello'],
|
||||
['3', ''],
|
||||
]),
|
||||
|
|
@ -767,7 +767,7 @@ def test_table_filter_queries(app_client, path, expected_rows):
|
|||
|
||||
def test_max_returned_rows(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables.json?sql=select+content+from+no_primary_key'
|
||||
'/fixtures.json?sql=select+content+from+no_primary_key'
|
||||
)
|
||||
data = response.json
|
||||
assert {
|
||||
|
|
@ -779,7 +779,7 @@ def test_max_returned_rows(app_client):
|
|||
|
||||
|
||||
def test_view(app_client):
|
||||
response = app_client.get('/test_tables/simple_view.json?_shape=objects')
|
||||
response = app_client.get('/fixtures/simple_view.json?_shape=objects')
|
||||
assert response.status == 200
|
||||
data = response.json
|
||||
assert data['rows'] == [{
|
||||
|
|
@ -795,13 +795,13 @@ def test_view(app_client):
|
|||
|
||||
|
||||
def test_row(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key/1.json?_shape=objects')
|
||||
response = app_client.get('/fixtures/simple_primary_key/1.json?_shape=objects')
|
||||
assert response.status == 200
|
||||
assert [{'id': '1', 'content': 'hello'}] == response.json['rows']
|
||||
|
||||
|
||||
def test_row_foreign_key_tables(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key/1.json?_extras=foreign_key_tables')
|
||||
response = app_client.get('/fixtures/simple_primary_key/1.json?_extras=foreign_key_tables')
|
||||
assert response.status == 200
|
||||
assert [{
|
||||
'column': 'id',
|
||||
|
|
@ -828,7 +828,7 @@ def test_row_foreign_key_tables(app_client):
|
|||
|
||||
def test_unit_filters(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/units.json?distance__lt=75km&frequency__gt=1kHz'
|
||||
'/fixtures/units.json?distance__lt=75km&frequency__gt=1kHz'
|
||||
)
|
||||
assert response.status == 200
|
||||
data = response.json
|
||||
|
|
@ -906,7 +906,7 @@ def test_config_json(app_client):
|
|||
|
||||
def test_page_size_matching_max_returned_rows(app_client_returned_rows_matches_page_size):
|
||||
fetched = []
|
||||
path = '/test_tables/no_primary_key.json'
|
||||
path = '/fixtures/no_primary_key.json'
|
||||
while path:
|
||||
response = app_client_returned_rows_matches_page_size.get(path)
|
||||
fetched.extend(response.json['rows'])
|
||||
|
|
@ -917,7 +917,7 @@ def test_page_size_matching_max_returned_rows(app_client_returned_rows_matches_p
|
|||
|
||||
@pytest.mark.parametrize('path,expected_facet_results', [
|
||||
(
|
||||
"/test_tables/facetable.json?_facet=state&_facet=city_id",
|
||||
"/fixtures/facetable.json?_facet=state&_facet=city_id",
|
||||
{
|
||||
"state": {
|
||||
"name": "state",
|
||||
|
|
@ -982,7 +982,7 @@ def test_page_size_matching_max_returned_rows(app_client_returned_rows_matches_p
|
|||
}
|
||||
}
|
||||
), (
|
||||
"/test_tables/facetable.json?_facet=state&_facet=city_id&state=MI",
|
||||
"/fixtures/facetable.json?_facet=state&_facet=city_id&state=MI",
|
||||
{
|
||||
"state": {
|
||||
"name": "state",
|
||||
|
|
@ -1012,7 +1012,7 @@ def test_page_size_matching_max_returned_rows(app_client_returned_rows_matches_p
|
|||
},
|
||||
},
|
||||
), (
|
||||
"/test_tables/facetable.json?_facet=planet_int",
|
||||
"/fixtures/facetable.json?_facet=planet_int",
|
||||
{
|
||||
"planet_int": {
|
||||
"name": "planet_int",
|
||||
|
|
@ -1037,7 +1037,7 @@ def test_page_size_matching_max_returned_rows(app_client_returned_rows_matches_p
|
|||
},
|
||||
), (
|
||||
# planet_int is an integer field:
|
||||
"/test_tables/facetable.json?_facet=planet_int&planet_int=1",
|
||||
"/fixtures/facetable.json?_facet=planet_int&planet_int=1",
|
||||
{
|
||||
"planet_int": {
|
||||
"name": "planet_int",
|
||||
|
|
@ -1069,7 +1069,7 @@ def test_facets(app_client, path, expected_facet_results):
|
|||
|
||||
def test_suggested_facets(app_client):
|
||||
assert len(app_client.get(
|
||||
"/test_tables/facetable.json"
|
||||
"/fixtures/facetable.json"
|
||||
).json["suggested_facets"]) > 0
|
||||
|
||||
|
||||
|
|
@ -1078,11 +1078,11 @@ def test_allow_facet_off():
|
|||
'allow_facet': False,
|
||||
}):
|
||||
assert 400 == client.get(
|
||||
"/test_tables/facetable.json?_facet=planet_int"
|
||||
"/fixtures/facetable.json?_facet=planet_int"
|
||||
).status
|
||||
# Should not suggest any facets either:
|
||||
assert [] == client.get(
|
||||
"/test_tables/facetable.json"
|
||||
"/fixtures/facetable.json"
|
||||
).json["suggested_facets"]
|
||||
|
||||
|
||||
|
|
@ -1092,13 +1092,13 @@ def test_suggest_facets_off():
|
|||
}):
|
||||
# Now suggested_facets should be []
|
||||
assert [] == client.get(
|
||||
"/test_tables/facetable.json"
|
||||
"/fixtures/facetable.json"
|
||||
).json["suggested_facets"]
|
||||
|
||||
|
||||
def test_expand_labels(app_client):
|
||||
response = app_client.get(
|
||||
"/test_tables/facetable.json?_shape=object&_labels=1&_size=2"
|
||||
"/fixtures/facetable.json?_shape=object&_labels=1&_size=2"
|
||||
"&neighborhood__contains=c"
|
||||
)
|
||||
assert {
|
||||
|
|
@ -1127,7 +1127,7 @@ def test_expand_labels(app_client):
|
|||
|
||||
def test_expand_label(app_client):
|
||||
response = app_client.get(
|
||||
"/test_tables/foreign_key_references.json?_shape=object"
|
||||
"/fixtures/foreign_key_references.json?_shape=object"
|
||||
"&_label=foreign_key_with_label"
|
||||
)
|
||||
assert {
|
||||
|
|
@ -1143,10 +1143,10 @@ def test_expand_label(app_client):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('path,expected_cache_control', [
|
||||
("/test_tables/facetable.json", "max-age=31536000"),
|
||||
("/test_tables/facetable.json?_ttl=invalid", "max-age=31536000"),
|
||||
("/test_tables/facetable.json?_ttl=10", "max-age=10"),
|
||||
("/test_tables/facetable.json?_ttl=0", "no-cache"),
|
||||
("/fixtures/facetable.json", "max-age=31536000"),
|
||||
("/fixtures/facetable.json?_ttl=invalid", "max-age=31536000"),
|
||||
("/fixtures/facetable.json?_ttl=10", "max-age=10"),
|
||||
("/fixtures/facetable.json?_ttl=0", "no-cache"),
|
||||
])
|
||||
def test_ttl_parameter(app_client, path, expected_cache_control):
|
||||
response = app_client.get(path)
|
||||
|
|
@ -1180,7 +1180,7 @@ def test_json_columns(app_client, extra_args, expected):
|
|||
select 1 as intval, "s" as strval, 0.5 as floatval,
|
||||
'{"foo": "bar"}' as jsonval
|
||||
'''
|
||||
path = "/test_tables.json?" + urllib.parse.urlencode({
|
||||
path = "/fixtures.json?" + urllib.parse.urlencode({
|
||||
"sql": sql,
|
||||
"_shape": "array"
|
||||
})
|
||||
|
|
@ -1191,6 +1191,6 @@ def test_json_columns(app_client, extra_args, expected):
|
|||
|
||||
def test_config_cache_size(app_client_larger_cache_size):
|
||||
response = app_client_larger_cache_size.get(
|
||||
'/test_tables/pragma_cache_size.json'
|
||||
'/fixtures/pragma_cache_size.json'
|
||||
)
|
||||
assert [[-2500]] == response.json['rows']
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ pk,planet_int,state,city_id,city_id_label,neighborhood
|
|||
'''.lstrip().replace('\n', '\r\n')
|
||||
|
||||
def test_table_csv(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key.csv')
|
||||
response = app_client.get('/fixtures/simple_primary_key.csv')
|
||||
assert response.status == 200
|
||||
assert 'text/plain; charset=utf-8' == response.headers['Content-Type']
|
||||
assert EXPECTED_TABLE_CSV == response.text
|
||||
|
||||
|
||||
def test_table_csv_with_labels(app_client):
|
||||
response = app_client.get('/test_tables/facetable.csv?_labels=1')
|
||||
response = app_client.get('/fixtures/facetable.csv?_labels=1')
|
||||
assert response.status == 200
|
||||
assert 'text/plain; charset=utf-8' == response.headers['Content-Type']
|
||||
assert EXPECTED_TABLE_WITH_LABELS_CSV == response.text
|
||||
|
|
@ -46,7 +46,7 @@ def test_table_csv_with_labels(app_client):
|
|||
|
||||
def test_custom_sql_csv(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables.csv?sql=select+content+from+simple_primary_key+limit+2'
|
||||
'/fixtures.csv?sql=select+content+from+simple_primary_key+limit+2'
|
||||
)
|
||||
assert response.status == 200
|
||||
assert 'text/plain; charset=utf-8' == response.headers['Content-Type']
|
||||
|
|
@ -54,7 +54,7 @@ def test_custom_sql_csv(app_client):
|
|||
|
||||
|
||||
def test_table_csv_download(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key.csv?_dl=1')
|
||||
response = app_client.get('/fixtures/simple_primary_key.csv?_dl=1')
|
||||
assert response.status == 200
|
||||
assert 'text/csv; charset=utf-8' == response.headers['Content-Type']
|
||||
expected_disposition = 'attachment; filename="simple_primary_key.csv"'
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@ import urllib.parse
|
|||
def test_homepage(app_client):
|
||||
response = app_client.get('/')
|
||||
assert response.status == 200
|
||||
assert 'test_tables' in response.text
|
||||
assert 'fixtures' in response.text
|
||||
|
||||
|
||||
def test_database_page(app_client):
|
||||
response = app_client.get('/test_tables', allow_redirects=False)
|
||||
response = app_client.get('/fixtures', allow_redirects=False)
|
||||
assert response.status == 302
|
||||
response = app_client.get('/test_tables')
|
||||
assert 'test_tables' in response.text
|
||||
response = app_client.get('/fixtures')
|
||||
assert 'fixtures' in response.text
|
||||
|
||||
|
||||
def test_invalid_custom_sql(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables?sql=.schema'
|
||||
'/fixtures?sql=.schema'
|
||||
)
|
||||
assert response.status == 400
|
||||
assert 'Statement must be a SELECT' in response.text
|
||||
|
|
@ -31,7 +31,7 @@ def test_invalid_custom_sql(app_client):
|
|||
|
||||
def test_sql_time_limit(app_client_shorter_time_limit):
|
||||
response = app_client_shorter_time_limit.get(
|
||||
'/test_tables?sql=select+sleep(0.5)'
|
||||
'/fixtures?sql=select+sleep(0.5)'
|
||||
)
|
||||
assert 400 == response.status
|
||||
expected_html_fragment = """
|
||||
|
|
@ -41,18 +41,18 @@ def test_sql_time_limit(app_client_shorter_time_limit):
|
|||
|
||||
|
||||
def test_view(app_client):
|
||||
response = app_client.get('/test_tables/simple_view')
|
||||
response = app_client.get('/fixtures/simple_view')
|
||||
assert response.status == 200
|
||||
|
||||
|
||||
def test_row(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/simple_primary_key/1',
|
||||
'/fixtures/simple_primary_key/1',
|
||||
allow_redirects=False
|
||||
)
|
||||
assert response.status == 302
|
||||
assert response.headers['Location'].endswith('/1')
|
||||
response = app_client.get('/test_tables/simple_primary_key/1')
|
||||
response = app_client.get('/fixtures/simple_primary_key/1')
|
||||
assert response.status == 200
|
||||
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ def test_add_filter_redirects(app_client):
|
|||
})
|
||||
# First we need to resolve the correct path before testing more redirects
|
||||
path_base = app_client.get(
|
||||
'/test_tables/simple_primary_key', allow_redirects=False
|
||||
'/fixtures/simple_primary_key', allow_redirects=False
|
||||
).headers['Location']
|
||||
path = path_base + '?' + filter_args
|
||||
response = app_client.get(path, allow_redirects=False)
|
||||
|
|
@ -104,7 +104,7 @@ def test_existing_filter_redirects(app_client):
|
|||
'_filter_value_4': 'world',
|
||||
}
|
||||
path_base = app_client.get(
|
||||
'/test_tables/simple_primary_key', allow_redirects=False
|
||||
'/fixtures/simple_primary_key', allow_redirects=False
|
||||
).headers['Location']
|
||||
path = path_base + '?' + urllib.parse.urlencode(filter_args)
|
||||
response = app_client.get(path, allow_redirects=False)
|
||||
|
|
@ -132,7 +132,7 @@ def test_existing_filter_redirects(app_client):
|
|||
|
||||
def test_empty_search_parameter_gets_removed(app_client):
|
||||
path_base = app_client.get(
|
||||
'/test_tables/simple_primary_key', allow_redirects=False
|
||||
'/fixtures/simple_primary_key', allow_redirects=False
|
||||
).headers['Location']
|
||||
path = path_base + '?' + urllib.parse.urlencode({
|
||||
'_search': '',
|
||||
|
|
@ -149,7 +149,7 @@ def test_empty_search_parameter_gets_removed(app_client):
|
|||
|
||||
def test_sort_by_desc_redirects(app_client):
|
||||
path_base = app_client.get(
|
||||
'/test_tables/sortable', allow_redirects=False
|
||||
'/fixtures/sortable', allow_redirects=False
|
||||
).headers['Location']
|
||||
path = path_base + '?' + urllib.parse.urlencode({
|
||||
'_sort': 'sortable',
|
||||
|
|
@ -162,7 +162,7 @@ def test_sort_by_desc_redirects(app_client):
|
|||
|
||||
def test_sort_links(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/sortable?_sort=sortable'
|
||||
'/fixtures/sortable?_sort=sortable'
|
||||
|
||||
)
|
||||
assert response.status == 200
|
||||
|
|
@ -213,7 +213,7 @@ def test_sort_links(app_client):
|
|||
|
||||
def test_facets_persist_through_filter_form(app_client):
|
||||
response = app_client.get(
|
||||
'/test_tables/facetable?_facet=planet_int&_facet=city_id'
|
||||
'/fixtures/facetable?_facet=planet_int&_facet=city_id'
|
||||
)
|
||||
assert response.status == 200
|
||||
inputs = Soup(response.body, 'html.parser').find('form').findAll('input')
|
||||
|
|
@ -228,15 +228,15 @@ def test_facets_persist_through_filter_form(app_client):
|
|||
|
||||
@pytest.mark.parametrize('path,expected_classes', [
|
||||
('/', ['index']),
|
||||
('/test_tables', ['db', 'db-test_tables']),
|
||||
('/test_tables/simple_primary_key', [
|
||||
'table', 'db-test_tables', 'table-simple_primary_key'
|
||||
('/fixtures', ['db', 'db-fixtures']),
|
||||
('/fixtures/simple_primary_key', [
|
||||
'table', 'db-fixtures', 'table-simple_primary_key'
|
||||
]),
|
||||
('/test_tables/table%2Fwith%2Fslashes.csv', [
|
||||
'table', 'db-test_tables', 'table-tablewithslashescsv-fa7563'
|
||||
('/fixtures/table%2Fwith%2Fslashes.csv', [
|
||||
'table', 'db-fixtures', 'table-tablewithslashescsv-fa7563'
|
||||
]),
|
||||
('/test_tables/simple_primary_key/1', [
|
||||
'row', 'db-test_tables', 'table-simple_primary_key'
|
||||
('/fixtures/simple_primary_key/1', [
|
||||
'row', 'db-fixtures', 'table-simple_primary_key'
|
||||
]),
|
||||
])
|
||||
def test_css_classes_on_body(app_client, path, expected_classes):
|
||||
|
|
@ -247,7 +247,7 @@ def test_css_classes_on_body(app_client, path, expected_classes):
|
|||
|
||||
|
||||
def test_table_html_simple_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key')
|
||||
response = app_client.get('/fixtures/simple_primary_key')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
assert table['class'] == ['rows-and-columns']
|
||||
|
|
@ -262,20 +262,20 @@ def test_table_html_simple_primary_key(app_client):
|
|||
assert ['nofollow'] == a['rel']
|
||||
assert [
|
||||
[
|
||||
'<td class="col-id"><a href="/test_tables/simple_primary_key/1">1</a></td>',
|
||||
'<td class="col-id"><a href="/fixtures/simple_primary_key/1">1</a></td>',
|
||||
'<td class="col-content">hello</td>'
|
||||
], [
|
||||
'<td class="col-id"><a href="/test_tables/simple_primary_key/2">2</a></td>',
|
||||
'<td class="col-id"><a href="/fixtures/simple_primary_key/2">2</a></td>',
|
||||
'<td class="col-content">world</td>'
|
||||
], [
|
||||
'<td class="col-id"><a href="/test_tables/simple_primary_key/3">3</a></td>',
|
||||
'<td class="col-id"><a href="/fixtures/simple_primary_key/3">3</a></td>',
|
||||
'<td class="col-content"></td>'
|
||||
]
|
||||
] == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
|
||||
|
||||
|
||||
def test_table_csv_json_export_links(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key')
|
||||
response = app_client.get('/fixtures/simple_primary_key')
|
||||
assert response.status == 200
|
||||
links = Soup(response.body, "html.parser").find("p", {
|
||||
"class": "export-links"
|
||||
|
|
@ -290,7 +290,7 @@ def test_table_csv_json_export_links(app_client):
|
|||
|
||||
|
||||
def test_row_html_simple_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key/1')
|
||||
response = app_client.get('/fixtures/simple_primary_key/1')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
assert [
|
||||
|
|
@ -306,12 +306,12 @@ def test_row_html_simple_primary_key(app_client):
|
|||
|
||||
def test_table_not_exists(app_client):
|
||||
assert 'Table not found: blah' in app_client.get(
|
||||
'/test_tables/blah'
|
||||
'/fixtures/blah'
|
||||
).body.decode('utf8')
|
||||
|
||||
|
||||
def test_table_html_no_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/no_primary_key')
|
||||
response = app_client.get('/fixtures/no_primary_key')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
# We have disabled sorting for this table using metadata.json
|
||||
|
|
@ -320,7 +320,7 @@ def test_table_html_no_primary_key(app_client):
|
|||
] == [th.string.strip() for th in table.select('thead th')[2:]]
|
||||
expected = [
|
||||
[
|
||||
'<td class="col-Link"><a href="/test_tables/no_primary_key/{}">{}</a></td>'.format(i, i),
|
||||
'<td class="col-Link"><a href="/fixtures/no_primary_key/{}">{}</a></td>'.format(i, i),
|
||||
'<td class="col-rowid">{}</td>'.format(i),
|
||||
'<td class="col-content">{}</td>'.format(i),
|
||||
'<td class="col-a">a{}</td>'.format(i),
|
||||
|
|
@ -332,7 +332,7 @@ def test_table_html_no_primary_key(app_client):
|
|||
|
||||
|
||||
def test_row_html_no_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/no_primary_key/1')
|
||||
response = app_client.get('/fixtures/no_primary_key/1')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
assert [
|
||||
|
|
@ -351,7 +351,7 @@ def test_row_html_no_primary_key(app_client):
|
|||
|
||||
|
||||
def test_table_html_compound_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/compound_primary_key')
|
||||
response = app_client.get('/fixtures/compound_primary_key')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
ths = table.findAll('th')
|
||||
|
|
@ -365,7 +365,7 @@ def test_table_html_compound_primary_key(app_client):
|
|||
))
|
||||
expected = [
|
||||
[
|
||||
'<td class="col-Link"><a href="/test_tables/compound_primary_key/a,b">a,b</a></td>',
|
||||
'<td class="col-Link"><a href="/fixtures/compound_primary_key/a,b">a,b</a></td>',
|
||||
'<td class="col-pk1">a</td>',
|
||||
'<td class="col-pk2">b</td>',
|
||||
'<td class="col-content">c</td>',
|
||||
|
|
@ -375,26 +375,26 @@ def test_table_html_compound_primary_key(app_client):
|
|||
|
||||
|
||||
def test_table_html_foreign_key_links(app_client):
|
||||
response = app_client.get('/test_tables/foreign_key_references')
|
||||
response = app_client.get('/fixtures/foreign_key_references')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
expected = [
|
||||
[
|
||||
'<td class="col-pk"><a href="/test_tables/foreign_key_references/1">1</a></td>',
|
||||
'<td class="col-foreign_key_with_label"><a href="/test_tables/simple_primary_key/1">hello</a>\xa0<em>1</em></td>',
|
||||
'<td class="col-foreign_key_with_no_label"><a href="/test_tables/primary_key_multiple_columns/1">1</a></td>'
|
||||
'<td class="col-pk"><a href="/fixtures/foreign_key_references/1">1</a></td>',
|
||||
'<td class="col-foreign_key_with_label"><a href="/fixtures/simple_primary_key/1">hello</a>\xa0<em>1</em></td>',
|
||||
'<td class="col-foreign_key_with_no_label"><a href="/fixtures/primary_key_multiple_columns/1">1</a></td>'
|
||||
]
|
||||
]
|
||||
assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
|
||||
|
||||
|
||||
def test_table_html_disable_foreign_key_links_with_labels(app_client):
|
||||
response = app_client.get('/test_tables/foreign_key_references?_labels=off')
|
||||
response = app_client.get('/fixtures/foreign_key_references?_labels=off')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
expected = [
|
||||
[
|
||||
'<td class="col-pk"><a href="/test_tables/foreign_key_references/1">1</a></td>',
|
||||
'<td class="col-pk"><a href="/fixtures/foreign_key_references/1">1</a></td>',
|
||||
'<td class="col-foreign_key_with_label">1</td>',
|
||||
'<td class="col-foreign_key_with_no_label">1</td>'
|
||||
]
|
||||
|
|
@ -403,20 +403,20 @@ def test_table_html_disable_foreign_key_links_with_labels(app_client):
|
|||
|
||||
|
||||
def test_table_html_foreign_key_custom_label_column(app_client):
|
||||
response = app_client.get('/test_tables/custom_foreign_key_label')
|
||||
response = app_client.get('/fixtures/custom_foreign_key_label')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
expected = [
|
||||
[
|
||||
'<td class="col-pk"><a href="/test_tables/custom_foreign_key_label/1">1</a></td>',
|
||||
'<td class="col-foreign_key_with_custom_label"><a href="/test_tables/primary_key_multiple_columns_explicit_label/1">world2</a>\xa0<em>1</em></td>',
|
||||
'<td class="col-pk"><a href="/fixtures/custom_foreign_key_label/1">1</a></td>',
|
||||
'<td class="col-foreign_key_with_custom_label"><a href="/fixtures/primary_key_multiple_columns_explicit_label/1">world2</a>\xa0<em>1</em></td>',
|
||||
]
|
||||
]
|
||||
assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
|
||||
|
||||
|
||||
def test_row_html_compound_primary_key(app_client):
|
||||
response = app_client.get('/test_tables/compound_primary_key/a,b')
|
||||
response = app_client.get('/fixtures/compound_primary_key/a,b')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
assert [
|
||||
|
|
@ -433,7 +433,7 @@ def test_row_html_compound_primary_key(app_client):
|
|||
|
||||
|
||||
def test_view_html(app_client):
|
||||
response = app_client.get('/test_tables/simple_view')
|
||||
response = app_client.get('/fixtures/simple_view')
|
||||
assert response.status == 200
|
||||
table = Soup(response.body, 'html.parser').find('table')
|
||||
assert [
|
||||
|
|
@ -466,11 +466,11 @@ def test_index_metadata(app_client):
|
|||
|
||||
|
||||
def test_database_metadata(app_client):
|
||||
response = app_client.get('/test_tables')
|
||||
response = app_client.get('/fixtures')
|
||||
assert response.status == 200
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
# Page title should be the default
|
||||
assert 'test_tables' == soup.find('h1').text
|
||||
assert 'fixtures' == soup.find('h1').text
|
||||
# Description should be custom
|
||||
assert 'Test tables description' == inner_html(
|
||||
soup.find('div', {'class': 'metadata-description'})
|
||||
|
|
@ -480,7 +480,7 @@ def test_database_metadata(app_client):
|
|||
|
||||
|
||||
def test_table_metadata(app_client):
|
||||
response = app_client.get('/test_tables/simple_primary_key')
|
||||
response = app_client.get('/fixtures/simple_primary_key')
|
||||
assert response.status == 200
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
# Page title should be custom and should be HTML escaped
|
||||
|
|
@ -495,7 +495,7 @@ def test_table_metadata(app_client):
|
|||
|
||||
def test_allow_download_on(app_client):
|
||||
response = app_client.get(
|
||||
"/test_tables"
|
||||
"/fixtures"
|
||||
)
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
assert len(soup.findAll('a', {'href': re.compile('\.db$')}))
|
||||
|
|
@ -506,14 +506,14 @@ def test_allow_download_off():
|
|||
'allow_download': False,
|
||||
}):
|
||||
response = client.get(
|
||||
"/test_tables",
|
||||
"/fixtures",
|
||||
|
||||
)
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
assert not len(soup.findAll('a', {'href': re.compile('\.db$')}))
|
||||
# Accessing URL directly should 403
|
||||
response = client.get(
|
||||
"/test_tables.db",
|
||||
"/fixtures.db",
|
||||
|
||||
)
|
||||
assert 403 == response.status
|
||||
|
|
@ -521,7 +521,7 @@ def test_allow_download_off():
|
|||
|
||||
def test_allow_sql_on(app_client):
|
||||
response = app_client.get(
|
||||
"/test_tables"
|
||||
"/fixtures"
|
||||
)
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
assert len(soup.findAll('textarea', {'name': 'sql'}))
|
||||
|
|
@ -532,7 +532,7 @@ def test_allow_sql_off():
|
|||
'allow_sql': False,
|
||||
}):
|
||||
response = client.get(
|
||||
"/test_tables"
|
||||
"/fixtures"
|
||||
)
|
||||
soup = Soup(response.body, 'html.parser')
|
||||
assert not len(soup.findAll('textarea', {'name': 'sql'}))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ CREATE TABLE "office" (
|
|||
@pytest.fixture(scope='session')
|
||||
def ds_instance():
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
filepath = os.path.join(tmpdir, 'test_tables.db')
|
||||
filepath = os.path.join(tmpdir, 'fixtures.db')
|
||||
conn = sqlite3.connect(filepath)
|
||||
conn.executescript(TABLES)
|
||||
yield Datasette([filepath])
|
||||
|
|
@ -46,7 +46,7 @@ def ds_instance():
|
|||
|
||||
def test_inspect_hidden_tables(ds_instance):
|
||||
info = ds_instance.inspect()
|
||||
tables = info['test_tables']['tables']
|
||||
tables = info['fixtures']['tables']
|
||||
expected_hidden = (
|
||||
'election_results_fts',
|
||||
'election_results_fts_content',
|
||||
|
|
@ -71,7 +71,7 @@ def test_inspect_hidden_tables(ds_instance):
|
|||
|
||||
def test_inspect_foreign_keys(ds_instance):
|
||||
info = ds_instance.inspect()
|
||||
tables = info['test_tables']['tables']
|
||||
tables = info['fixtures']['tables']
|
||||
for table_name in ('county', 'party', 'office'):
|
||||
assert 0 == tables[table_name]['count']
|
||||
foreign_keys = tables[table_name]['foreign_keys']
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
|
||||
def test_plugins_dir_plugin(app_client):
|
||||
response = app_client.get(
|
||||
"/test_tables.json?sql=select+convert_units(100%2C+'m'%2C+'ft')"
|
||||
"/fixtures.json?sql=select+convert_units(100%2C+'m'%2C+'ft')"
|
||||
)
|
||||
assert pytest.approx(328.0839) == response.json['rows'][0][0]
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ def test_plugin_extra_js_urls(app_client):
|
|||
def test_plugins_with_duplicate_js_urls(app_client):
|
||||
# If two plugins both require jQuery, jQuery should be loaded only once
|
||||
response = app_client.get(
|
||||
"/test_tables"
|
||||
"/fixtures"
|
||||
)
|
||||
# This test is a little tricky, as if the user has any other plugins in
|
||||
# their current virtual environment those may affect what comes back too.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue