forked from mirrors/bookwyrm
Merge pull request #2074 from bookwyrm-social/pylint-tests-dir
Include test files in pylint
This commit is contained in:
commit
300eea3b94
29 changed files with 56 additions and 33 deletions
2
.github/workflows/pylint.yml
vendored
2
.github/workflows/pylint.yml
vendored
|
@ -24,5 +24,5 @@ jobs:
|
|||
pip install pylint
|
||||
- name: Analysing the code with pylint
|
||||
run: |
|
||||
pylint bookwyrm/ --ignore=migrations,tests --disable=E1101,E1135,E1136,R0903,R0901,R0902,W0707,W0511,W0406,R0401,R0801
|
||||
pylint bookwyrm/ --ignore=migrations --disable=E1101,E1135,E1136,R0903,R0901,R0902,W0707,W0511,W0406,R0401,R0801
|
||||
|
||||
|
|
|
@ -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:])
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
""" import ALL the tests """
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -162,6 +162,7 @@ class ModelFields(TestCase):
|
|||
class TestActivity(ActivityObject):
|
||||
"""real simple mock"""
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
to: List[str]
|
||||
cc: List[str]
|
||||
id: str = "http://hi.com"
|
||||
|
|
|
@ -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"})
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -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"],
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from . import *
|
||||
# pylint: disable=missing-module-docstring
|
||||
from . import * # pylint: disable=import-self
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue