style cleanup

Even tests must be formatted to please Black...
This commit is contained in:
Hugh Rundle 2021-10-10 12:33:11 +11:00
parent 8ae20928bb
commit 2a78c1221c
2 changed files with 39 additions and 31 deletions

View file

@ -21,32 +21,40 @@ class Group(TestCase):
)
self.badger = models.User.objects.create_user(
"badger", "badger@badger.badger", "badgerword", local=True, localname="badger"
"badger",
"badger@badger.badger",
"badgerword",
local=True,
localname="badger",
)
self.capybara = models.User.objects.create_user(
"capybara", "capybara@capybara.capybara", "capybaraword", local=True, localname="capybara"
"capybara",
"capybara@capybara.capybara",
"capybaraword",
local=True,
localname="capybara",
)
self.public_group = models.Group.objects.create(
name="Public Group",
name="Public Group",
description="Initial description",
user=self.owner_user,
privacy="public"
user=self.owner_user,
privacy="public",
)
self.private_group = models.Group.objects.create(
name="Private Group",
name="Private Group",
description="Top secret",
user=self.owner_user,
privacy="direct"
user=self.owner_user,
privacy="direct",
)
self.followers_only_group = models.Group.objects.create(
name="Followers Group",
name="Followers Group",
description="No strangers",
user=self.owner_user,
privacy="followers"
user=self.owner_user,
privacy="followers",
)
self.followers_list = models.List.objects.create(
@ -54,7 +62,7 @@ class Group(TestCase):
curation="group",
privacy="followers",
group=self.public_group,
user=self.owner_user
user=self.owner_user,
)
self.private_list = models.List.objects.create(
@ -62,18 +70,14 @@ class Group(TestCase):
privacy="direct",
curation="group",
group=self.public_group,
user=self.owner_user
user=self.owner_user,
)
models.GroupMember.objects.create(
group=self.private_group, user=self.badger
)
models.GroupMember.objects.create(group=self.private_group, user=self.badger)
models.GroupMember.objects.create(
group=self.followers_only_group, user=self.badger
)
models.GroupMember.objects.create(
group=self.public_group, user=self.capybara
)
models.GroupMember.objects.create(group=self.public_group, user=self.capybara)
def test_group_members_can_see_followers_only_groups(self, _):
"""follower-only group should not be excluded from group listings for group members viewing"""
@ -103,7 +107,7 @@ class Group(TestCase):
self.assertFalse(self.followers_list in rat_lists)
self.assertFalse(self.followers_list in badger_lists)
self.assertTrue(self.followers_list in capybara_lists)
def test_group_members_can_see_private_lists(self, _):
"""private group booklists should not be excluded from group booklist listing for group members"""

View file

@ -39,10 +39,10 @@ class GroupViews(TestCase):
)
self.testgroup = models.Group.objects.create(
name="Test Group",
name="Test Group",
description="Initial description",
user=self.local_user,
privacy="public"
user=self.local_user,
privacy="public",
)
self.membership = models.GroupMember.objects.create(
group=self.testgroup, user=self.local_user
@ -99,20 +99,24 @@ class GroupViews(TestCase):
new_group = models.Group.objects.filter(name="A group").get()
self.assertEqual(new_group.description, "wowzers")
self.assertEqual(new_group.privacy, "unlisted")
self.assertTrue(models.GroupMember.objects.filter(group=new_group, user=self.local_user).exists())
self.assertTrue(
models.GroupMember.objects.filter(
group=new_group, user=self.local_user
).exists()
)
def test_group_edit(self, _):
"""test editing a "group" database entry"""
view = views.Group.as_view()
request = self.factory.post(
"",
{
"name": "Updated Group name",
"description": "wow",
"privacy": "direct",
"user": self.local_user.id,
}
"",
{
"name": "Updated Group name",
"description": "wow",
"privacy": "direct",
"user": self.local_user.id,
},
)
request.user = self.local_user