aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/tests
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-09-17 16:24:10 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-09-17 16:24:10 +0200
commit0576b70f921e7bdf9d950ecb8c4202200a61d5f9 (patch)
tree8066b1c5076e0a0b7b9b3288b99c9be95c168a3c /pydis_site/apps/api/tests
parentAdd test cases for `TypeError` fallbacks. (diff)
Make API return infraction list with newest first
The most recent infraction a user has is usually the most relevant to us. This PR aims to make our life easier by sorting the infractions by their `inserted_at` date, with the most recent insertion date first. Note: The `id` is not entirely in chronological order, because we did not import historical infractions in chronological order. That's why the `inserted_at` field is specified instead of the `id` field.
Diffstat (limited to 'pydis_site/apps/api/tests')
-rw-r--r--pydis_site/apps/api/tests/test_infractions.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/pydis_site/apps/api/tests/test_infractions.py b/pydis_site/apps/api/tests/test_infractions.py
index 7c370c17..0092d355 100644
--- a/pydis_site/apps/api/tests/test_infractions.py
+++ b/pydis_site/apps/api/tests/test_infractions.py
@@ -63,6 +63,7 @@ class InfractionTests(APISubdomainTestCase):
)
def test_list_all(self):
+ """Tests the list-view, which should be ordered by inserted_at (newest first)."""
url = reverse('bot:infraction-list', host='api')
response = self.client.get(url)
@@ -70,8 +71,8 @@ class InfractionTests(APISubdomainTestCase):
infractions = response.json()
self.assertEqual(len(infractions), 2)
- self.assertEqual(infractions[0]['id'], self.ban_hidden.id)
- self.assertEqual(infractions[1]['id'], self.ban_inactive.id)
+ self.assertEqual(infractions[0]['id'], self.ban_inactive.id)
+ self.assertEqual(infractions[1]['id'], self.ban_hidden.id)
def test_filter_search(self):
url = reverse('bot:infraction-list', host='api')