Apply code suggestions from @stumpylog

This commit is contained in:
Michael Shamoon 2022-11-28 12:53:20 -08:00
parent 35ca2195fe
commit 93fab8bb95
2 changed files with 2 additions and 18 deletions

View File

@ -735,7 +735,7 @@ class MailAccountSerializer(serializers.ModelSerializer):
class AccountField(serializers.PrimaryKeyRelatedField): class AccountField(serializers.PrimaryKeyRelatedField):
def get_queryset(self): def get_queryset(self):
return MailAccount.objects.all() return MailAccount.objects.all().order_by("-id")
class MailRuleSerializer(serializers.ModelSerializer): class MailRuleSerializer(serializers.ModelSerializer):

View File

@ -2968,15 +2968,11 @@ class TestAPIMailAccounts(APITestCase):
self.assertEqual(response.data["count"], 1) self.assertEqual(response.data["count"], 1)
returned_account1 = response.data["results"][0] returned_account1 = response.data["results"][0]
from pprint import pprint
pprint(returned_account1)
self.assertEqual(returned_account1["name"], account1.name) self.assertEqual(returned_account1["name"], account1.name)
self.assertEqual(returned_account1["username"], account1.username) self.assertEqual(returned_account1["username"], account1.username)
self.assertEqual( self.assertEqual(
returned_account1["password"], returned_account1["password"],
re.sub(".", "*", account1.password), "*" * len(account1.password),
) )
self.assertEqual(returned_account1["imap_server"], account1.imap_server) self.assertEqual(returned_account1["imap_server"], account1.imap_server)
self.assertEqual(returned_account1["imap_port"], account1.imap_port) self.assertEqual(returned_account1["imap_port"], account1.imap_port)
@ -3010,10 +3006,6 @@ class TestAPIMailAccounts(APITestCase):
returned_account1 = MailAccount.objects.get(name="Email1") 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.name, account1["name"])
self.assertEqual(returned_account1.username, account1["username"]) self.assertEqual(returned_account1.username, account1["username"])
self.assertEqual(returned_account1.password, account1["password"]) self.assertEqual(returned_account1.password, account1["password"])
@ -3150,10 +3142,6 @@ class TestAPIMailRules(APITestCase):
self.assertEqual(response.data["count"], 1) self.assertEqual(response.data["count"], 1)
returned_rule1 = response.data["results"][0] returned_rule1 = response.data["results"][0]
from pprint import pprint
pprint(returned_rule1)
self.assertEqual(returned_rule1["name"], rule1.name) self.assertEqual(returned_rule1["name"], rule1.name)
self.assertEqual(returned_rule1["account"], account1.pk) self.assertEqual(returned_rule1["account"], account1.pk)
self.assertEqual(returned_rule1["folder"], rule1.folder) self.assertEqual(returned_rule1["folder"], rule1.folder)
@ -3239,10 +3227,6 @@ class TestAPIMailRules(APITestCase):
self.assertEqual(response.data["count"], 1) self.assertEqual(response.data["count"], 1)
returned_rule1 = response.data["results"][0] returned_rule1 = response.data["results"][0]
from pprint import pprint
pprint(returned_rule1)
self.assertEqual(returned_rule1["name"], rule1["name"]) self.assertEqual(returned_rule1["name"], rule1["name"])
self.assertEqual(returned_rule1["account"], account1.pk) self.assertEqual(returned_rule1["account"], account1.pk)
self.assertEqual(returned_rule1["folder"], rule1["folder"]) self.assertEqual(returned_rule1["folder"], rule1["folder"])