Tests: Updated Episode Tests for New Parsing Method
This commit is contained in:
parent
00ab93dfbb
commit
009d9fef1a
|
@ -9,166 +9,60 @@ namespace dropout_dl {
|
|||
|
||||
std::string (*test_function)(const std::string&) = episode::get_episode_name;
|
||||
|
||||
|
||||
// window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":2429553,"COLLECTION_ID":784936,"COLLECTION_TITLE":"Season 5","PRODUCT_ID":28599,"VIDEO_TITLE":"Sam Says 2","CANONICAL_COLLECTION":{"id":784936,"name":"Season 5","href":"https://www.dropout.tv/season-5-7","parent":{"id":121093,"name":"Game Changer","type":"series"}}}}
|
||||
|
||||
std::string base_test_solution = "Base Test Title";
|
||||
std::string base_test = " <h1 class=\"video-title\">\n"
|
||||
" <strong>" + base_test_solution + "</strong>\n"
|
||||
" </h1>";
|
||||
std::string base_test = R"(window.Page = {"VIDEO_TITLE":")" + base_test_solution + "\"}";
|
||||
|
||||
|
||||
out.emplace_back("Basic Episode Name Parsing", test_function, base_test, base_test_solution);
|
||||
|
||||
|
||||
std::string multiple_header_test_solution = "Multi Header Test Title";
|
||||
std::string multiple_header_test = "<h1>\n"
|
||||
"Header without class or strong\n"
|
||||
"</h1>\n"
|
||||
"<h1 class=\"head primary site-font-primary-color site-font-primary-family margin-bottom-small collection-title\">\n"
|
||||
"Header with incorrect classes"
|
||||
"</h1>\n"
|
||||
"<h1>\n"
|
||||
"<strong>Header with strong</strong>"
|
||||
"</h1>\n"
|
||||
"<h1 class=\"video-title\">\n"
|
||||
" <strong>" + multiple_header_test_solution + "</strong>\n"
|
||||
"</h1>\n"
|
||||
"<h1 class=\"video-title\">\n"
|
||||
" <strong> Valid Header and Strong After Correct Title </strong>\n"
|
||||
"</h1>";
|
||||
std::string full_test_solution = "Full Test Title";
|
||||
std::string full_test = R"(window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":12345,"COLLECTION_ID":12345,"COLLECTION_TITLE":"Season 0","PRODUCT_ID":12345,"VIDEO_TITLE":")" + full_test_solution + R"(","CANONICAL_COLLECTION":{"id":12345,"name":"Season 0","href":"https://www.dropout.tv/season-0-0","parent":{"id":12345,"name":"lorem","type":"series"}}}})";
|
||||
|
||||
out.emplace_back("Full Episode Name Parsing", test_function, full_test, full_test_solution);
|
||||
|
||||
out.emplace_back("Multiple Header Episode Name Parsing", test_function, multiple_header_test, multiple_header_test_solution);
|
||||
std::string no_valid_title_test_solution = "ERROR";
|
||||
std::string no_valid_title_test = R"(window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":12345,"COLLECTION_ID":12345,"COLLECTION_TITLE":"Season 0","PRODUCT_ID":12345,"CANONICAL_COLLECTION":{"id":12345,"name":"Season 0","href":"https://www.dropout.tv/season-0-0","parent":{"id":12345,"name":"lorem","type":"series"}}}})";
|
||||
|
||||
std::string no_valid_header_test_solution = "ERROR";
|
||||
std::string no_valid_header_test = "<h1>\n"
|
||||
"Header without class or Strong\n"
|
||||
"</h1>\n"
|
||||
"<h1 class=\"head primary site-font-primary-color site-font-primary-family margin-bottom-small collection-title\">\n"
|
||||
"Header with incorrect classes"
|
||||
"</h1>\n"
|
||||
"<h1>\n"
|
||||
"<strong>Header with strong</strong>"
|
||||
"</h1>\n";
|
||||
|
||||
out.emplace_back("No Valid Header Episode Name Parsing", test_function, no_valid_header_test, no_valid_header_test_solution);
|
||||
out.emplace_back("No Valid Title Episode Name Parsing", test_function, no_valid_title_test, no_valid_title_test_solution);
|
||||
|
||||
|
||||
std::string html_character_test_solution = "'&;";
|
||||
std::string html_character_test = "<h1 class=\"video-title\">\n"
|
||||
" <strong>'&;</strong>\n"
|
||||
"</h1>";
|
||||
std::string html_character_test = R"(window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":12345,"COLLECTION_ID":12345,"COLLECTION_TITLE":"Season 0","PRODUCT_ID":12345,"VIDEO_TITLE":"'&;","CANONICAL_COLLECTION":{"id":12345,"name":"Season 0","href":"https://www.dropout.tv/season-0-0","parent":{"id":12345,"name":"lorem","type":"series"}}}})";
|
||||
|
||||
out.emplace_back("Html Character Code Episode Name Parsing", test_function, html_character_test, html_character_test_solution);
|
||||
|
||||
|
||||
return {"Episode Name Parsing", out};
|
||||
}
|
||||
|
||||
tests test_episode_number_parsing() {
|
||||
std::vector<dropout_dl::test<std::string>> out;
|
||||
|
||||
std::string (*test_function)(const std::string&) = episode::get_episode_number;
|
||||
|
||||
std::string base_test_solution = "1";
|
||||
std::string base_test = "<a>\n"
|
||||
" Season 1, Episode 1\n"
|
||||
"</a>";
|
||||
|
||||
out.emplace_back("Basic Episode Number Parsing", test_function, base_test, base_test_solution);
|
||||
|
||||
|
||||
std::string multiple_link_test_solution = "1";
|
||||
std::string multiple_link_test = "<a>\n"
|
||||
"asjdhgaorihg\n"
|
||||
"</a>\n"
|
||||
"<a>\n"
|
||||
" Season 1, Episode 1\n"
|
||||
"</a>\n"
|
||||
"<a>\n"
|
||||
" Season 1, Episode 2\n";
|
||||
|
||||
|
||||
out.emplace_back("Multiple Link Episode Number Parsing", test_function, multiple_link_test, multiple_link_test_solution);
|
||||
|
||||
std::string no_valid_number_test_solution = "-1";
|
||||
std::string no_valid_number_test = "<a>\n"
|
||||
"816\n"
|
||||
"</a>\n"
|
||||
"<a href=\"www.mossx.net\">\n"
|
||||
"157"
|
||||
"</a>\n"
|
||||
"<a>\n"
|
||||
"Episode"
|
||||
"</a>\n";
|
||||
|
||||
out.emplace_back("No Valid Episode Number Parsing", test_function, no_valid_number_test, no_valid_number_test_solution);
|
||||
|
||||
|
||||
std::string earlier_episode_text_test_solution = "15";
|
||||
std::string earlier_episode_text_test = " <h1 class=\"head primary site-font-primary-color site-font-primary-family margin-bottom-small collection-title video-title\">\n"
|
||||
" <strong>Episode Wrong</strong>\n"
|
||||
" </h1>\n"
|
||||
"<a>\n"
|
||||
" Season 1, Episode 15\n"
|
||||
"</a>";
|
||||
|
||||
out.emplace_back("Earlier Episode Text Number Parsing", test_function, earlier_episode_text_test, earlier_episode_text_test_solution);
|
||||
|
||||
return {"Episode Number Parsing", out};
|
||||
}
|
||||
|
||||
tests test_episode_series_name_parsing() {
|
||||
std::vector<dropout_dl::test<std::string>> out;
|
||||
|
||||
std::string (*test_function)(const std::string&) = episode::get_series_name;
|
||||
|
||||
// window.Page = {"PROPERTIES":{"VIEW_TYPE":"collection","PRODUCT_ID":28599,"COLLECTION_ID":121093,"COLLECTION_TITLE":"Game Changer"}}
|
||||
|
||||
std::string base_test_solution = "Base Test Title";
|
||||
std::string base_test = "<h3 class=\"series-title\">\n"
|
||||
" <a>\n"
|
||||
" Base Test Title\n"
|
||||
" </a>\n"
|
||||
"</h3>";
|
||||
std::string base_test = R"(window.Page = {"parent":{"name":")" + base_test_solution + R"("}})";
|
||||
|
||||
out.emplace_back("Basic Episode Series Name Parsing", test_function, base_test, base_test_solution);
|
||||
|
||||
|
||||
std::string multiple_header_test_solution = "Multi Header Test Title";
|
||||
std::string multiple_header_test = "<h3>\n"
|
||||
"Header without class or link\n"
|
||||
"</h3>\n"
|
||||
"<h3 class=\"head primary site-font-primary-color site-font-primary-family margin-bottom-small collection-title\">\n"
|
||||
"Header with incorrect classes"
|
||||
"</h3>\n"
|
||||
"<h3>\n"
|
||||
"<a>Header with strong</a>"
|
||||
"</h3>\n"
|
||||
"<h3 class=\"series-title\">\n"
|
||||
" <a>" + multiple_header_test_solution + "</a>\n"
|
||||
"</h3>\n"
|
||||
"<h3 class=\"series-title\">\n"
|
||||
" <a> Valid Header and Link After Correct Title </a>\n"
|
||||
"</h3>";
|
||||
std::string full_test_solution = "Full Test Title";
|
||||
std::string full_test = R"(window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":12345,"COLLECTION_ID":12345,"COLLECTION_TITLE":"Season 0","PRODUCT_ID":12345,"VIDEO_TITLE":"lorem","CANONICAL_COLLECTION":{"id":12345,"name":"Season 0","href":"https://www.dropout.tv/season-0-0","parent":{"id":12345,"name":")" + full_test_solution + R"(","type":"series"}}}})";
|
||||
|
||||
|
||||
out.emplace_back("Multiple Header Episode Series Name Parsing", test_function, multiple_header_test, multiple_header_test_solution);
|
||||
out.emplace_back("Full Series Name Parsing", test_function, full_test, full_test_solution);
|
||||
|
||||
std::string no_valid_header_test_solution = "ERROR";
|
||||
std::string no_valid_header_test = "<h3>\n"
|
||||
"Header without class or link\n"
|
||||
"</h3>\n"
|
||||
"<h3 class=\"head primary site-font-primary-color site-font-primary-family margin-bottom-small collection-title\">\n"
|
||||
"Header with incorrect classes"
|
||||
"</h3>\n"
|
||||
"<h3>\n"
|
||||
"<a>Header with strong</a>"
|
||||
"</h3>\n";
|
||||
|
||||
std::string no_valid_header_test = R"(window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":12345,"COLLECTION_ID":12345,"COLLECTION_TITLE":"Season 0","PRODUCT_ID":12345,"VIDEO_TITLE":"lorem","CANONICAL_COLLECTION":{"id":12345,"name":"Season 0","href":"https://www.dropout.tv/season-0-0","parent":{"id":12345,"type":"series"}}}})";
|
||||
out.emplace_back("No Valid Header Episode Series Name Parsing", test_function, no_valid_header_test, no_valid_header_test_solution);
|
||||
|
||||
|
||||
std::string html_character_test_solution = "'&;";
|
||||
std::string html_character_test = "<h3 class=\"series-title\">\n"
|
||||
" <a>'&;</a>\n"
|
||||
"</h3>";
|
||||
|
||||
std::string html_character_test = R"(window.Page = {"PROPERTIES":{"VIEW_TYPE":"video","VIDEO_ID":12345,"COLLECTION_ID":12345,"COLLECTION_TITLE":"Season 0","PRODUCT_ID":12345,"VIDEO_TITLE":"lorem","CANONICAL_COLLECTION":{"id":12345,"name":"Season 0","href":"https://www.dropout.tv/season-0-0","parent":{"id":12345,"name":"'&;","type":"series"}}}})";
|
||||
out.emplace_back("Html Character Code Episode Series Name Parsing", test_function, html_character_test, html_character_test_solution);
|
||||
|
||||
return {"Series Name Parsing", out};
|
||||
|
@ -292,9 +186,6 @@ std::vector<dropout_dl::tests> test_episode() {
|
|||
testss.push_back(dropout_dl::test_episode_name_parsing());
|
||||
|
||||
|
||||
testss.push_back(dropout_dl::test_episode_number_parsing());
|
||||
|
||||
|
||||
testss.push_back(dropout_dl::test_episode_series_name_parsing());
|
||||
|
||||
|
||||
|
@ -305,4 +196,4 @@ std::vector<dropout_dl::tests> test_episode() {
|
|||
|
||||
|
||||
return testss;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue