mirror of
https://github.com/FuzzyGrim/Yamtrack.git
synced 2026-06-27 22:35:55 +00:00
fix magic value comparison (PLR2004)
This commit is contained in:
@@ -4,7 +4,7 @@ extend-exclude = ["migrations"]
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["ALL"]
|
||||
ignore = ["ANN", "PT", "D100", "D104", "PLR2004", "RUF012"]
|
||||
ignore = ["ANN", "PT", "D100", "D104", "RUF012"]
|
||||
|
||||
[tool.ruff.lint.pycodestyle]
|
||||
max-doc-length = 88
|
||||
|
||||
@@ -120,16 +120,14 @@ def manga(media_id):
|
||||
|
||||
def get_format(response):
|
||||
"""Return the original type of the media."""
|
||||
# MAL return tv in metadata for anime
|
||||
if response["media_type"] == "tv":
|
||||
response["media_type"] = "anime"
|
||||
media_format = response["media_type"]
|
||||
|
||||
# for light_novel, tv_special, etc
|
||||
formatted = response["media_type"].replace("_", " ")
|
||||
if len(formatted) <= 3:
|
||||
# ona, ova, etc
|
||||
return formatted.upper()
|
||||
return formatted.title()
|
||||
# MAL return tv in metadata for anime
|
||||
if media_format == "tv":
|
||||
return "Anime"
|
||||
if media_format in ("ova", "ona"):
|
||||
return media_format.upper()
|
||||
return media_format.replace("_", " ").title()
|
||||
|
||||
|
||||
def get_image_url(response):
|
||||
|
||||
@@ -16,8 +16,8 @@ def api_request(url, method, headers=None, json=None):
|
||||
elif method == "POST":
|
||||
response = requests.post(url, json=json, timeout=settings.REQUEST_TIMEOUT)
|
||||
|
||||
# rate limit exceeded
|
||||
if response.status_code == 429:
|
||||
rate_limit_code = 429
|
||||
if response.status_code == rate_limit_code:
|
||||
seconds_to_wait = int(response.headers["Retry-After"])
|
||||
time.sleep(seconds_to_wait)
|
||||
return api_request(url, method, json)
|
||||
|
||||
@@ -39,17 +39,16 @@ class ImportMAL(TestCase):
|
||||
self.assertEqual(Anime.objects.filter(user=self.user).count(), 4)
|
||||
self.assertEqual(Manga.objects.filter(user=self.user).count(), 2)
|
||||
self.assertEqual(
|
||||
Anime.objects.get(user=self.user, title="Ama Gli Animali").image
|
||||
== settings.IMG_NONE,
|
||||
True,
|
||||
Anime.objects.get(user=self.user, title="Ama Gli Animali").image,
|
||||
settings.IMG_NONE,
|
||||
)
|
||||
self.assertEqual(
|
||||
Anime.objects.get(user=self.user, title="FLCL").status == "Paused",
|
||||
True,
|
||||
Anime.objects.get(user=self.user, title="FLCL").status,
|
||||
"Paused",
|
||||
)
|
||||
self.assertEqual(
|
||||
Manga.objects.get(user=self.user, title="Fire Punch").score == 7,
|
||||
True,
|
||||
Manga.objects.get(user=self.user, title="Fire Punch").score,
|
||||
7,
|
||||
)
|
||||
|
||||
def test_user_not_found(self):
|
||||
@@ -104,12 +103,12 @@ class ImportAniList(TestCase):
|
||||
self.assertEqual(Anime.objects.filter(user=self.user).count(), 4)
|
||||
self.assertEqual(Manga.objects.filter(user=self.user).count(), 2)
|
||||
self.assertEqual(
|
||||
Anime.objects.get(user=self.user, title="FLCL").status == "Paused",
|
||||
True,
|
||||
Anime.objects.get(user=self.user, title="FLCL").status,
|
||||
"Paused",
|
||||
)
|
||||
self.assertEqual(
|
||||
Manga.objects.get(user=self.user, title="One Punch-Man").score == 9,
|
||||
True,
|
||||
Manga.objects.get(user=self.user, title="One Punch-Man").score,
|
||||
9,
|
||||
)
|
||||
|
||||
def test_user_not_found(self):
|
||||
|
||||
Reference in New Issue
Block a user