Various pylint complaince fixes

This commit is contained in:
Mouse Reeve 2022-04-08 14:23:37 -07:00
parent a92bf785dd
commit 9921a1e754
10 changed files with 19 additions and 15 deletions

View file

@ -125,7 +125,7 @@ class ActivitypubFieldMixin:
"""model_field_name to activitypubFieldName"""
if self.activitypub_field:
return self.activitypub_field
name = self.name.split(".")[-1]
name = self.name.rsplit(".", maxsplit=1)[-1]
components = name.split("_")
return components[0] + "".join(x.title() for x in components[1:])

View file

@ -4,7 +4,10 @@ from bookwyrm import models
class Author(TestCase):
""" serialize author tests """
def setUp(self):
""" initial data """
self.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
@ -16,6 +19,7 @@ class Author(TestCase):
)
def test_serialize_model(self):
""" check presense of author fields """
activity = self.author.to_activity()
self.assertEqual(activity["id"], self.author.remote_id)
self.assertIsInstance(activity["aliases"], list)

View file

@ -38,7 +38,7 @@ class BaseModel(TestCase):
def test_remote_id(self):
"""these should be generated"""
self.test_model.id = 1
self.test_model.id = 1 # pylint: disable=invalid-name
expected = self.test_model.get_remote_id()
self.assertEqual(expected, f"https://{DOMAIN}/bookwyrmtestmodel/1")

View file

@ -161,7 +161,7 @@ class ModelFields(TestCase):
@dataclass(init=False)
class TestActivity(ActivityObject):
"""real simple mock"""
# pylint: disbale=invalid-name
to: List[str]
cc: List[str]
id: str = "http://hi.com"

View file

@ -17,7 +17,7 @@ class User(TestCase):
"bookwyrm.activitystreams.populate_stream_task.delay"
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.user = models.User.objects.create_user(
"mouse@%s" % DOMAIN,
f"mouse@{DOMAIN}",
"mouse@mouse.mouse",
"mouseword",
local=True,
@ -107,7 +107,7 @@ class User(TestCase):
def test_get_or_create_remote_server(self):
responses.add(
responses.GET,
"https://%s/.well-known/nodeinfo" % DOMAIN,
f"https://{DOMAIN}/.well-known/nodeinfo",
json={"links": [{"href": "http://www.example.com"}, {}]},
)
responses.add(
@ -124,7 +124,7 @@ class User(TestCase):
@responses.activate
def test_get_or_create_remote_server_no_wellknown(self):
responses.add(
responses.GET, "https://%s/.well-known/nodeinfo" % DOMAIN, status=404
responses.GET, f"https://{DOMAIN}/.well-known/nodeinfo", status=404
)
server = models.user.get_or_create_remote_server(DOMAIN)
@ -136,7 +136,7 @@ class User(TestCase):
def test_get_or_create_remote_server_no_links(self):
responses.add(
responses.GET,
"https://%s/.well-known/nodeinfo" % DOMAIN,
f"https://{DOMAIN}/.well-known/nodeinfo",
json={"links": [{"href": "http://www.example.com"}, {}]},
)
responses.add(responses.GET, "http://www.example.com", status=404)
@ -150,7 +150,7 @@ class User(TestCase):
def test_get_or_create_remote_server_unknown_format(self):
responses.add(
responses.GET,
"https://%s/.well-known/nodeinfo" % DOMAIN,
f"https://{DOMAIN}/.well-known/nodeinfo",
json={"links": [{"href": "http://www.example.com"}, {}]},
)
responses.add(responses.GET, "http://www.example.com", json={"fish": "salmon"})

View file

@ -64,8 +64,8 @@ class Signature(TestCase):
def send(self, signature, now, data, digest):
"""test request"""
c = Client()
return c.post(
client = Client()
return client.post(
urlsplit(self.rat.inbox).path,
data=data,
content_type="application/json",

View file

@ -61,7 +61,7 @@ class InboxActivities(TestCase):
self.assertEqual(models.Notification.objects.count(), 0)
activity = {
"type": "Announce",
"id": "%s/boost" % self.status.remote_id,
"id": f"{self.status.remote_id}/boost",
"actor": self.remote_user.remote_id,
"object": self.status.remote_id,
"to": ["https://www.w3.org/ns/activitystreams#public"],
@ -94,7 +94,7 @@ class InboxActivities(TestCase):
self.assertEqual(models.Notification.objects.count(), 0)
activity = {
"type": "Announce",
"id": "%s/boost" % self.status.remote_id,
"id": f"{self.status.remote_id}/boost",
"actor": self.remote_user.remote_id,
"object": "https://remote.com/status/1",
"to": ["https://www.w3.org/ns/activitystreams#public"],

View file

@ -66,7 +66,7 @@ class AuthorViews(TestCase):
def test_author_page_edition_author(self):
"""there are so many views, this just makes sure it LOADS"""
view = views.Author.as_view()
another_book = models.Edition.objects.create(
models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=self.work,

View file

@ -139,7 +139,7 @@ class ViewsHelpers(TestCase):
}
responses.add(
responses.GET,
"https://example.com/.well-known/webfinger?resource=acct:%s" % username,
f"https://example.com/.well-known/webfinger?resource=acct:{username}",
json=wellknown,
status=200,
)

View file

@ -83,7 +83,7 @@ class UserViews(TestCase):
def test_user_page_domain(self):
"""when the user domain has dashes in it"""
with patch("bookwyrm.models.user.set_remote_server"):
self.remote_user = models.User.objects.create_user(
models.User.objects.create_user(
"nutria",
"",
"nutriaword",