diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 11a9cba39..2d1119dfb 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -735,7 +735,7 @@ class MailAccountSerializer(serializers.ModelSerializer): class AccountField(serializers.PrimaryKeyRelatedField): def get_queryset(self): - return MailAccount.objects.all() + return MailAccount.objects.all().order_by("-id") class MailRuleSerializer(serializers.ModelSerializer): diff --git a/src/documents/tests/test_api.py b/src/documents/tests/test_api.py index 2c777f516..bdc729a36 100644 --- a/src/documents/tests/test_api.py +++ b/src/documents/tests/test_api.py @@ -2968,15 +2968,11 @@ class TestAPIMailAccounts(APITestCase): self.assertEqual(response.data["count"], 1) returned_account1 = response.data["results"][0] - from pprint import pprint - - pprint(returned_account1) - self.assertEqual(returned_account1["name"], account1.name) self.assertEqual(returned_account1["username"], account1.username) self.assertEqual( returned_account1["password"], - re.sub(".", "*", account1.password), + "*" * len(account1.password), ) self.assertEqual(returned_account1["imap_server"], account1.imap_server) self.assertEqual(returned_account1["imap_port"], account1.imap_port) @@ -3010,10 +3006,6 @@ class TestAPIMailAccounts(APITestCase): returned_account1 = MailAccount.objects.get(name="Email1") - from pprint import pprint - - pprint(returned_account1) - self.assertEqual(returned_account1.name, account1["name"]) self.assertEqual(returned_account1.username, account1["username"]) self.assertEqual(returned_account1.password, account1["password"]) @@ -3150,10 +3142,6 @@ class TestAPIMailRules(APITestCase): self.assertEqual(response.data["count"], 1) returned_rule1 = response.data["results"][0] - from pprint import pprint - - pprint(returned_rule1) - self.assertEqual(returned_rule1["name"], rule1.name) self.assertEqual(returned_rule1["account"], account1.pk) self.assertEqual(returned_rule1["folder"], rule1.folder) @@ -3239,10 +3227,6 @@ class TestAPIMailRules(APITestCase): self.assertEqual(response.data["count"], 1) returned_rule1 = response.data["results"][0] - from pprint import pprint - - pprint(returned_rule1) - self.assertEqual(returned_rule1["name"], rule1["name"]) self.assertEqual(returned_rule1["account"], account1.pk) self.assertEqual(returned_rule1["folder"], rule1["folder"])