mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 10:01:04 +00:00
Various pylint complaince fixes
This commit is contained in:
parent
a92bf785dd
commit
9921a1e754
10 changed files with 19 additions and 15 deletions
|
@ -125,7 +125,7 @@ class ActivitypubFieldMixin:
|
||||||
"""model_field_name to activitypubFieldName"""
|
"""model_field_name to activitypubFieldName"""
|
||||||
if self.activitypub_field:
|
if self.activitypub_field:
|
||||||
return self.activitypub_field
|
return self.activitypub_field
|
||||||
name = self.name.split(".")[-1]
|
name = self.name.rsplit(".", maxsplit=1)[-1]
|
||||||
components = name.split("_")
|
components = name.split("_")
|
||||||
return components[0] + "".join(x.title() for x in components[1:])
|
return components[0] + "".join(x.title() for x in components[1:])
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@ from bookwyrm import models
|
||||||
|
|
||||||
|
|
||||||
class Author(TestCase):
|
class Author(TestCase):
|
||||||
|
""" serialize author tests """
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
""" initial data """
|
||||||
self.book = models.Edition.objects.create(
|
self.book = models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
|
@ -16,6 +19,7 @@ class Author(TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_serialize_model(self):
|
def test_serialize_model(self):
|
||||||
|
""" check presense of author fields """
|
||||||
activity = self.author.to_activity()
|
activity = self.author.to_activity()
|
||||||
self.assertEqual(activity["id"], self.author.remote_id)
|
self.assertEqual(activity["id"], self.author.remote_id)
|
||||||
self.assertIsInstance(activity["aliases"], list)
|
self.assertIsInstance(activity["aliases"], list)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class BaseModel(TestCase):
|
||||||
|
|
||||||
def test_remote_id(self):
|
def test_remote_id(self):
|
||||||
"""these should be generated"""
|
"""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()
|
expected = self.test_model.get_remote_id()
|
||||||
self.assertEqual(expected, f"https://{DOMAIN}/bookwyrmtestmodel/1")
|
self.assertEqual(expected, f"https://{DOMAIN}/bookwyrmtestmodel/1")
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ class ModelFields(TestCase):
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class TestActivity(ActivityObject):
|
class TestActivity(ActivityObject):
|
||||||
"""real simple mock"""
|
"""real simple mock"""
|
||||||
|
# pylint: disbale=invalid-name
|
||||||
to: List[str]
|
to: List[str]
|
||||||
cc: List[str]
|
cc: List[str]
|
||||||
id: str = "http://hi.com"
|
id: str = "http://hi.com"
|
||||||
|
|
|
@ -17,7 +17,7 @@ class User(TestCase):
|
||||||
"bookwyrm.activitystreams.populate_stream_task.delay"
|
"bookwyrm.activitystreams.populate_stream_task.delay"
|
||||||
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
|
||||||
self.user = models.User.objects.create_user(
|
self.user = models.User.objects.create_user(
|
||||||
"mouse@%s" % DOMAIN,
|
f"mouse@{DOMAIN}",
|
||||||
"mouse@mouse.mouse",
|
"mouse@mouse.mouse",
|
||||||
"mouseword",
|
"mouseword",
|
||||||
local=True,
|
local=True,
|
||||||
|
@ -107,7 +107,7 @@ class User(TestCase):
|
||||||
def test_get_or_create_remote_server(self):
|
def test_get_or_create_remote_server(self):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET,
|
responses.GET,
|
||||||
"https://%s/.well-known/nodeinfo" % DOMAIN,
|
f"https://{DOMAIN}/.well-known/nodeinfo",
|
||||||
json={"links": [{"href": "http://www.example.com"}, {}]},
|
json={"links": [{"href": "http://www.example.com"}, {}]},
|
||||||
)
|
)
|
||||||
responses.add(
|
responses.add(
|
||||||
|
@ -124,7 +124,7 @@ class User(TestCase):
|
||||||
@responses.activate
|
@responses.activate
|
||||||
def test_get_or_create_remote_server_no_wellknown(self):
|
def test_get_or_create_remote_server_no_wellknown(self):
|
||||||
responses.add(
|
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)
|
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):
|
def test_get_or_create_remote_server_no_links(self):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET,
|
responses.GET,
|
||||||
"https://%s/.well-known/nodeinfo" % DOMAIN,
|
f"https://{DOMAIN}/.well-known/nodeinfo",
|
||||||
json={"links": [{"href": "http://www.example.com"}, {}]},
|
json={"links": [{"href": "http://www.example.com"}, {}]},
|
||||||
)
|
)
|
||||||
responses.add(responses.GET, "http://www.example.com", status=404)
|
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):
|
def test_get_or_create_remote_server_unknown_format(self):
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET,
|
responses.GET,
|
||||||
"https://%s/.well-known/nodeinfo" % DOMAIN,
|
f"https://{DOMAIN}/.well-known/nodeinfo",
|
||||||
json={"links": [{"href": "http://www.example.com"}, {}]},
|
json={"links": [{"href": "http://www.example.com"}, {}]},
|
||||||
)
|
)
|
||||||
responses.add(responses.GET, "http://www.example.com", json={"fish": "salmon"})
|
responses.add(responses.GET, "http://www.example.com", json={"fish": "salmon"})
|
||||||
|
|
|
@ -64,8 +64,8 @@ class Signature(TestCase):
|
||||||
|
|
||||||
def send(self, signature, now, data, digest):
|
def send(self, signature, now, data, digest):
|
||||||
"""test request"""
|
"""test request"""
|
||||||
c = Client()
|
client = Client()
|
||||||
return c.post(
|
return client.post(
|
||||||
urlsplit(self.rat.inbox).path,
|
urlsplit(self.rat.inbox).path,
|
||||||
data=data,
|
data=data,
|
||||||
content_type="application/json",
|
content_type="application/json",
|
||||||
|
|
|
@ -61,7 +61,7 @@ class InboxActivities(TestCase):
|
||||||
self.assertEqual(models.Notification.objects.count(), 0)
|
self.assertEqual(models.Notification.objects.count(), 0)
|
||||||
activity = {
|
activity = {
|
||||||
"type": "Announce",
|
"type": "Announce",
|
||||||
"id": "%s/boost" % self.status.remote_id,
|
"id": f"{self.status.remote_id}/boost",
|
||||||
"actor": self.remote_user.remote_id,
|
"actor": self.remote_user.remote_id,
|
||||||
"object": self.status.remote_id,
|
"object": self.status.remote_id,
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
||||||
|
@ -94,7 +94,7 @@ class InboxActivities(TestCase):
|
||||||
self.assertEqual(models.Notification.objects.count(), 0)
|
self.assertEqual(models.Notification.objects.count(), 0)
|
||||||
activity = {
|
activity = {
|
||||||
"type": "Announce",
|
"type": "Announce",
|
||||||
"id": "%s/boost" % self.status.remote_id,
|
"id": f"{self.status.remote_id}/boost",
|
||||||
"actor": self.remote_user.remote_id,
|
"actor": self.remote_user.remote_id,
|
||||||
"object": "https://remote.com/status/1",
|
"object": "https://remote.com/status/1",
|
||||||
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
"to": ["https://www.w3.org/ns/activitystreams#public"],
|
||||||
|
|
|
@ -66,7 +66,7 @@ class AuthorViews(TestCase):
|
||||||
def test_author_page_edition_author(self):
|
def test_author_page_edition_author(self):
|
||||||
"""there are so many views, this just makes sure it LOADS"""
|
"""there are so many views, this just makes sure it LOADS"""
|
||||||
view = views.Author.as_view()
|
view = views.Author.as_view()
|
||||||
another_book = models.Edition.objects.create(
|
models.Edition.objects.create(
|
||||||
title="Example Edition",
|
title="Example Edition",
|
||||||
remote_id="https://example.com/book/1",
|
remote_id="https://example.com/book/1",
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
|
|
|
@ -139,7 +139,7 @@ class ViewsHelpers(TestCase):
|
||||||
}
|
}
|
||||||
responses.add(
|
responses.add(
|
||||||
responses.GET,
|
responses.GET,
|
||||||
"https://example.com/.well-known/webfinger?resource=acct:%s" % username,
|
f"https://example.com/.well-known/webfinger?resource=acct:{username}",
|
||||||
json=wellknown,
|
json=wellknown,
|
||||||
status=200,
|
status=200,
|
||||||
)
|
)
|
||||||
|
|
|
@ -83,7 +83,7 @@ class UserViews(TestCase):
|
||||||
def test_user_page_domain(self):
|
def test_user_page_domain(self):
|
||||||
"""when the user domain has dashes in it"""
|
"""when the user domain has dashes in it"""
|
||||||
with patch("bookwyrm.models.user.set_remote_server"):
|
with patch("bookwyrm.models.user.set_remote_server"):
|
||||||
self.remote_user = models.User.objects.create_user(
|
models.User.objects.create_user(
|
||||||
"nutria",
|
"nutria",
|
||||||
"",
|
"",
|
||||||
"nutriaword",
|
"nutriaword",
|
||||||
|
|
Loading…
Reference in a new issue