Skip to content

Commit 1790db6

Browse files
committed
Fix tests for tags generation
1 parent ad03148 commit 1790db6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

leetcode_anki/helpers/leetcode.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class LeetcodeData:
8383
names.
8484
"""
8585

86-
def __init__(self, start: int, stop: int, page_size: int = 1000, list_id: str = "") -> None:
86+
def __init__(
87+
self, start: int, stop: int, page_size: int = 1000, list_id: str = ""
88+
) -> None:
8789
"""
8890
Initialize leetcode API and disk cache for API responses
8991
"""
@@ -354,7 +356,7 @@ async def tags(self, problem_slug: str) -> List[str]:
354356
"""
355357
data = self._get_problem_data(problem_slug)
356358
tags = list(map(lambda x: x.slug, data.topic_tags))
357-
tags.append(data.difficulty)
359+
tags.append(f"difficulty-{data.difficulty.lower()}-tag")
358360
return tags
359361

360362
async def freq_bar(self, problem_slug: str) -> float:

test/helpers/test_leetcode.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ async def test_dislikes(self) -> None:
245245
async def test_tags(self) -> None:
246246
self._leetcode_data._cache["test"] = QUESTION_DETAIL
247247

248-
assert (await self._leetcode_data.tags("test")) == ["test-tag"]
248+
assert (await self._leetcode_data.tags("test")) == [
249+
"test-tag",
250+
"difficulty-hard-tag",
251+
]
249252

250253
@pytest.mark.asyncio
251254
@mock.patch(

0 commit comments

Comments
 (0)