diff options
author | Victor Toso <me@victortoso.com> | 2015-08-25 14:00:26 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2015-08-25 14:55:44 +0200 |
commit | 060472c67305db0da6cd4b0673cdd73534a403c8 (patch) | |
tree | 0f1088def5b79ea734dd2425c705c6e013fc9d85 | |
parent | 2a6dcfc954c14ae5d0b6161f436ce6a4a2f3f5e8 (diff) | |
download | grilo-plugins-060472c67305db0da6cd4b0673cdd73534a403c8.tar.gz |
tests: thetvdb with fuzzy name in show name
https://bugzilla.gnome.org/show_bug.cgi?id=748423
-rw-r--r-- | tests/thetvdb/Makefile.am | 2 | ||||
-rw-r--r-- | tests/thetvdb/data/config.ini | 6 | ||||
-rw-r--r-- | tests/thetvdb/data/csi_miami_get_series.txt | 15 | ||||
-rw-r--r-- | tests/thetvdb/data/csi_miami_series_all_en.zip | bin | 0 -> 61997 bytes | |||
-rw-r--r-- | tests/thetvdb/test_thetvdb_resolve_shows.c | 54 |
5 files changed, 77 insertions, 0 deletions
diff --git a/tests/thetvdb/Makefile.am b/tests/thetvdb/Makefile.am index 4d05edd..d65ed68 100644 --- a/tests/thetvdb/Makefile.am +++ b/tests/thetvdb/Makefile.am @@ -55,6 +55,8 @@ dist_noinst_DATA = \ data/adventure_time_series_all_en.zip \ data/boardwalk_empire_get_series.txt \ data/boardwalk_empire_series_all_en.zip \ + data/csi_miami_get_series.txt \ + data/csi_miami_series_all_en.zip \ data/felicity_get_series.txt \ data/felicity_series_all_en.zip \ data/house_get_series.txt \ diff --git a/tests/thetvdb/data/config.ini b/tests/thetvdb/data/config.ini index da7d1eb..59b48f4 100644 --- a/tests/thetvdb/data/config.ini +++ b/tests/thetvdb/data/config.ini @@ -30,3 +30,9 @@ data = house_series_all_en.zip data = naruto_get_series.txt [http://thetvdb.com/api/THETVDB_TEST_MOCK_API_KEY/series/78857/all/en.zip] data = naruto_series_all_en.zip + +# CSI - Miami (fuzzy name) +[http://thetvdb.com/api/GetSeries.php?seriesname=CSI - Miami] +data = csi_miami_get_series.txt +[http://thetvdb.com/api/THETVDB_TEST_MOCK_API_KEY/series/78310/all/en.zip] +data = csi_miami_series_all_en.zip diff --git a/tests/thetvdb/data/csi_miami_get_series.txt b/tests/thetvdb/data/csi_miami_get_series.txt new file mode 100644 index 0000000..904ae5b --- /dev/null +++ b/tests/thetvdb/data/csi_miami_get_series.txt @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<Data> +<Series> +<seriesid>78310</seriesid> +<language>en</language> +<SeriesName>CSI: Miami</SeriesName> +<banner>graphical/78310-g4.jpg</banner> +<Overview>CSI's gritty approach to crime known as forensic science makes its way from Las Vegas to the streets of Florida in CSI: Miami. A whole new team of crime scene investigators is on hand to probe the seamy underside of Miami.</Overview> +<FirstAired>2002-08-05</FirstAired> +<Network>CBS</Network> +<IMDB_ID>tt0313043</IMDB_ID> +<zap2it_id>EP00524061</zap2it_id> +<id>78310</id> +</Series> +</Data>
\ No newline at end of file diff --git a/tests/thetvdb/data/csi_miami_series_all_en.zip b/tests/thetvdb/data/csi_miami_series_all_en.zip Binary files differnew file mode 100644 index 0000000..a8eed04 --- /dev/null +++ b/tests/thetvdb/data/csi_miami_series_all_en.zip diff --git a/tests/thetvdb/test_thetvdb_resolve_shows.c b/tests/thetvdb/test_thetvdb_resolve_shows.c index 7bc8963..d6c4e17 100644 --- a/tests/thetvdb/test_thetvdb_resolve_shows.c +++ b/tests/thetvdb/test_thetvdb_resolve_shows.c @@ -178,6 +178,59 @@ test_shows (void) } } +/* As the net is mocked we ensure that request with fuzzy name returns the same + * data that the correct name in tvdb's database. Note that tvdb has its own + * fuzzy name handling and the response could change in the future; + * Current wiki for GetSeries API says: + * "This is the string you want to search for. If there is an exact match for + * the parameter, it will be the first result returned." + */ +static void +test_shows_fuzzy_name (void) +{ + GrlSource *source; + guint i; + + struct { + gchar *name_in_tvdb; + gchar *fuzzy_name; + gchar *tvdb_id; + gchar *imdb; + } videos[] = { + { "CSI: Miami", "CSI - Miami", "78310", "tt0313043" } + }; + + source = test_get_source (); + g_assert (source); + + /* First we search and populate the db using the fuzzy name and then we do + * a cache-only request with both, correct and fuzzy name */ + for (i = 0; i < G_N_ELEMENTS (videos); i++) { + gchar *imdb, *tvdb_id; + + get_show_metadata (source, FALSE, videos[i].fuzzy_name, &imdb, &tvdb_id, + NULL, NULL, NULL, NULL, NULL); + g_assert_cmpstr (videos[i].tvdb_id, ==, tvdb_id); + g_free (tvdb_id); + g_assert_cmpstr (videos[i].imdb, ==, imdb); + g_free (imdb); + + get_show_metadata (source, TRUE, videos[i].name_in_tvdb, &imdb, &tvdb_id, + NULL, NULL, NULL, NULL, NULL); + g_assert_cmpstr (videos[i].tvdb_id, ==, tvdb_id); + g_free (tvdb_id); + g_assert_cmpstr (videos[i].imdb, ==, imdb); + g_free (imdb); + + get_show_metadata (source, TRUE, videos[i].fuzzy_name, &imdb, &tvdb_id, + NULL, NULL, NULL, NULL, NULL); + g_assert_cmpstr (videos[i].tvdb_id, ==, tvdb_id); + g_free (tvdb_id); + g_assert_cmpstr (videos[i].imdb, ==, imdb); + g_free (imdb); + } +} + gint main (gint argc, gchar **argv) { @@ -195,6 +248,7 @@ main (gint argc, gchar **argv) test_setup_thetvdb (); g_test_add_func ("/thetvdb/resolve/shows", test_shows); + g_test_add_func ("/thetvdb/resolve/fuzzy-name-shows", test_shows_fuzzy_name); gint result = g_test_run (); |