This repository has been archived on 2023-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
PyNyaaTa/tests/filters_test.py
2023-01-06 18:19:59 +01:00

44 lines
999 B
Python

from pydantic_factories import ModelFactory
from pynyaata.filters import blacklist, danger, duplicate, inactive
from pynyaata.types import Color, RemoteFile
from pytest import MonkeyPatch
class RemoteFileFactory(ModelFactory[RemoteFile]):
__model__ = RemoteFile
color = Color.DEFAULT
def test_blacklist(monkeypatch: MonkeyPatch):
monkeypatch.setenv("BLACKLIST_WORDS", "one,two")
remotes = RemoteFileFactory.batch(10)
remotes[0].name = "oui one non"
remotes[1].name = "non two oui"
assert len(blacklist(remotes)) == 8
def test_danger():
remotes = RemoteFileFactory.batch(10)
remotes[0].color = Color.DANGER
assert len(danger(remotes)) == 9
def test_duplicate():
remotes = RemoteFileFactory.batch(10)
remotes[0].id = 1
remotes[1].id = 1
assert len(duplicate(remotes)) == 9
def test_inactive():
remotes = RemoteFileFactory.batch(10)
remotes[0].seeds = 0
remotes[0].downloads = 0
assert len(inactive(remotes)) == 9