Fixed incorrect display of compound primary keys with foreign key references

Closes #319
This commit is contained in:
Simon Willison 2018-06-21 07:56:28 -07:00
commit 3b53eea382
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 122 additions and 10 deletions

View file

@ -550,6 +550,26 @@ def test_row_html_compound_primary_key(app_client):
assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
def test_compound_primary_key_with_foreign_key_references(app_client):
# e.g. a many-to-many table with a compound primary key on the two columns
response = app_client.get('/fixtures/searchable_tags')
assert response.status == 200
table = Soup(response.body, 'html.parser').find('table')
expected = [
[
'<td class="col-Link"><a href="/fixtures/searchable_tags/1,feline">1,feline</a></td>',
'<td class="col-searchable_id"><a href="/fixtures/searchable/1">1</a>\xa0<em>1</em></td>',
'<td class="col-tag"><a href="/fixtures/tags/feline">feline</a></td>',
],
[
'<td class="col-Link"><a href="/fixtures/searchable_tags/2,canine">2,canine</a></td>',
'<td class="col-searchable_id"><a href="/fixtures/searchable/2">2</a>\xa0<em>2</em></td>',
'<td class="col-tag"><a href="/fixtures/tags/canine">canine</a></td>',
],
]
assert expected == [[str(td) for td in tr.select('td')] for tr in table.select('tbody tr')]
def test_view_html(app_client):
response = app_client.get('/fixtures/simple_view')
assert response.status == 200