kopia lustrzana https://github.com/simonw/datasette
Rename city_id to _city_id in fixtures, refs #1525
rodzic
06762776f7
commit
69244a617b
|
@ -358,7 +358,7 @@ METADATA = {
|
||||||
select _neighborhood, facet_cities.name, state
|
select _neighborhood, facet_cities.name, state
|
||||||
from facetable
|
from facetable
|
||||||
join facet_cities
|
join facet_cities
|
||||||
on facetable.city_id = facet_cities.id
|
on facetable._city_id = facet_cities.id
|
||||||
where _neighborhood like '%' || :text || '%'
|
where _neighborhood like '%' || :text || '%'
|
||||||
order by _neighborhood;
|
order by _neighborhood;
|
||||||
"""
|
"""
|
||||||
|
@ -558,15 +558,15 @@ CREATE TABLE facetable (
|
||||||
planet_int integer,
|
planet_int integer,
|
||||||
on_earth integer,
|
on_earth integer,
|
||||||
state text,
|
state text,
|
||||||
city_id integer,
|
_city_id integer,
|
||||||
_neighborhood text,
|
_neighborhood text,
|
||||||
tags text,
|
tags text,
|
||||||
complex_array text,
|
complex_array text,
|
||||||
distinct_some_null,
|
distinct_some_null,
|
||||||
FOREIGN KEY ("city_id") REFERENCES [facet_cities](id)
|
FOREIGN KEY ("_city_id") REFERENCES [facet_cities](id)
|
||||||
);
|
);
|
||||||
INSERT INTO facetable
|
INSERT INTO facetable
|
||||||
(created, planet_int, on_earth, state, city_id, _neighborhood, tags, complex_array, distinct_some_null)
|
(created, planet_int, on_earth, state, _city_id, _neighborhood, tags, complex_array, distinct_some_null)
|
||||||
VALUES
|
VALUES
|
||||||
("2019-01-14 08:00:00", 1, 1, 'CA', 1, 'Mission', '["tag1", "tag2"]', '[{"foo": "bar"}]', 'one'),
|
("2019-01-14 08:00:00", 1, 1, 'CA', 1, 'Mission', '["tag1", "tag2"]', '[{"foo": "bar"}]', 'one'),
|
||||||
("2019-01-14 08:00:00", 1, 1, 'CA', 1, 'Dogpatch', '["tag1", "tag3"]', '[]', 'two'),
|
("2019-01-14 08:00:00", 1, 1, 'CA', 1, 'Dogpatch', '["tag1", "tag3"]', '[]', 'two'),
|
||||||
|
|
|
@ -197,7 +197,7 @@ def test_database_page(app_client):
|
||||||
{
|
{
|
||||||
"other_table": "facetable",
|
"other_table": "facetable",
|
||||||
"column": "id",
|
"column": "id",
|
||||||
"other_column": "city_id",
|
"other_column": "_city_id",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outgoing": [],
|
"outgoing": [],
|
||||||
|
@ -212,7 +212,7 @@ def test_database_page(app_client):
|
||||||
"planet_int",
|
"planet_int",
|
||||||
"on_earth",
|
"on_earth",
|
||||||
"state",
|
"state",
|
||||||
"city_id",
|
"_city_id",
|
||||||
"_neighborhood",
|
"_neighborhood",
|
||||||
"tags",
|
"tags",
|
||||||
"complex_array",
|
"complex_array",
|
||||||
|
@ -227,7 +227,7 @@ def test_database_page(app_client):
|
||||||
"outgoing": [
|
"outgoing": [
|
||||||
{
|
{
|
||||||
"other_table": "facet_cities",
|
"other_table": "facet_cities",
|
||||||
"column": "city_id",
|
"column": "_city_id",
|
||||||
"other_column": "id",
|
"other_column": "id",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -1512,40 +1512,40 @@ def test_page_size_matching_max_returned_rows(
|
||||||
"path,expected_facet_results",
|
"path,expected_facet_results",
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"/fixtures/facetable.json?_facet=state&_facet=city_id",
|
"/fixtures/facetable.json?_facet=state&_facet=_city_id",
|
||||||
{
|
{
|
||||||
"state": {
|
"state": {
|
||||||
"name": "state",
|
"name": "state",
|
||||||
"hideable": True,
|
"hideable": True,
|
||||||
"type": "column",
|
"type": "column",
|
||||||
"toggle_url": "/fixtures/facetable.json?_facet=city_id",
|
"toggle_url": "/fixtures/facetable.json?_facet=_city_id",
|
||||||
"results": [
|
"results": [
|
||||||
{
|
{
|
||||||
"value": "CA",
|
"value": "CA",
|
||||||
"label": "CA",
|
"label": "CA",
|
||||||
"count": 10,
|
"count": 10,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&state=CA",
|
"toggle_url": "_facet=state&_facet=_city_id&state=CA",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": "MI",
|
"value": "MI",
|
||||||
"label": "MI",
|
"label": "MI",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&state=MI",
|
"toggle_url": "_facet=state&_facet=_city_id&state=MI",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": "MC",
|
"value": "MC",
|
||||||
"label": "MC",
|
"label": "MC",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&state=MC",
|
"toggle_url": "_facet=state&_facet=_city_id&state=MC",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"truncated": False,
|
"truncated": False,
|
||||||
},
|
},
|
||||||
"city_id": {
|
"_city_id": {
|
||||||
"name": "city_id",
|
"name": "_city_id",
|
||||||
"hideable": True,
|
"hideable": True,
|
||||||
"type": "column",
|
"type": "column",
|
||||||
"toggle_url": "/fixtures/facetable.json?_facet=state",
|
"toggle_url": "/fixtures/facetable.json?_facet=state",
|
||||||
|
@ -1554,28 +1554,28 @@ def test_page_size_matching_max_returned_rows(
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"label": "San Francisco",
|
"label": "San Francisco",
|
||||||
"count": 6,
|
"count": 6,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&city_id=1",
|
"toggle_url": "_facet=state&_facet=_city_id&_city_id__exact=1",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 2,
|
"value": 2,
|
||||||
"label": "Los Angeles",
|
"label": "Los Angeles",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&city_id=2",
|
"toggle_url": "_facet=state&_facet=_city_id&_city_id__exact=2",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 3,
|
"value": 3,
|
||||||
"label": "Detroit",
|
"label": "Detroit",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&city_id=3",
|
"toggle_url": "_facet=state&_facet=_city_id&_city_id__exact=3",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 4,
|
"value": 4,
|
||||||
"label": "Memnonia",
|
"label": "Memnonia",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&city_id=4",
|
"toggle_url": "_facet=state&_facet=_city_id&_city_id__exact=4",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -1584,26 +1584,26 @@ def test_page_size_matching_max_returned_rows(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"/fixtures/facetable.json?_facet=state&_facet=city_id&state=MI",
|
"/fixtures/facetable.json?_facet=state&_facet=_city_id&state=MI",
|
||||||
{
|
{
|
||||||
"state": {
|
"state": {
|
||||||
"name": "state",
|
"name": "state",
|
||||||
"hideable": True,
|
"hideable": True,
|
||||||
"type": "column",
|
"type": "column",
|
||||||
"toggle_url": "/fixtures/facetable.json?_facet=city_id&state=MI",
|
"toggle_url": "/fixtures/facetable.json?_facet=_city_id&state=MI",
|
||||||
"results": [
|
"results": [
|
||||||
{
|
{
|
||||||
"value": "MI",
|
"value": "MI",
|
||||||
"label": "MI",
|
"label": "MI",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"selected": True,
|
"selected": True,
|
||||||
"toggle_url": "_facet=state&_facet=city_id",
|
"toggle_url": "_facet=state&_facet=_city_id",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"truncated": False,
|
"truncated": False,
|
||||||
},
|
},
|
||||||
"city_id": {
|
"_city_id": {
|
||||||
"name": "city_id",
|
"name": "_city_id",
|
||||||
"hideable": True,
|
"hideable": True,
|
||||||
"type": "column",
|
"type": "column",
|
||||||
"toggle_url": "/fixtures/facetable.json?_facet=state&state=MI",
|
"toggle_url": "/fixtures/facetable.json?_facet=state&state=MI",
|
||||||
|
@ -1613,7 +1613,7 @@ def test_page_size_matching_max_returned_rows(
|
||||||
"label": "Detroit",
|
"label": "Detroit",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"selected": False,
|
"selected": False,
|
||||||
"toggle_url": "_facet=state&_facet=city_id&state=MI&city_id=3",
|
"toggle_url": "_facet=state&_facet=_city_id&state=MI&_city_id__exact=3",
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"truncated": False,
|
"truncated": False,
|
||||||
|
@ -1699,7 +1699,7 @@ def test_suggested_facets(app_client):
|
||||||
{"name": "planet_int", "querystring": "_facet=planet_int"},
|
{"name": "planet_int", "querystring": "_facet=planet_int"},
|
||||||
{"name": "on_earth", "querystring": "_facet=on_earth"},
|
{"name": "on_earth", "querystring": "_facet=on_earth"},
|
||||||
{"name": "state", "querystring": "_facet=state"},
|
{"name": "state", "querystring": "_facet=state"},
|
||||||
{"name": "city_id", "querystring": "_facet=city_id"},
|
{"name": "_city_id", "querystring": "_facet=_city_id"},
|
||||||
{"name": "_neighborhood", "querystring": "_facet=_neighborhood"},
|
{"name": "_neighborhood", "querystring": "_facet=_neighborhood"},
|
||||||
{"name": "tags", "querystring": "_facet=tags"},
|
{"name": "tags", "querystring": "_facet=tags"},
|
||||||
{"name": "complex_array", "querystring": "_facet=complex_array"},
|
{"name": "complex_array", "querystring": "_facet=complex_array"},
|
||||||
|
@ -1765,7 +1765,7 @@ def test_expand_labels(app_client):
|
||||||
"planet_int": 1,
|
"planet_int": 1,
|
||||||
"on_earth": 1,
|
"on_earth": 1,
|
||||||
"state": "CA",
|
"state": "CA",
|
||||||
"city_id": {"value": 1, "label": "San Francisco"},
|
"_city_id": {"value": 1, "label": "San Francisco"},
|
||||||
"_neighborhood": "Dogpatch",
|
"_neighborhood": "Dogpatch",
|
||||||
"tags": '["tag1", "tag3"]',
|
"tags": '["tag1", "tag3"]',
|
||||||
"complex_array": "[]",
|
"complex_array": "[]",
|
||||||
|
@ -1777,7 +1777,7 @@ def test_expand_labels(app_client):
|
||||||
"planet_int": 1,
|
"planet_int": 1,
|
||||||
"on_earth": 1,
|
"on_earth": 1,
|
||||||
"state": "MI",
|
"state": "MI",
|
||||||
"city_id": {"value": 3, "label": "Detroit"},
|
"_city_id": {"value": 3, "label": "Detroit"},
|
||||||
"_neighborhood": "Corktown",
|
"_neighborhood": "Corktown",
|
||||||
"tags": "[]",
|
"tags": "[]",
|
||||||
"complex_array": "[]",
|
"complex_array": "[]",
|
||||||
|
@ -2128,7 +2128,7 @@ def test_http_options_request(app_client):
|
||||||
"planet_int",
|
"planet_int",
|
||||||
"on_earth",
|
"on_earth",
|
||||||
"state",
|
"state",
|
||||||
"city_id",
|
"_city_id",
|
||||||
"_neighborhood",
|
"_neighborhood",
|
||||||
"tags",
|
"tags",
|
||||||
"complex_array",
|
"complex_array",
|
||||||
|
@ -2155,7 +2155,7 @@ def test_http_options_request(app_client):
|
||||||
"created",
|
"created",
|
||||||
"planet_int",
|
"planet_int",
|
||||||
"on_earth",
|
"on_earth",
|
||||||
"city_id",
|
"_city_id",
|
||||||
"_neighborhood",
|
"_neighborhood",
|
||||||
"tags",
|
"tags",
|
||||||
"complex_array",
|
"complex_array",
|
||||||
|
|
|
@ -23,7 +23,7 @@ async def test_column_facet_suggest(app_client):
|
||||||
{"name": "planet_int", "toggle_url": "http://localhost/?_facet=planet_int"},
|
{"name": "planet_int", "toggle_url": "http://localhost/?_facet=planet_int"},
|
||||||
{"name": "on_earth", "toggle_url": "http://localhost/?_facet=on_earth"},
|
{"name": "on_earth", "toggle_url": "http://localhost/?_facet=on_earth"},
|
||||||
{"name": "state", "toggle_url": "http://localhost/?_facet=state"},
|
{"name": "state", "toggle_url": "http://localhost/?_facet=state"},
|
||||||
{"name": "city_id", "toggle_url": "http://localhost/?_facet=city_id"},
|
{"name": "_city_id", "toggle_url": "http://localhost/?_facet=_city_id"},
|
||||||
{
|
{
|
||||||
"name": "_neighborhood",
|
"name": "_neighborhood",
|
||||||
"toggle_url": "http://localhost/?_facet=_neighborhood",
|
"toggle_url": "http://localhost/?_facet=_neighborhood",
|
||||||
|
@ -56,8 +56,8 @@ async def test_column_facet_suggest_skip_if_already_selected(app_client):
|
||||||
"toggle_url": "http://localhost/?_facet=planet_int&_facet=on_earth&_facet=state",
|
"toggle_url": "http://localhost/?_facet=planet_int&_facet=on_earth&_facet=state",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "city_id",
|
"name": "_city_id",
|
||||||
"toggle_url": "http://localhost/?_facet=planet_int&_facet=on_earth&_facet=city_id",
|
"toggle_url": "http://localhost/?_facet=planet_int&_facet=on_earth&_facet=_city_id",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "_neighborhood",
|
"name": "_neighborhood",
|
||||||
|
@ -82,7 +82,7 @@ async def test_column_facet_suggest_skip_if_enabled_by_metadata(app_client):
|
||||||
database="fixtures",
|
database="fixtures",
|
||||||
sql="select * from facetable",
|
sql="select * from facetable",
|
||||||
table="facetable",
|
table="facetable",
|
||||||
metadata={"facets": ["city_id"]},
|
metadata={"facets": ["_city_id"]},
|
||||||
)
|
)
|
||||||
suggestions = [s["name"] for s in await facet.suggest()]
|
suggestions = [s["name"] for s in await facet.suggest()]
|
||||||
assert [
|
assert [
|
||||||
|
@ -100,7 +100,7 @@ async def test_column_facet_suggest_skip_if_enabled_by_metadata(app_client):
|
||||||
async def test_column_facet_results(app_client):
|
async def test_column_facet_results(app_client):
|
||||||
facet = ColumnFacet(
|
facet = ColumnFacet(
|
||||||
app_client.ds,
|
app_client.ds,
|
||||||
Request.fake("/?_facet=city_id"),
|
Request.fake("/?_facet=_city_id"),
|
||||||
database="fixtures",
|
database="fixtures",
|
||||||
sql="select * from facetable",
|
sql="select * from facetable",
|
||||||
table="facetable",
|
table="facetable",
|
||||||
|
@ -108,8 +108,8 @@ async def test_column_facet_results(app_client):
|
||||||
buckets, timed_out = await facet.facet_results()
|
buckets, timed_out = await facet.facet_results()
|
||||||
assert [] == timed_out
|
assert [] == timed_out
|
||||||
assert {
|
assert {
|
||||||
"city_id": {
|
"_city_id": {
|
||||||
"name": "city_id",
|
"name": "_city_id",
|
||||||
"type": "column",
|
"type": "column",
|
||||||
"hideable": True,
|
"hideable": True,
|
||||||
"toggle_url": "/",
|
"toggle_url": "/",
|
||||||
|
@ -118,28 +118,28 @@ async def test_column_facet_results(app_client):
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"label": "San Francisco",
|
"label": "San Francisco",
|
||||||
"count": 6,
|
"count": 6,
|
||||||
"toggle_url": "http://localhost/?_facet=city_id&city_id=1",
|
"toggle_url": "http://localhost/?_facet=_city_id&_city_id__exact=1",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 2,
|
"value": 2,
|
||||||
"label": "Los Angeles",
|
"label": "Los Angeles",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "http://localhost/?_facet=city_id&city_id=2",
|
"toggle_url": "http://localhost/?_facet=_city_id&_city_id__exact=2",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 3,
|
"value": 3,
|
||||||
"label": "Detroit",
|
"label": "Detroit",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "http://localhost/?_facet=city_id&city_id=3",
|
"toggle_url": "http://localhost/?_facet=_city_id&_city_id__exact=3",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 4,
|
"value": 4,
|
||||||
"label": "Memnonia",
|
"label": "Memnonia",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"toggle_url": "http://localhost/?_facet=city_id&city_id=4",
|
"toggle_url": "http://localhost/?_facet=_city_id&_city_id__exact=4",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -278,13 +278,13 @@ async def test_column_facet_from_metadata_cannot_be_hidden(app_client):
|
||||||
database="fixtures",
|
database="fixtures",
|
||||||
sql="select * from facetable",
|
sql="select * from facetable",
|
||||||
table="facetable",
|
table="facetable",
|
||||||
metadata={"facets": ["city_id"]},
|
metadata={"facets": ["_city_id"]},
|
||||||
)
|
)
|
||||||
buckets, timed_out = await facet.facet_results()
|
buckets, timed_out = await facet.facet_results()
|
||||||
assert [] == timed_out
|
assert [] == timed_out
|
||||||
assert {
|
assert {
|
||||||
"city_id": {
|
"_city_id": {
|
||||||
"name": "city_id",
|
"name": "_city_id",
|
||||||
"type": "column",
|
"type": "column",
|
||||||
"hideable": False,
|
"hideable": False,
|
||||||
"toggle_url": "/",
|
"toggle_url": "/",
|
||||||
|
@ -293,28 +293,28 @@ async def test_column_facet_from_metadata_cannot_be_hidden(app_client):
|
||||||
"value": 1,
|
"value": 1,
|
||||||
"label": "San Francisco",
|
"label": "San Francisco",
|
||||||
"count": 6,
|
"count": 6,
|
||||||
"toggle_url": "http://localhost/?city_id=1",
|
"toggle_url": "http://localhost/?_city_id__exact=1",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 2,
|
"value": 2,
|
||||||
"label": "Los Angeles",
|
"label": "Los Angeles",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "http://localhost/?city_id=2",
|
"toggle_url": "http://localhost/?_city_id__exact=2",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 3,
|
"value": 3,
|
||||||
"label": "Detroit",
|
"label": "Detroit",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
"toggle_url": "http://localhost/?city_id=3",
|
"toggle_url": "http://localhost/?_city_id__exact=3",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"value": 4,
|
"value": 4,
|
||||||
"label": "Memnonia",
|
"label": "Memnonia",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"toggle_url": "http://localhost/?city_id=4",
|
"toggle_url": "http://localhost/?_city_id__exact=4",
|
||||||
"selected": False,
|
"selected": False,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -487,7 +487,7 @@ def test_sort_links(app_client):
|
||||||
|
|
||||||
def test_facet_display(app_client):
|
def test_facet_display(app_client):
|
||||||
response = app_client.get(
|
response = app_client.get(
|
||||||
"/fixtures/facetable?_facet=planet_int&_facet=city_id&_facet=on_earth"
|
"/fixtures/facetable?_facet=planet_int&_facet=_city_id&_facet=on_earth"
|
||||||
)
|
)
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
soup = Soup(response.body, "html.parser")
|
soup = Soup(response.body, "html.parser")
|
||||||
|
@ -509,26 +509,26 @@ def test_facet_display(app_client):
|
||||||
)
|
)
|
||||||
assert actual == [
|
assert actual == [
|
||||||
{
|
{
|
||||||
"name": "city_id",
|
"name": "_city_id",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"name": "San Francisco",
|
"name": "San Francisco",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&city_id=1",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&_city_id__exact=1",
|
||||||
"count": 6,
|
"count": 6,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Los Angeles",
|
"name": "Los Angeles",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&city_id=2",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&_city_id__exact=2",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Detroit",
|
"name": "Detroit",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&city_id=3",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&_city_id__exact=3",
|
||||||
"count": 4,
|
"count": 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Memnonia",
|
"name": "Memnonia",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&city_id=4",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&_city_id__exact=4",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -538,12 +538,12 @@ def test_facet_display(app_client):
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"name": "1",
|
"name": "1",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&planet_int=1",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&planet_int=1",
|
||||||
"count": 14,
|
"count": 14,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "2",
|
"name": "2",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&planet_int=2",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&planet_int=2",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -553,12 +553,12 @@ def test_facet_display(app_client):
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"name": "1",
|
"name": "1",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&on_earth=1",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&on_earth=1",
|
||||||
"count": 14,
|
"count": 14,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "0",
|
"name": "0",
|
||||||
"qs": "_facet=planet_int&_facet=city_id&_facet=on_earth&on_earth=0",
|
"qs": "_facet=planet_int&_facet=_city_id&_facet=on_earth&on_earth=0",
|
||||||
"count": 1,
|
"count": 1,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -568,14 +568,14 @@ def test_facet_display(app_client):
|
||||||
|
|
||||||
def test_facets_persist_through_filter_form(app_client):
|
def test_facets_persist_through_filter_form(app_client):
|
||||||
response = app_client.get(
|
response = app_client.get(
|
||||||
"/fixtures/facetable?_facet=planet_int&_facet=city_id&_facet_array=tags"
|
"/fixtures/facetable?_facet=planet_int&_facet=_city_id&_facet_array=tags"
|
||||||
)
|
)
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
inputs = Soup(response.body, "html.parser").find("form").findAll("input")
|
inputs = Soup(response.body, "html.parser").find("form").findAll("input")
|
||||||
hiddens = [i for i in inputs if i["type"] == "hidden"]
|
hiddens = [i for i in inputs if i["type"] == "hidden"]
|
||||||
assert [(hidden["name"], hidden["value"]) for hidden in hiddens] == [
|
assert [(hidden["name"], hidden["value"]) for hidden in hiddens] == [
|
||||||
("_facet", "planet_int"),
|
("_facet", "planet_int"),
|
||||||
("_facet", "city_id"),
|
("_facet", "_city_id"),
|
||||||
("_facet_array", "tags"),
|
("_facet_array", "tags"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1350,20 +1350,20 @@ def test_canned_query_show_hide_metadata_option(
|
||||||
|
|
||||||
def test_extra_where_clauses(app_client):
|
def test_extra_where_clauses(app_client):
|
||||||
response = app_client.get(
|
response = app_client.get(
|
||||||
"/fixtures/facetable?_where=_neighborhood='Dogpatch'&_where=city_id=1"
|
"/fixtures/facetable?_where=_neighborhood='Dogpatch'&_where=_city_id=1"
|
||||||
)
|
)
|
||||||
soup = Soup(response.body, "html.parser")
|
soup = Soup(response.body, "html.parser")
|
||||||
div = soup.select(".extra-wheres")[0]
|
div = soup.select(".extra-wheres")[0]
|
||||||
assert "2 extra where clauses" == div.find("h3").text
|
assert "2 extra where clauses" == div.find("h3").text
|
||||||
hrefs = [a["href"] for a in div.findAll("a")]
|
hrefs = [a["href"] for a in div.findAll("a")]
|
||||||
assert [
|
assert [
|
||||||
"/fixtures/facetable?_where=city_id%3D1",
|
"/fixtures/facetable?_where=_city_id%3D1",
|
||||||
"/fixtures/facetable?_where=_neighborhood%3D%27Dogpatch%27",
|
"/fixtures/facetable?_where=_neighborhood%3D%27Dogpatch%27",
|
||||||
] == hrefs
|
] == hrefs
|
||||||
# These should also be persisted as hidden fields
|
# These should also be persisted as hidden fields
|
||||||
inputs = soup.find("form").findAll("input")
|
inputs = soup.find("form").findAll("input")
|
||||||
hiddens = [i for i in inputs if i["type"] == "hidden"]
|
hiddens = [i for i in inputs if i["type"] == "hidden"]
|
||||||
assert [("_where", "_neighborhood='Dogpatch'"), ("_where", "city_id=1")] == [
|
assert [("_where", "_neighborhood='Dogpatch'"), ("_where", "_city_id=1")] == [
|
||||||
(hidden["name"], hidden["value"]) for hidden in hiddens
|
(hidden["name"], hidden["value"]) for hidden in hiddens
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1683,11 +1683,11 @@ def test_base_url_affects_metadata_extra_css_urls(app_client_base_url_prefix):
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
"/fixtures/neighborhood_search",
|
"/fixtures/neighborhood_search",
|
||||||
"/fixtures?sql=%0Aselect+_neighborhood%2C+facet_cities.name%2C+state%0Afrom+facetable%0A++++join+facet_cities%0A++++++++on+facetable.city_id+%3D+facet_cities.id%0Awhere+_neighborhood+like+%27%25%27+%7C%7C+%3Atext+%7C%7C+%27%25%27%0Aorder+by+_neighborhood%3B%0A&text=",
|
"/fixtures?sql=%0Aselect+_neighborhood%2C+facet_cities.name%2C+state%0Afrom+facetable%0A++++join+facet_cities%0A++++++++on+facetable._city_id+%3D+facet_cities.id%0Awhere+_neighborhood+like+%27%25%27+%7C%7C+%3Atext+%7C%7C+%27%25%27%0Aorder+by+_neighborhood%3B%0A&text=",
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"/fixtures/neighborhood_search?text=ber",
|
"/fixtures/neighborhood_search?text=ber",
|
||||||
"/fixtures?sql=%0Aselect+_neighborhood%2C+facet_cities.name%2C+state%0Afrom+facetable%0A++++join+facet_cities%0A++++++++on+facetable.city_id+%3D+facet_cities.id%0Awhere+_neighborhood+like+%27%25%27+%7C%7C+%3Atext+%7C%7C+%27%25%27%0Aorder+by+_neighborhood%3B%0A&text=ber",
|
"/fixtures?sql=%0Aselect+_neighborhood%2C+facet_cities.name%2C+state%0Afrom+facetable%0A++++join+facet_cities%0A++++++++on+facetable._city_id+%3D+facet_cities.id%0Awhere+_neighborhood+like+%27%25%27+%7C%7C+%3Atext+%7C%7C+%27%25%27%0Aorder+by+_neighborhood%3B%0A&text=ber",
|
||||||
),
|
),
|
||||||
("/fixtures/pragma_cache_size", None),
|
("/fixtures/pragma_cache_size", None),
|
||||||
(
|
(
|
||||||
|
|
|
@ -81,7 +81,7 @@ async def test_table_exists(db, tables, exists):
|
||||||
"planet_int",
|
"planet_int",
|
||||||
"on_earth",
|
"on_earth",
|
||||||
"state",
|
"state",
|
||||||
"city_id",
|
"_city_id",
|
||||||
"_neighborhood",
|
"_neighborhood",
|
||||||
"tags",
|
"tags",
|
||||||
"complex_array",
|
"complex_array",
|
||||||
|
@ -161,7 +161,7 @@ async def test_table_columns(db, table, expected):
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
cid=5,
|
cid=5,
|
||||||
name="city_id",
|
name="_city_id",
|
||||||
type="integer",
|
type="integer",
|
||||||
notnull=0,
|
notnull=0,
|
||||||
default_value=None,
|
default_value=None,
|
||||||
|
|
|
@ -436,7 +436,7 @@ def test_hook_register_output_renderer_all_parameters(app_client):
|
||||||
"planet_int",
|
"planet_int",
|
||||||
"on_earth",
|
"on_earth",
|
||||||
"state",
|
"state",
|
||||||
"city_id",
|
"_city_id",
|
||||||
"_neighborhood",
|
"_neighborhood",
|
||||||
"tags",
|
"tags",
|
||||||
"complex_array",
|
"complex_array",
|
||||||
|
@ -459,7 +459,7 @@ def test_hook_register_output_renderer_all_parameters(app_client):
|
||||||
"<sqlite3.Row object at 0xXXX>",
|
"<sqlite3.Row object at 0xXXX>",
|
||||||
"<sqlite3.Row object at 0xXXX>",
|
"<sqlite3.Row object at 0xXXX>",
|
||||||
],
|
],
|
||||||
"sql": "select pk, created, planet_int, on_earth, state, city_id, _neighborhood, tags, complex_array, distinct_some_null from facetable order by pk limit 51",
|
"sql": "select pk, created, planet_int, on_earth, state, _city_id, _neighborhood, tags, complex_array, distinct_some_null from facetable order by pk limit 51",
|
||||||
"query_name": None,
|
"query_name": None,
|
||||||
"database": "fixtures",
|
"database": "fixtures",
|
||||||
"table": "facetable",
|
"table": "facetable",
|
||||||
|
@ -525,13 +525,13 @@ def test_hook_register_output_renderer_can_render(app_client):
|
||||||
"planet_int",
|
"planet_int",
|
||||||
"on_earth",
|
"on_earth",
|
||||||
"state",
|
"state",
|
||||||
"city_id",
|
"_city_id",
|
||||||
"_neighborhood",
|
"_neighborhood",
|
||||||
"tags",
|
"tags",
|
||||||
"complex_array",
|
"complex_array",
|
||||||
"distinct_some_null",
|
"distinct_some_null",
|
||||||
],
|
],
|
||||||
"sql": "select pk, created, planet_int, on_earth, state, city_id, _neighborhood, tags, complex_array, distinct_some_null from facetable order by pk limit 51",
|
"sql": "select pk, created, planet_int, on_earth, state, _city_id, _neighborhood, tags, complex_array, distinct_some_null from facetable order by pk limit 51",
|
||||||
"query_name": None,
|
"query_name": None,
|
||||||
"database": "fixtures",
|
"database": "fixtures",
|
||||||
"table": "facetable",
|
"table": "facetable",
|
||||||
|
|
Ładowanie…
Reference in New Issue