Initial commit

This commit is contained in:
2025-05-21 16:19:06 +02:00
commit 4ec4a27b89
23 changed files with 1230 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
{
"figures": [
{
"hpoi_id": 74499,
"cn_name": "粘土人#1939 初音未來 15周年纪念版",
"original_name": "ねんどろいど 初音ミク 15th Anniversary Ver.",
"tags": [
{
"name": "女",
"link": "hobby/all?order=hits7Day&sex=0&category=3"
},
{
"name": "Q版人形",
"link": "hobby/all?order=hits7Day&category=3"
},
{
"name": "全年龄",
"link": "hobby/all?order=hits7Day&r18=0&category=3"
},
{
"name": "可动",
"link": "hobby/all?order=hits7Day&specs=649231,&category=3"
}
],
"value": {
"JPY": 9400,
"CNY": 465
},
"release": [],
"scale": null,
"size": "H=100mm",
"mfc_id": null,
"images": [
"https://r.hpoi.net/gk/pic/raw/2025/05/12d8f19dac3e464ab7e9664220fe055a.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/208c269428424209be23fe4703a63aa4.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/82248e0d7479484eb0fad567dccb9941.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/83a72c5f468b4ccb84afdc3edbe59c0f.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/b7cf949c1d1342e6a24fe82e3d2c8bae.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/72be01a91cbc4b18b15803c7e91ef368.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/14ab574070f64147ab5b69554950f495.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/4e720f38ce4e4143b2b947fa996b54e7.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/2aa5fed24fe943e49b542744d53f95c6.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/a6ab1f2caaa14eb391be09e05684e408.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/a46506d98fd54e8488c8dcc1c44e48ac.jpg",
"https://r.hpoi.net/gk/pic/raw/2022/08/0e11694622a34d939860f124945f0cd7.gif"
]
},
{
"hpoi_id": 61735,
"cn_name": "宝箱怪",
"original_name": "宝箱怪",
"tags": [
{
"name": "女",
"link": "hobby/all?order=hits7Day&sex=0&category=1"
},
{
"name": "比例人形",
"link": "hobby/all?order=hits7Day&category=1"
},
{
"name": "普通露出",
"link": "hobby/all?order=hits7Day&r18=15&category=1"
}
],
"value": {
"CNY": 1999
},
"release": [],
"scale": "1/3",
"size": "H=270mm L=335mm D=355mm",
"mfc_id": null,
"images": [
"https://r.hpoi.net/gk/pic/raw/2021/10/19da2a2a42d8422d9048b33d743d7afb.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/eee8e4820fe04fb7aec0c3b7093ab528.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/c507b616ad8d42b6b899234e041bebe7.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/8e86d1a8ea9742209c521c6767f898f4.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/63cc169243714c458a164c1dd55140cf.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/8af0233a86954090b2087842e165747a.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/56612f2a53584faaa56469606b782b09.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/f3e2f303c36748ed82a14af8bcd6f8bb.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/10/b146e3f46fa14b46917153d6249a52e2.jpg",
"https://r.hpoi.net/gk/pic/raw/2021/06/44cec85622eb49d9847b0ce2ed86fb0d.jpg",
"https://r.hpoi.net/gk/pic/raw/2020/10/f9241e34a31e4506a0115af98745ac27.jpg",
"https://r.hpoi.net/gk/pic/raw/2020/10/3b41f782778c40b1b3f8e2d7385b0626.jpg"
]
}
]
}

View File

@@ -0,0 +1,25 @@
import asyncio
import json
import os
from dataclasses import asdict
from hpoi.models.figure import Figure
async def generate_test_data_figures():
data = {
"figures": [
asdict(await Figure.from_hpoi_id(hpoi_id)) for hpoi_id in [74499, 61735]
]
}
json.dump(
data,
open(os.path.join(os.path.dirname(__file__), "figures.json"), "w"),
indent=4,
ensure_ascii=False,
)
if __name__ == "__main__":
asyncio.run(generate_test_data_figures())

30
tests/test_figures.py Normal file
View File

@@ -0,0 +1,30 @@
import json
import os
from dataclasses import asdict
import pytest
from hpoi.models.figure import Figure
from hpoi.models.tag import Tag
async def common_figure_test(hpoi_id):
figure = await Figure.from_hpoi_id(hpoi_id)
assert figure is not None
assert isinstance(figure, Figure)
return figure
@pytest.mark.asyncio
async def test_figures():
with open(
os.path.join(os.path.dirname(__file__), "test_data/figures.json")
) as file:
test_cases: list[dict] = json.load(file)["figures"]
for test_case in test_cases:
figure_test_case = Figure(**test_case)
figure_hpoi = asdict(await Figure.from_hpoi_id(figure_test_case.hpoi_id))
for parameter, value in test_case.items():
assert value == figure_hpoi[parameter]

11
tests/test_utils.py Normal file
View File

@@ -0,0 +1,11 @@
from hpoi.models.currency import Currency
from hpoi.utils import get_price_from_text
def test_get_price_from_text():
assert get_price_from_text("0人民币") == {}
assert get_price_from_text("9,400日元 含税465元") == {
Currency.CNY: 465,
Currency.JPY: 9400,
}
assert get_price_from_text("249人民币") == {Currency.CNY: 249}