43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from typing import List
|
|
|
|
from pynyaata.bridge.nyaa import Nyaa
|
|
from pynyaata.types import RemoteFile
|
|
|
|
from pytest import mark
|
|
import requests
|
|
from requests_mock import Mocker
|
|
|
|
|
|
def test_search_url():
|
|
assert (
|
|
Nyaa().search_url()
|
|
== "https://nyaa.si?f=0&c=1_3&q=%28+vf%29%7C%28+vostfr%29%7C%28+multi%29%7C%28+fre%29&s=id&o=desc&p=1"
|
|
)
|
|
|
|
assert (
|
|
Nyaa().search_url("", 2)
|
|
== "https://nyaa.si?f=0&c=1_3&q=%28+vf%29%7C%28+vostfr%29%7C%28+multi%29%7C%28+fre%29&s=id&o=desc&p=2"
|
|
)
|
|
|
|
assert (
|
|
Nyaa().search_url("test", 1)
|
|
== "https://nyaa.si?f=0&c=1_3&q=%28test+vf%29%7C%28test+vostfr%29%7C%28test+multi%29%7C%28test+fre%29&s=size&o=desc&p=1"
|
|
)
|
|
|
|
assert (
|
|
Nyaa().search_url("test", 2)
|
|
== "https://nyaa.si?f=0&c=1_3&q=%28test+vf%29%7C%28test+vostfr%29%7C%28test+multi%29%7C%28test+fre%29&s=size&o=desc&p=2"
|
|
)
|
|
|
|
|
|
@mark.asyncio
|
|
async def test_search(requests_mock: Mocker):
|
|
requests_mock.real_http = True
|
|
requests_mock.get(
|
|
Nyaa().search_url(), text=requests.get("https://nyaa.si/user/Chaussette33").text
|
|
)
|
|
|
|
remotes: List[RemoteFile] = []
|
|
|
|
assert await Nyaa().search() == remotes
|