Update unit tests to use XML as well.
Danbooru and Konachan aren't passing just because the posts retrieved aren't the same.
This commit is contained in:
parent
dc6236f00c
commit
bff2dd2ef1
4 changed files with 212 additions and 0 deletions
63
src/libdanbooru/autotests/donmai.xml
Normal file
63
src/libdanbooru/autotests/donmai.xml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<posts type="array">
|
||||||
|
<post>
|
||||||
|
<id type="integer">2107611</id>
|
||||||
|
<created-at type="dateTime">2015-08-27T09:34:16-04:00</created-at>
|
||||||
|
<uploader-id type="integer">366860</uploader-id>
|
||||||
|
<score type="integer">0</score>
|
||||||
|
<source>
|
||||||
|
https://twitter.com/un9man/status/636889719113052160/photo/1</source>
|
||||||
|
<md5>0f9dbcbd1bad31fe266af9878422039f</md5>
|
||||||
|
<last-comment-bumped-at type="dateTime" nil="true" />
|
||||||
|
<rating>s</rating>
|
||||||
|
<image-width type="integer">1000</image-width>
|
||||||
|
<image-height type="integer">1524</image-height>
|
||||||
|
<tag-string>1girl bikini bismarck_(kantai_collection) blonde_hair
|
||||||
|
blue_eyes breasts hat highres kantai_collection long_hair
|
||||||
|
looking_at_viewer oota_yuuichi peaked_cap skirt solo striped
|
||||||
|
striped_bikini striped_swimsuit swimsuit</tag-string>
|
||||||
|
<is-note-locked type="boolean">false</is-note-locked>
|
||||||
|
<fav-count type="integer">0</fav-count>
|
||||||
|
<file-ext>png</file-ext>
|
||||||
|
<last-noted-at type="dateTime" nil="true" />
|
||||||
|
<is-rating-locked type="boolean">false</is-rating-locked>
|
||||||
|
<parent-id type="integer" nil="true" />
|
||||||
|
<has-children type="boolean">false</has-children>
|
||||||
|
<approver-id type="integer" nil="true" />
|
||||||
|
<tag-count-general type="integer">16</tag-count-general>
|
||||||
|
<tag-count-artist type="integer">1</tag-count-artist>
|
||||||
|
<tag-count-character type="integer">1</tag-count-character>
|
||||||
|
<tag-count-copyright type="integer">1</tag-count-copyright>
|
||||||
|
<file-size type="integer">907930</file-size>
|
||||||
|
<is-status-locked type="boolean">false</is-status-locked>
|
||||||
|
<fav-string></fav-string>
|
||||||
|
<pool-string></pool-string>
|
||||||
|
<up-score type="integer">0</up-score>
|
||||||
|
<down-score type="integer">0</down-score>
|
||||||
|
<is-pending type="boolean">false</is-pending>
|
||||||
|
<is-flagged type="boolean">false</is-flagged>
|
||||||
|
<is-deleted type="boolean">false</is-deleted>
|
||||||
|
<tag-count type="integer">19</tag-count>
|
||||||
|
<updated-at type="dateTime">2015-08-27T09:34:16-04:00</updated-at>
|
||||||
|
<is-banned type="boolean">false</is-banned>
|
||||||
|
<pixiv-id type="integer" nil="true" />
|
||||||
|
<last-commented-at type="dateTime" nil="true" />
|
||||||
|
<has-active-children type="boolean">false</has-active-children>
|
||||||
|
<bit-flags type="integer">0</bit-flags>
|
||||||
|
<uploader-name>gary25566</uploader-name>
|
||||||
|
<has-large type="boolean">true</has-large>
|
||||||
|
<tag-string-artist>oota_yuuichi</tag-string-artist>
|
||||||
|
<tag-string-character>
|
||||||
|
bismarck_(kantai_collection)</tag-string-character>
|
||||||
|
<tag-string-copyright>kantai_collection</tag-string-copyright>
|
||||||
|
<tag-string-general>1girl bikini blonde_hair blue_eyes breasts hat
|
||||||
|
highres long_hair looking_at_viewer peaked_cap skirt solo striped
|
||||||
|
striped_bikini striped_swimsuit swimsuit</tag-string-general>
|
||||||
|
<has-visible-children type="boolean">false</has-visible-children>
|
||||||
|
<file-url>/data/0f9dbcbd1bad31fe266af9878422039f.png</file-url>
|
||||||
|
<large-file-url>
|
||||||
|
/data/sample/sample-0f9dbcbd1bad31fe266af9878422039f.jpg</large-file-url>
|
||||||
|
<preview-file-url>
|
||||||
|
/data/preview/0f9dbcbd1bad31fe266af9878422039f.jpg</preview-file-url>
|
||||||
|
</post>
|
||||||
|
</posts>
|
23
src/libdanbooru/autotests/konachan.xml
Normal file
23
src/libdanbooru/autotests/konachan.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<posts count="165244" offset="0">
|
||||||
|
<post actual_preview_height="225" actual_preview_width="300"
|
||||||
|
author="Flandre93" change="907837" created_at="1440681143"
|
||||||
|
creator_id="80078" file_size="815082"
|
||||||
|
file_url="http://konachan.net/image/ef374c49e410b125c5a8d48c692c2a60/Konachan.com%20-%20205776%20bloomers%20gym_uniform%20lemon_tea%20purple_eyes%20purple_hair%20short_hair%20socks%20sport.jpg"
|
||||||
|
frames="" frames_pending="" frames_pending_string=""
|
||||||
|
frames_string="" has_children="false" height="900" id="205776"
|
||||||
|
is_held="false" is_shown_in_index="true" jpeg_file_size="0"
|
||||||
|
jpeg_height="900"
|
||||||
|
jpeg_url="http://konachan.net/image/ef374c49e410b125c5a8d48c692c2a60/Konachan.com%20-%20205776%20bloomers%20gym_uniform%20lemon_tea%20purple_eyes%20purple_hair%20short_hair%20socks%20sport.jpg"
|
||||||
|
jpeg_width="1200" md5="ef374c49e410b125c5a8d48c692c2a60"
|
||||||
|
preview_height="113"
|
||||||
|
preview_url="http://konachan.net/data/preview/ef/37/ef374c49e410b125c5a8d48c692c2a60.jpg"
|
||||||
|
preview_width="150" rating="s" sample_file_size="0"
|
||||||
|
sample_height="900"
|
||||||
|
sample_url="http://konachan.net/image/ef374c49e410b125c5a8d48c692c2a60/Konachan.com%20-%20205776%20bloomers%20gym_uniform%20lemon_tea%20purple_eyes%20purple_hair%20short_hair%20socks%20sport.jpg"
|
||||||
|
sample_width="1200" score="4"
|
||||||
|
source="http://i4.pixiv.net/img-original/img/2015/08/27/21/32/49/52219795_p0.jpg"
|
||||||
|
status="active"
|
||||||
|
tags="bloomers gym_uniform lemon_tea purple_eyes purple_hair short_hair socks sport"
|
||||||
|
width="1200" />
|
||||||
|
</posts>
|
|
@ -79,6 +79,54 @@ void TestDanbooruPost::testPostLoading()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestDanbooruPost::testPostLoadingXml()
|
||||||
|
{
|
||||||
|
QFETCH(QString, jsonFile);
|
||||||
|
auto fileName = QFINDTESTDATA(jsonFile);
|
||||||
|
|
||||||
|
QFile file;
|
||||||
|
file.setFileName(fileName);
|
||||||
|
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
QByteArray data = file.readAll();
|
||||||
|
QFETCH(Danbooru::ApiType, apiType);
|
||||||
|
auto contents = Danbooru::parseDanbooruResult(data, "post", &ok, apiType).at(0).toMap();
|
||||||
|
qDebug() << Danbooru::parseDanbooruResult(data, "post", &ok, apiType).length();
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
QFAIL("XML file failed to load");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QFETCH(QUrl, boardUrl);
|
||||||
|
|
||||||
|
auto post = new Danbooru::DanbooruPost(contents, apiType);
|
||||||
|
Danbooru::fixPostUrl(post, boardUrl);
|
||||||
|
|
||||||
|
QFETCH(int, postId);
|
||||||
|
QFETCH(int, postWidth);
|
||||||
|
QFETCH(int, postHeight);
|
||||||
|
QFETCH(int, fileSize);
|
||||||
|
QFETCH(QSet<QString>, postTags);
|
||||||
|
QFETCH(QUrl, fileUrl);
|
||||||
|
QFETCH(QUrl, thumbnailUrl);
|
||||||
|
QFETCH(QUrl, sampleUrl);
|
||||||
|
QFETCH(Danbooru::DanbooruPost::Rating, rating);
|
||||||
|
|
||||||
|
QCOMPARE(post->id(), postId);
|
||||||
|
QCOMPARE(post->width(), postWidth);
|
||||||
|
QCOMPARE(post->height(), postHeight);
|
||||||
|
QCOMPARE(post->size(), fileSize);
|
||||||
|
QCOMPARE(post->tags(), postTags);
|
||||||
|
QCOMPARE(post->fileUrl(), fileUrl);
|
||||||
|
QCOMPARE(post->thumbnailUrl(), thumbnailUrl);
|
||||||
|
QCOMPARE(post->sampleUrl(), sampleUrl);
|
||||||
|
QCOMPARE(post->rating(), rating);
|
||||||
|
QCOMPARE(post->pixmap().isNull(), true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TestDanbooruPost::testPostLoading_data()
|
void TestDanbooruPost::testPostLoading_data()
|
||||||
{
|
{
|
||||||
//TODO: Add API type
|
//TODO: Add API type
|
||||||
|
@ -132,6 +180,82 @@ void TestDanbooruPost::testPostLoading_data()
|
||||||
// Gelbooru
|
// Gelbooru
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestDanbooruPost::testPostLoadingXml_data()
|
||||||
|
{
|
||||||
|
//TODO: Add API type
|
||||||
|
QTest::addColumn<QString>("jsonFile");
|
||||||
|
QTest::addColumn<Danbooru::ApiType>("apiType");
|
||||||
|
QTest::addColumn<int>("postId");
|
||||||
|
QTest::addColumn<int>("postWidth");
|
||||||
|
QTest::addColumn<int>("postHeight");
|
||||||
|
QTest::addColumn<int>("fileSize");
|
||||||
|
QTest::addColumn<QSet< QString >>("postTags");
|
||||||
|
QTest::addColumn<QUrl>("fileUrl");
|
||||||
|
QTest::addColumn<QUrl>("thumbnailUrl");
|
||||||
|
QTest::addColumn<QUrl>("sampleUrl");
|
||||||
|
QTest::addColumn<Danbooru::DanbooruPost::Rating>("rating");
|
||||||
|
QTest::addColumn<QUrl>("boardUrl");
|
||||||
|
|
||||||
|
// Konachan.com / yande.re
|
||||||
|
QTest::newRow("konachan") << "konachan.xml" // jsonFile
|
||||||
|
<< Danbooru::ApiType::KonachanDanbooru
|
||||||
|
<< 205621 // id
|
||||||
|
<< 1280 // width
|
||||||
|
<< 720 // height
|
||||||
|
<< 885610 // file_size
|
||||||
|
<< QSet<QString>({"azuki_(sayori)", "coconut_(sayori)", "game_cg", "nekopara",
|
||||||
|
"sayori"}) // tags
|
||||||
|
<< QUrl("http://konachan.net/image/eb36c568af4f4e4ea2f59eda7d8c802d/Konachan.com%20-%20205621%20azuki_%28sayori%29%20coconut_%28sayori%29%20game_cg%20nekopara%20sayori.png")
|
||||||
|
<< QUrl("http://konachan.net/data/preview/eb/36/eb36c568af4f4e4ea2f59eda7d8c802d.jpg")
|
||||||
|
<< QUrl("http://konachan.net/jpeg/eb36c568af4f4e4ea2f59eda7d8c802d/Konachan.com%20-%20205621%20azuki_%28sayori%29%20coconut_%28sayori%29%20game_cg%20nekopara%20sayori.jpg")
|
||||||
|
<< Danbooru::DanbooruPost::Safe
|
||||||
|
<< QUrl("http://konachan.com");
|
||||||
|
// Danbooru
|
||||||
|
|
||||||
|
QTest::newRow("danbooru") << "donmai.xml"
|
||||||
|
<< Danbooru::ApiType::OriginalDanbooru
|
||||||
|
<< 2106872
|
||||||
|
<< 1200
|
||||||
|
<< 993
|
||||||
|
<< 514370
|
||||||
|
<< QSet<QString>({"1girl", "all_fours", "bare_legs",
|
||||||
|
"barefoot", "brown_eyes", "brown_hair", "chain",
|
||||||
|
"collar", "hat", "hecatia_lapislazuli", "long_hair",
|
||||||
|
"looking_at_viewer", "off_shoulder",
|
||||||
|
"shirt", "skirt", "solo", "touhou",
|
||||||
|
"uranaishi_(miraura)" })
|
||||||
|
<< QUrl("http://danbooru.donmai.us/data/7ee70315eba5ea4fbda7cd6011c8d833.jpg")
|
||||||
|
<< QUrl("http://danbooru.donmai.us/data/preview/7ee70315eba5ea4fbda7cd6011c8d833.jpg")
|
||||||
|
<< QUrl("http://danbooru.donmai.us/data/sample/sample-7ee70315eba5ea4fbda7cd6011c8d833.jpg")
|
||||||
|
<< Danbooru::DanbooruPost::Safe
|
||||||
|
<< QUrl("http://danbooru.donmai.us");
|
||||||
|
|
||||||
|
// Gelbooru
|
||||||
|
|
||||||
|
QTest::newRow("gelbooru") << "gelbooru.xml"
|
||||||
|
<< Danbooru::ApiType::Gelbooru
|
||||||
|
<< 2825488
|
||||||
|
<< 2483
|
||||||
|
<< 3500
|
||||||
|
<< 0
|
||||||
|
<< QSet<QString>({"2girls", "absurdres", "ahoge", "artist_request", "bikini",
|
||||||
|
"blonde_hair", "blush", "braid", "building", "cameltoe",
|
||||||
|
"character_request", "city", "cloud", "cover",
|
||||||
|
"cover_page", "eating", "flat_chest", "food",
|
||||||
|
"hair_intakes", "highres", "ice_cream", "ice_cream_cone",
|
||||||
|
"leaning_forward", "leg_lift", "licking", "long_hair",
|
||||||
|
"looking_at_viewer", "multiple_girls", "navel", "open_mouth",
|
||||||
|
"outdoors", "red_eyes", "ribbon", "sandals", "school_swimsuit",
|
||||||
|
"side-tie_bikini", "silver_hair", "sky", "skyscraper",
|
||||||
|
"smile", "swimsuit", "thigh_gap", "tongue", "twin_braids",
|
||||||
|
"twintails", "two_side_up", "very_long_hair"})
|
||||||
|
<< QUrl("http://gelbooru.com/images/92/ba/92ba4abfcb084ee49c0d3c1a08bcc3bf.jpg")
|
||||||
|
<< QUrl("http://gelbooru.com/thumbnails/92/ba/thumbnail_92ba4abfcb084ee49c0d3c1a08bcc3bf.jpg")
|
||||||
|
<< QUrl("http://gelbooru.com/samples/92/ba/sample_92ba4abfcb084ee49c0d3c1a08bcc3bf.jpg")
|
||||||
|
<< Danbooru::DanbooruPost::Safe
|
||||||
|
<< QUrl("http://gelbooru.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN(TestDanbooruPost)
|
QTEST_MAIN(TestDanbooruPost)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ private Q_SLOTS:
|
||||||
void initTestCase();
|
void initTestCase();
|
||||||
void testPostLoading();
|
void testPostLoading();
|
||||||
void testPostLoading_data();
|
void testPostLoading_data();
|
||||||
|
void testPostLoadingXml();
|
||||||
|
void testPostLoadingXml_data();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue