diff options
author | randomdan <randomdan@localhost> | 2014-09-19 23:52:30 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2014-09-19 23:52:30 +0000 |
commit | 28691c29e93fbc4fdb5ae4866287282840fba021 (patch) | |
tree | 8b83ca80afc3f3a5d11b04a56c440d2aa38f4e16 /libtmdb/testModels.cpp | |
parent | Support muxing directly in storage (diff) | |
download | p2pvr-28691c29e93fbc4fdb5ae4866287282840fba021.tar.bz2 p2pvr-28691c29e93fbc4fdb5ae4866287282840fba021.tar.xz p2pvr-28691c29e93fbc4fdb5ae4866287282840fba021.zip |
First bash at a slicer ice proxy for TMDb and an untested instantiation in p2pvr's core adapter
Diffstat (limited to 'libtmdb/testModels.cpp')
-rw-r--r-- | libtmdb/testModels.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/libtmdb/testModels.cpp b/libtmdb/testModels.cpp new file mode 100644 index 0000000..19e1df7 --- /dev/null +++ b/libtmdb/testModels.cpp @@ -0,0 +1,117 @@ +#define BOOST_TEST_MODULE Deserialize +#include <boost/test/included/unit_test.hpp> + +#include <tmdb-models.h> +#include <slicer/slicer.h> +#include <slicer/json/serializer.h> + +namespace std { + std::ostream & + operator<<(std::ostream & o, const TMDb::Date & d) + { + o << d.Year << '-' << d.Month << '-' << d.Day; + return o; + } +}; + +BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json ) +{ + auto results = Slicer::Deserialize<Slicer::JsonFile, TMDb::SearchMultiResults>("samples/searchMulti_breakingBad.json"); + BOOST_REQUIRE_EQUAL(1, results->Page); + BOOST_REQUIRE_EQUAL(1, results->TotalPages); + BOOST_REQUIRE_EQUAL(3, results->TotalResults); + + BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchTv", results->Results[0]->ice_id()); + auto tv = TMDb::SearchMatchTvPtr::dynamicCast(results->Results[0]); + BOOST_REQUIRE_EQUAL("Breaking Bad", tv->Name); + BOOST_REQUIRE_EQUAL("/4yMXf3DW6oCL0lVPZaZM2GypgwE.jpg", tv->PosterPath); + BOOST_REQUIRE_EQUAL(1396, tv->Id); + + BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchMovie", results->Results[1]->ice_id()); + auto movie = TMDb::SearchMatchMoviePtr::dynamicCast(results->Results[1]); + BOOST_REQUIRE_EQUAL("No Half Measures: Creating the Final Season of Breaking Bad", movie->Title); + BOOST_REQUIRE_EQUAL("/8OixSR45U5dbqv8F0tlspmTbXxN.jpg", movie->PosterPath); + BOOST_REQUIRE_EQUAL(239459, movie->Id); + + BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchPerson", results->Results[2]->ice_id()); + auto person = TMDb::SearchMatchPersonPtr::dynamicCast(results->Results[2]); + BOOST_REQUIRE_EQUAL("Brad Pitt", person->Name); + BOOST_REQUIRE_EQUAL(287, person->Id); +} + +BOOST_AUTO_TEST_CASE( deserialize_movie_json ) +{ + auto movie = Slicer::Deserialize<Slicer::JsonFile, TMDb::Movie>("samples/movie_550.json"); + BOOST_REQUIRE_EQUAL(550, movie->Id); + BOOST_REQUIRE_EQUAL(false, movie->Adult); + BOOST_REQUIRE_EQUAL("/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg", movie->BackdropPath); + BOOST_REQUIRE_EQUAL(3, movie->Genres.size()); + BOOST_REQUIRE_EQUAL(28, movie->Genres.front().Id); + BOOST_REQUIRE_EQUAL("Action", movie->Genres.front().Name); + BOOST_REQUIRE_EQUAL(63000000, movie->Budget); + BOOST_REQUIRE_EQUAL("http://www.fightclub.com/", movie->HomePage); + BOOST_REQUIRE_EQUAL("tt0137523", movie->ImdbId); + BOOST_REQUIRE_EQUAL("Fight Club", movie->OriginalTitle); + BOOST_REQUIRE_CLOSE(61151.75, movie->Popularity, 0.1); + BOOST_REQUIRE_EQUAL("/2lECpi35Hnbpa4y46JX0aY3AWTy.jpg", movie->PosterPath); + BOOST_REQUIRE_EQUAL(295, movie->Overview.length()); + BOOST_REQUIRE_EQUAL(1, movie->ProductionCompanies.size()); + BOOST_REQUIRE_EQUAL(25, movie->ProductionCompanies.front().Id); + BOOST_REQUIRE_EQUAL("20th Century Fox", movie->ProductionCompanies.front().Name); + BOOST_REQUIRE_EQUAL(2, movie->ProductionCountries.size()); + BOOST_REQUIRE_EQUAL("DE", movie->ProductionCountries.front().Id); + BOOST_REQUIRE_EQUAL("Germany", movie->ProductionCountries.front().Name); + BOOST_REQUIRE_EQUAL(TMDb::Date({1999, 10, 15}), movie->ReleaseDate); + BOOST_REQUIRE_EQUAL(1, movie->SpokenLanguages.size()); + BOOST_REQUIRE_EQUAL("en", movie->SpokenLanguages.front().Id); + BOOST_REQUIRE_EQUAL("English", movie->SpokenLanguages.front().Name); + BOOST_REQUIRE_EQUAL(100853753, movie->Revenue); + BOOST_REQUIRE_EQUAL(139, movie->Runtime); + BOOST_REQUIRE_EQUAL("Released", movie->Status); + BOOST_REQUIRE_EQUAL("How much can you know about yourself if you've never been in a fight?", movie->Tagline); + BOOST_REQUIRE_EQUAL("Fight Club", movie->Title); + BOOST_REQUIRE_CLOSE(9.0999999, movie->VoteAverage, 0.01); + BOOST_REQUIRE_EQUAL(174, movie->VoteCount); +} + +BOOST_AUTO_TEST_CASE( deserialize_tvseries_json ) +{ + auto tvSeries = Slicer::Deserialize<Slicer::JsonFile, TMDb::TvSeries>("samples/tv_1396.json"); + BOOST_REQUIRE_EQUAL("/sIJyCJedGlZf1TId41gCtkblBGo.jpg", tvSeries->BackdropPath); + BOOST_REQUIRE_EQUAL(1, tvSeries->CreatedBy.size()); + BOOST_REQUIRE_EQUAL(66633, tvSeries->CreatedBy.front().Id); + BOOST_REQUIRE_EQUAL("Vince Gilligan", tvSeries->CreatedBy.front().Name); + BOOST_REQUIRE_EQUAL("/rLSUjr725ez1cK7SKVxC9udO03Y.jpg", tvSeries->CreatedBy.front().ProfilePath); + BOOST_REQUIRE_EQUAL(2, tvSeries->EpisodeRunTimes.size()); + BOOST_REQUIRE_EQUAL(45, tvSeries->EpisodeRunTimes.front()); + BOOST_REQUIRE_EQUAL(TMDb::Date({2008, 1, 19}), tvSeries->FirstAirDate); + BOOST_REQUIRE_EQUAL(1, tvSeries->Genres.size()); + BOOST_REQUIRE_EQUAL(18, tvSeries->Genres.front().Id); + BOOST_REQUIRE_EQUAL("Drama", tvSeries->Genres.front().Name); + BOOST_REQUIRE_EQUAL("http://www.amctv.com/shows/breaking-bad", tvSeries->HomePage); + BOOST_REQUIRE_EQUAL(1396, tvSeries->Id); + BOOST_REQUIRE_EQUAL(false, tvSeries->InProduction); + BOOST_REQUIRE_EQUAL(5, tvSeries->Languages.size()); + BOOST_REQUIRE_EQUAL("en", tvSeries->Languages.front()); + BOOST_REQUIRE_EQUAL(TMDb::Date({2013, 9, 29}), tvSeries->LastAirDate); + BOOST_REQUIRE_EQUAL("Breaking Bad", tvSeries->Name); + BOOST_REQUIRE_EQUAL(1, tvSeries->Networks.size()); + BOOST_REQUIRE_EQUAL(174, tvSeries->Networks.front().Id); + BOOST_REQUIRE_EQUAL("AMC", tvSeries->Networks.front().Name); + BOOST_REQUIRE_EQUAL(62, tvSeries->NumberOfEpisodes); + BOOST_REQUIRE_EQUAL(5, tvSeries->NumberOfSeasons); + BOOST_REQUIRE_EQUAL(1, tvSeries->OriginCountries.size()); + BOOST_REQUIRE_EQUAL("US", tvSeries->OriginCountries.front()); + BOOST_REQUIRE_EQUAL(651, tvSeries->Overview.length()); + BOOST_REQUIRE_CLOSE(7.684, tvSeries->Popularity, 0.01); + BOOST_REQUIRE_EQUAL("/4yMXf3DW6oCL0lVPZaZM2GypgwE.jpg", tvSeries->PosterPath); + BOOST_REQUIRE_EQUAL(6, tvSeries->Seasons.size()); + BOOST_REQUIRE_EQUAL(TMDb::Date({2012, 7, 15}), tvSeries->Seasons.back().AirDate); + BOOST_REQUIRE_EQUAL(3578, tvSeries->Seasons.back().Id); + BOOST_REQUIRE_EQUAL("/ih1JKNxEzW56azeFpEQmdu4poA4.jpg", tvSeries->Seasons.back().PosterPath); + BOOST_REQUIRE_EQUAL(5, tvSeries->Seasons.back().SeasonNumber); + BOOST_REQUIRE_EQUAL("Ended", tvSeries->Status); + BOOST_REQUIRE_CLOSE(9, tvSeries->VoteAverage, 0.01); + BOOST_REQUIRE_EQUAL(72, tvSeries->VoteCount); +} + |