Skip to content

Commit

Permalink
Return feed items in correct order, fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 30, 2019
1 parent 6b43f0d commit 239503b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datasette_atom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def render_atom(args, data, view_name):
title += ": " + data["human_description_en"]
fg.title(title)
# And the rows
for row in data["rows"]:
for row in reversed(data["rows"]):
entry = fg.add_entry()
entry.id(row["atom_id"])
entry.content(row["atom_content"], type="text")
Expand Down
20 changes: 18 additions & 2 deletions tests/test_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,33 @@
EXPECTED_ATOM = """
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
<id>:memory:/fb1e7a9ccb71dcf0e87071fab748b133bb1f7f5e43a1f5ac8a6dff99caf11cac</id>
<id>:memory:/051e4d600fc8678005e17f13e1b4065a14833423d0da19f4f34aaeab87822cd4</id>
<title>
select
'atom-id' as atom_id,
'title' as atom_title,
'2019-10-23T21:32:12-07:00' as atom_updated,
'blah' as atom_content
union select
'atom-id-2' as atom_id,
'title 2' as atom_title,
'2019-09-23T21:32:12-07:00' as atom_updated,
'blah' as atom_content;
</title>
<updated>2019-10-23T21:32:12-07:00</updated>
<generator uri="https://github.com/simonw/datasette" version="{version}">Datasette</generator>
<generator uri="https://github.com/simonw/datasette" version="0.32">Datasette</generator>
<entry>
<id>atom-id</id>
<title>title</title>
<updated>2019-10-23T21:32:12-07:00</updated>
<content type="text">blah</content>
</entry>
<entry>
<id>atom-id-2</id>
<title>title 2</title>
<updated>2019-09-23T21:32:12-07:00</updated>
<content type="text">blah</content>
</entry>
</feed>
""".strip()

Expand Down Expand Up @@ -62,6 +73,11 @@ def test_atom_for_valid_query():
'atom-id' as atom_id,
'title' as atom_title,
'2019-10-23T21:32:12-07:00' as atom_updated,
'blah' as atom_content
union select
'atom-id-2' as atom_id,
'title 2' as atom_title,
'2019-09-23T21:32:12-07:00' as atom_updated,
'blah' as atom_content;
"""
app = make_app_client()
Expand Down

0 comments on commit 239503b

Please sign in to comment.