mirror of
https://github.com/simonw/datasette.git
synced 2026-05-27 20:36:17 +02:00
Fix test assertions broken by new fixture rows in 170f9de
The render_cell pks parameter commit added rows to compound_primary_key (2->3 rows) and no_primary_key (201->202 rows) tables but did not update existing tests that had hardcoded row count expectations. https://claude.ai/code/session_01XfPSZfK57bzRRiEa7Kz5n1
This commit is contained in:
parent
170f9de774
commit
51e341b06a
3 changed files with 17 additions and 10 deletions
|
|
@ -182,7 +182,7 @@ async def test_database_page(ds_client):
|
|||
# -- compound primary keys
|
||||
compound_pk = tables_by_name["compound_primary_key"]
|
||||
assert compound_pk["primary_keys"] == ["pk1", "pk2"]
|
||||
assert compound_pk["count"] == 2
|
||||
assert compound_pk["count"] == 3
|
||||
|
||||
compound_three = tables_by_name["compound_three_primary_keys"]
|
||||
assert compound_three["primary_keys"] == ["pk1", "pk2", "pk3"]
|
||||
|
|
@ -196,7 +196,7 @@ async def test_database_page(ds_client):
|
|||
# -- no_primary_key: hidden table with generated data
|
||||
no_pk = tables_by_name["no_primary_key"]
|
||||
assert no_pk["hidden"] is True
|
||||
assert no_pk["count"] == 201
|
||||
assert no_pk["count"] == 202
|
||||
assert no_pk["primary_keys"] == []
|
||||
|
||||
# -- roadside attractions relationship chain
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ async def test_table_shape_object_compound_primary_key(ds_client):
|
|||
assert response.json() == {
|
||||
"a,b": {"pk1": "a", "pk2": "b", "content": "c"},
|
||||
"a~2Fb,~2Ec-d": {"pk1": "a/b", "pk2": ".c-d", "content": "c"},
|
||||
"d,e": {"pk1": "d", "pk2": "e", "content": "RENDER_CELL_DEMO"},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -169,11 +170,11 @@ async def test_table_with_reserved_word_name(ds_client):
|
|||
@pytest.mark.parametrize(
|
||||
"path,expected_rows,expected_pages",
|
||||
[
|
||||
("/fixtures/no_primary_key.json", 201, 5),
|
||||
("/fixtures/paginated_view.json", 201, 9),
|
||||
("/fixtures/no_primary_key.json?_size=25", 201, 9),
|
||||
("/fixtures/paginated_view.json?_size=50", 201, 5),
|
||||
("/fixtures/paginated_view.json?_size=max", 201, 3),
|
||||
("/fixtures/no_primary_key.json", 202, 5),
|
||||
("/fixtures/paginated_view.json", 202, 9),
|
||||
("/fixtures/no_primary_key.json?_size=25", 202, 9),
|
||||
("/fixtures/paginated_view.json?_size=50", 202, 5),
|
||||
("/fixtures/paginated_view.json?_size=max", 202, 3),
|
||||
("/fixtures/123_starts_with_digits.json", 0, 1),
|
||||
# Ensure faceting doesn't break pagination:
|
||||
("/fixtures/compound_three_primary_keys.json?_facet=pk1", 1001, 21),
|
||||
|
|
@ -232,7 +233,7 @@ async def test_page_size_zero(ds_client):
|
|||
)
|
||||
assert response.status_code == 200
|
||||
assert [] == response.json()["rows"]
|
||||
assert 201 == response.json()["count"]
|
||||
assert 202 == response.json()["count"]
|
||||
assert None is response.json()["next"]
|
||||
assert None is response.json()["next_url"]
|
||||
|
||||
|
|
@ -722,11 +723,11 @@ def test_page_size_matching_max_returned_rows(
|
|||
while path:
|
||||
response = app_client_returned_rows_matches_page_size.get(path)
|
||||
fetched.extend(response.json["rows"])
|
||||
assert len(response.json["rows"]) in (1, 50)
|
||||
assert len(response.json["rows"]) in (2, 50)
|
||||
path = response.json["next_url"]
|
||||
if path:
|
||||
path = path.replace("http://localhost", "")
|
||||
assert len(fetched) == 201
|
||||
assert len(fetched) == 202
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
|
|
@ -597,6 +597,12 @@ async def test_table_html_compound_primary_key(ds_client):
|
|||
'<td class="col-pk2 type-str">.c-d</td>',
|
||||
'<td class="col-content type-str">c</td>',
|
||||
],
|
||||
[
|
||||
'<td class="col-Link type-pk"><a href="/fixtures/compound_primary_key/d,e">d,e</a></td>',
|
||||
'<td class="col-pk1 type-str">d</td>',
|
||||
'<td class="col-pk2 type-str">e</td>',
|
||||
'<td class="col-content type-str">{"row": {"pk1": "d", "pk2": "e", "content": "RENDER_CELL_DEMO"}, "column": "content", "table": "compound_primary_key", "database": "fixtures", "pks": ["pk1", "pk2"], "config": {"depth": "database"}}</td>',
|
||||
],
|
||||
]
|
||||
assert [
|
||||
[str(td) for td in tr.select("td")] for tr in table.select("tbody tr")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue