2023-01-13 20:32:58 +00:00
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
2023-06-04 15:53:29 +00:00
|
|
|
from pynyaata2.bridge.animeultime import AnimeUltime
|
|
|
|
from pynyaata2.types import RemoteFile
|
2023-01-13 20:32:58 +00:00
|
|
|
|
|
|
|
from pytest import mark
|
2023-01-13 22:11:55 +00:00
|
|
|
import requests
|
|
|
|
from requests_mock import Mocker
|
2023-01-13 20:32:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_search_url():
|
|
|
|
previous_month = datetime.now() - timedelta(days=30)
|
|
|
|
|
|
|
|
assert (
|
|
|
|
AnimeUltime().search_url()
|
|
|
|
== f"http://www.anime-ultime.net/history-0-1/{datetime.now().strftime('%m%Y')}"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
|
|
|
AnimeUltime().search_url("", 2)
|
|
|
|
== f"http://www.anime-ultime.net/history-0-1/{previous_month.strftime('%m%Y')}"
|
|
|
|
)
|
|
|
|
|
2023-01-13 22:11:55 +00:00
|
|
|
assert AnimeUltime().search_url("test") == "http://www.anime-ultime.net/search-0-1/"
|
2023-01-13 20:32:58 +00:00
|
|
|
|
|
|
|
assert (
|
|
|
|
AnimeUltime().search_url("test", 2) == "http://www.anime-ultime.net/search-0-1/"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@mark.asyncio
|
|
|
|
async def test_search():
|
2023-01-13 22:11:55 +00:00
|
|
|
assert await AnimeUltime().search("test") == [
|
2023-01-13 20:32:58 +00:00
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=4631,
|
|
|
|
category="OAV",
|
|
|
|
name="Akuma no Riddle: Shousha wa Dare? Nukiuchi Test",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/4631-Akuma-no-Riddle-Shousha-wa-Dare-Nukiuchi-Test",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=4250,
|
|
|
|
category="OAV",
|
|
|
|
name="Baka to Test to shoukanjuu (spécial Noël)",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/4250-Baka-to-Test-to-shoukanjuu-special-Noel",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=3057,
|
|
|
|
category="OAV",
|
|
|
|
name="Baka to Test to shoukanjuu (spéciaux)",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/3057-Baka-to-Test-to-shoukanjuu-speciaux",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=5453,
|
|
|
|
category="OAV",
|
|
|
|
name="Baka to Test to Shoukanjuu Mini Anime",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/5453-Baka-to-Test-to-Shoukanjuu-Mini-Anime",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=2458,
|
|
|
|
category="Episode",
|
|
|
|
name="Baka to Test to shoukanjuu ni! [Saison 2]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/2458-Baka-to-Test-to-shoukanjuu-ni-Saison-2",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=1887,
|
|
|
|
category="Episode",
|
|
|
|
name="Baka to Test to shoukanjuu [Saison 1]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/1887-Baka-to-Test-to-shoukanjuu-Saison-1",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=2320,
|
|
|
|
category="OAV",
|
|
|
|
name="Baka to Test to Shoukanjuu: Matsuri",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/2320-Baka-to-Test-to-Shoukanjuu-Matsuri",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=4463,
|
|
|
|
category="OAV",
|
|
|
|
name="Baka to Test to Shoukanjuu: Spinout! Sore ga Bokura no Nichijou",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/4463-Baka-to-Test-to-Shoukanjuu-Spinout-Sore-ga-Bokura-no-Nichijou",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=5069,
|
|
|
|
category="OAV",
|
|
|
|
name="Shinmai Maou no Testament Burst OAV [Interdit -16 ans]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/5069-Shinmai-Maou-no-Testament-Burst-OAV-Interdit--16-ans",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=5487,
|
|
|
|
category="OAV",
|
|
|
|
name="Shinmai Maou no Testament Departures [Interdit -16 ans]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/5487-Shinmai-Maou-no-Testament-Departures-Interdit--16-ans",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=4830,
|
|
|
|
category="OAV",
|
|
|
|
name="Shinmai Maou no Testament OAD [Interdit -16 ans]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/4830-Shinmai-Maou-no-Testament-OAD-Interdit--16-ans",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=3449,
|
|
|
|
category="Film",
|
|
|
|
name="Robot Contest [J-Film]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/3449-Robot-Contest-J-Film",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=2879,
|
|
|
|
category="OST",
|
|
|
|
name="Baka to Test to shoukanjuu ni! [Saison 2]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/2879-Baka-to-Test-to-shoukanjuu-ni-Saison-2",
|
|
|
|
),
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=1926,
|
|
|
|
category="OST",
|
|
|
|
name="Baka to Test to shoukanjuu [Saison 1]",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/1926-Baka-to-Test-to-shoukanjuu-Saison-1",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
2023-01-13 22:11:55 +00:00
|
|
|
|
|
|
|
@mark.asyncio
|
|
|
|
async def test_history(requests_mock: Mocker):
|
|
|
|
requests_mock.real_http = True
|
|
|
|
requests_mock.get(
|
|
|
|
AnimeUltime().search_url(),
|
|
|
|
text=requests.get("http://www.anime-ultime.net/history-0-1/042006").text,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert await AnimeUltime().search() == [
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=167,
|
|
|
|
category="Film",
|
|
|
|
name="Crayon Shin-chan - Arashi wo Yobu Appare! Sengoku Dai Kassen",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/167/Crayon-Shin-chan---Arashi-wo-Yobu-Appare-Sengoku-Dai-Kassen-vostfr",
|
2023-01-13 23:36:13 +00:00
|
|
|
date="2006-04-10 00:00:00",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@mark.asyncio
|
|
|
|
async def test_search_one(requests_mock: Mocker):
|
|
|
|
requests_mock.real_http = True
|
|
|
|
requests_mock.post(
|
|
|
|
AnimeUltime().search_url("akuma"),
|
|
|
|
text=requests.get(
|
|
|
|
"http://www.anime-ultime.net/file-0-1/4631/Akuma-no-Riddle-Shousha-wa-Dare-Nukiuchi-Test-vostfr"
|
|
|
|
).text,
|
|
|
|
)
|
|
|
|
|
|
|
|
assert await AnimeUltime().search("akuma") == [
|
|
|
|
RemoteFile(
|
|
|
|
bridge="AnimeUltime",
|
|
|
|
id=4631,
|
|
|
|
category="OAV",
|
|
|
|
name="Akuma no Riddle: Shousha wa Dare? Nukiuchi Test vostfr",
|
|
|
|
link="http://www.anime-ultime.net/file-0-1/4631",
|
|
|
|
date="2014-12-27 00:00:00",
|
2023-01-13 22:11:55 +00:00
|
|
|
),
|
|
|
|
]
|