[grilo-plugins] tests: Port lastfm-albumart test to test spotify-cover
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] tests: Port lastfm-albumart test to test spotify-cover
- Date: Mon, 14 Sep 2015 16:20:02 +0000 (UTC)
commit 6dc67fa5854eb5717714805a1736837316490b9f
Author: Bastien Nocera <hadess hadess net>
Date: Thu Sep 10 17:12:35 2015 +0200
tests: Port lastfm-albumart test to test spotify-cover
Repurpose the tests to cover the Spotify cover plugin instead of the
last.fm one, as the last.fm plugin now requires GOA to be instantiated.
https://bugzilla.gnome.org/show_bug.cgi?id=700276
configure.ac | 2 +-
tests/Makefile.am | 8 +--
tests/lastfm-albumart/Makefile.am | 35 --------
tests/lastfm-albumart/data/network-data.ini | 11 ---
.../data/resolve-good-found-default.data | 14 ----
tests/lastfm-albumart/data/resolve-good-found.data | 82 --------------------
tests/spotify-cover/Makefile.am | 36 +++++++++
tests/spotify-cover/data/network-data.ini | 9 ++
tests/spotify-cover/data/resolve-bad-found.data | 11 +++
tests/spotify-cover/data/resolve-good-found.data | 35 ++++++++
.../test_spotify_cover.c} | 82 +++++---------------
11 files changed, 114 insertions(+), 211 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1e524c7..7b5d27b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1276,7 +1276,7 @@ AC_CONFIG_FILES([
tests/Makefile
tests/dleyna/Makefile
tests/dleyna/dbusmock/dleyna-server-mock.service
- tests/lastfm-albumart/Makefile
+ tests/spotify-cover/Makefile
tests/local-metadata/Makefile
tests/lua-factory/Makefile
tests/lua-factory/sources/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7a76f7f..8750acb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,16 +13,12 @@ if DLEYNA_PLUGIN
SUBDIRS += dleyna
endif
-if LASTFM_ALBUMART_PLUGIN
-SUBDIRS += lastfm-albumart
-endif
-
if LOCALMETADATA_PLUGIN
SUBDIRS += local-metadata
endif
if LUA_FACTORY_PLUGIN
-SUBDIRS += lua-factory
+SUBDIRS += lua-factory spotify-cover
endif
if TMDB_PLUGIN
@@ -39,7 +35,7 @@ endif
DIST_SUBDIRS = \
dleyna \
- lastfm-albumart\
+ spotify-cover \
local-metadata \
lua-factory \
tmdb \
diff --git a/tests/spotify-cover/Makefile.am b/tests/spotify-cover/Makefile.am
new file mode 100644
index 0000000..3cd1324
--- /dev/null
+++ b/tests/spotify-cover/Makefile.am
@@ -0,0 +1,36 @@
+#
+# Makefile.am
+#
+# Author: Juan A. Suarez Romero <jasuarez igalia com>
+#
+# Copyright (C) 2014 Igalia S.L.
+
+include $(top_srcdir)/gtester.mk
+
+TEST_PROGS += \
+ test_spotify_cover
+
+test_spotify_cover_defines = \
+ -DLUA_FACTORY_PLUGIN_PATH=\""$(abs_top_builddir)/src/lua-factory/.libs/"\" \
+ -DLUA_SOURCES_PATH=\""$(abs_top_srcdir)/src/lua-factory/sources/"\" \
+ -DSPOTIFY_COVER_DATA_PATH=\""$(abs_top_srcdir)/tests/spotify-cover/data/"\"
+
+test_spotify_cover_SOURCES = \
+ test_spotify_cover.c
+
+test_spotify_cover_LDADD = \
+ @DEPS_LIBS@
+
+test_spotify_cover_CFLAGS = \
+ @DEPS_CFLAGS@ \
+ $(test_spotify_cover_defines)
+
+# Distribute the tests data:
+dist_noinst_DATA = \
+ data/network-data.ini \
+ data/resolve-bad-found.data \
+ data/resolve-good-found.data
+
+noinst_PROGRAMS = $(TEST_PROGS)
+
+-include $(top_srcdir)/git.mk
diff --git a/tests/spotify-cover/data/network-data.ini b/tests/spotify-cover/data/network-data.ini
new file mode 100644
index 0000000..2b9b78d
--- /dev/null
+++ b/tests/spotify-cover/data/network-data.ini
@@ -0,0 +1,9 @@
+[default]
+version=1
+
+[https://api.spotify.com/v1/search?q=album:ray%20of%20light+artist:madonna&type=album&limit=1]
+data=resolve-good-found.data
+
+[https://api.spotify.com/v1/search?q=album:ray%20of%20darkness+artist:madonna&type=album&limit=1]
+data=resolve-bad-found.data
+
diff --git a/tests/spotify-cover/data/resolve-bad-found.data b/tests/spotify-cover/data/resolve-bad-found.data
new file mode 100644
index 0000000..82cf538
--- /dev/null
+++ b/tests/spotify-cover/data/resolve-bad-found.data
@@ -0,0 +1,11 @@
+{
+ "albums" : {
+ "href" :
"https://api.spotify.com/v1/search?query=album%3Aray+of+darkness+artist%3Amadonna&offset=0&limit=1&type=album",
+ "items" : [ ],
+ "limit" : 1,
+ "next" : null,
+ "offset" : 0,
+ "previous" : null,
+ "total" : 0
+ }
+}
\ No newline at end of file
diff --git a/tests/spotify-cover/data/resolve-good-found.data
b/tests/spotify-cover/data/resolve-good-found.data
new file mode 100644
index 0000000..0d3aab4
--- /dev/null
+++ b/tests/spotify-cover/data/resolve-good-found.data
@@ -0,0 +1,35 @@
+{
+ "albums" : {
+ "href" :
"https://api.spotify.com/v1/search?query=album%3Aray+of+light+artist%3Amadonna&offset=0&limit=1&type=album",
+ "items" : [ {
+ "album_type" : "album",
+ "available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA", "CH", "CL", "CO", "CR",
"CY", "CZ", "DE", "DK", "DO", "EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK", "HN", "HU", "IE", "IS",
"IT", "LI", "LT", "LU", "LV", "MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA", "PE", "PH", "PL", "PT",
"PY", "RO", "SE", "SG", "SI", "SK", "SV", "TR", "TW", "US", "UY" ],
+ "external_urls" : {
+ "spotify" : "https://open.spotify.com/album/6cuNyrSmRjBeekioLdLkvI"
+ },
+ "href" : "https://api.spotify.com/v1/albums/6cuNyrSmRjBeekioLdLkvI",
+ "id" : "6cuNyrSmRjBeekioLdLkvI",
+ "images" : [ {
+ "height" : 640,
+ "url" : "https://i.scdn.co/image/246565c45ea4085d5b3889619fa1112ec6d42eed",
+ "width" : 640
+ }, {
+ "height" : 300,
+ "url" : "https://i.scdn.co/image/f89849d36862a9dd2807be1d6d07eb0159c26673",
+ "width" : 300
+ }, {
+ "height" : 64,
+ "url" : "https://i.scdn.co/image/cfa2d86696ff7cd8ea862f50ed05d086f1d66521",
+ "width" : 64
+ } ],
+ "name" : "Ray Of Light (U.S. Version)",
+ "type" : "album",
+ "uri" : "spotify:album:6cuNyrSmRjBeekioLdLkvI"
+ } ],
+ "limit" : 1,
+ "next" : null,
+ "offset" : 0,
+ "previous" : null,
+ "total" : 1
+ }
+}
\ No newline at end of file
diff --git a/tests/lastfm-albumart/test_lastfm_albumart.c b/tests/spotify-cover/test_spotify_cover.c
similarity index 72%
rename from tests/lastfm-albumart/test_lastfm_albumart.c
rename to tests/spotify-cover/test_spotify_cover.c
index 0966068..f907543 100644
--- a/tests/lastfm-albumart/test_lastfm_albumart.c
+++ b/tests/spotify-cover/test_spotify_cover.c
@@ -22,7 +22,7 @@
#include <grilo.h>
-#define LASTFM_ALBUMART_ID "grl-lastfm-albumart"
+#define LASTFM_ALBUMART_ID "grl-spotify-cover"
static GrlMedia *
build_media_audio (const gchar *artist,
@@ -156,7 +156,7 @@ test_resolve_good_found (void)
source = grl_registry_lookup_source (registry, LASTFM_ALBUMART_ID);
g_assert (source);
- media = build_media_audio ("madonna", "frozen");
+ media = build_media_audio ("madonna", "ray of light");
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
@@ -169,58 +169,16 @@ test_resolve_good_found (void)
/* We should get 5 thumbnails */
expected_n_thumbnails = grl_data_length (GRL_DATA (media), GRL_METADATA_KEY_THUMBNAIL);
- g_assert_cmpuint (expected_n_thumbnails, ==, 5);
+ g_assert_cmpuint (expected_n_thumbnails, ==, 3);
g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 0),
==,
- "http://userserve-ak.last.fm/serve/500/76737256.png");
+ "https://i.scdn.co/image/246565c45ea4085d5b3889619fa1112ec6d42eed");
g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 1),
==,
- "http://userserve-ak.last.fm/serve/252/76737256.png");
+ "https://i.scdn.co/image/f89849d36862a9dd2807be1d6d07eb0159c26673");
g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 2),
==,
- "http://userserve-ak.last.fm/serve/126/76737256.png");
- g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 3),
- ==,
- "http://userserve-ak.last.fm/serve/64s/76737256.png");
- g_assert_cmpstr (grl_media_get_thumbnail_nth (media, 4),
- ==,
- "http://userserve-ak.last.fm/serve/34s/76737256.png");
-
- g_list_free (keys);
- g_object_unref (options);
- g_object_unref (media);
-}
-
-static void
-test_resolve_good_found_default (void)
-{
- GError *error = NULL;
- GList *keys;
- GrlMedia *media;
- GrlOperationOptions *options;
- GrlRegistry *registry;
- GrlSource *source;
- guint expected_n_thumbnails;
-
- registry = grl_registry_get_default ();
- source = grl_registry_lookup_source (registry, LASTFM_ALBUMART_ID);
- g_assert (source);
-
- media = build_media_audio ("madonna", "frocen");
-
- keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
-
- options = grl_operation_options_new (NULL);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
-
- grl_source_resolve_sync (source, media, keys, options, &error);
-
- g_assert_no_error (error);
-
- /* We should get 0 thumbnails */
- expected_n_thumbnails = grl_data_length (GRL_DATA (media), GRL_METADATA_KEY_THUMBNAIL);
- g_assert_cmpuint (expected_n_thumbnails, ==, 0);
- g_assert (!grl_media_get_thumbnail (media));
+ "https://i.scdn.co/image/cfa2d86696ff7cd8ea862f50ed05d086f1d66521");
g_list_free (keys);
g_object_unref (options);
@@ -242,12 +200,12 @@ test_resolve_good_not_found (void)
source = grl_registry_lookup_source (registry, LASTFM_ALBUMART_ID);
g_assert (source);
- media = build_media_audio ("madonna", "unknown");
+ media = build_media_audio ("madonna", "ray of darkness");
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
options = grl_operation_options_new (NULL);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_NORMAL);
grl_source_resolve_sync (source, media, keys, options, &error);
@@ -283,7 +241,7 @@ test_resolve_missing_key (void)
keys = grl_metadata_key_list_new (GRL_METADATA_KEY_THUMBNAIL, NULL);
options = grl_operation_options_new (NULL);
- grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
+ grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_NORMAL);
grl_source_resolve_sync (source, media, keys, options, &error);
@@ -302,9 +260,10 @@ test_resolve_missing_key (void)
int
main(int argc, char **argv)
{
- g_setenv ("GRL_PLUGIN_PATH", LASTFM_ALBUMART_PLUGIN_PATH, TRUE);
- g_setenv ("GRL_PLUGIN_LIST", LASTFM_ALBUMART_ID, TRUE);
- g_setenv ("GRL_NET_MOCKED", LASTFM_ALBUMART_DATA_PATH "network-data.ini", TRUE);
+ g_setenv ("GRL_PLUGIN_PATH", LUA_FACTORY_PLUGIN_PATH, TRUE);
+ g_setenv ("GRL_LUA_SOURCES_PATH", LUA_SOURCES_PATH, TRUE);
+ g_setenv ("GRL_PLUGIN_LIST", "grl-lua-factory", TRUE);
+ g_setenv ("GRL_NET_MOCKED", SPOTIFY_COVER_DATA_PATH "network-data.ini", TRUE);
grl_init (&argc, &argv);
g_test_init (&argc, &argv, NULL);
@@ -315,14 +274,13 @@ main(int argc, char **argv)
test_setup ();
- g_test_add_func ("/lastfm-albumart/may-resolve/good", test_may_resolve_good);
- g_test_add_func ("/lastfm-albumart/may-resolve/wrong-key", test_may_resolve_wrong_key);
- g_test_add_func ("/lastfm-albumart/may-resolve/missing-key", test_may_resolve_missing_key);
- g_test_add_func ("/lastfm-albumart/may-resolve/missing-media", test_may_resolve_missing_media);
- g_test_add_func ("/lastfm-albumart/resolve/good-found", test_resolve_good_found);
- g_test_add_func ("/lastfm-albumart/resolve/good-found-default", test_resolve_good_found_default);
- g_test_add_func ("/lastfm-albumart/resolve/good-not-found", test_resolve_good_not_found);
- g_test_add_func ("/lastfm-albumart/resolve/missing-key", test_resolve_missing_key);
+ g_test_add_func ("/spotify-cover/may-resolve/good", test_may_resolve_good);
+ g_test_add_func ("/spotify-cover/may-resolve/wrong-key", test_may_resolve_wrong_key);
+ g_test_add_func ("/spotify-cover/may-resolve/missing-key", test_may_resolve_missing_key);
+ g_test_add_func ("/spotify-cover/may-resolve/missing-media", test_may_resolve_missing_media);
+ g_test_add_func ("/spotify-cover/resolve/good-found", test_resolve_good_found);
+ g_test_add_func ("/spotify-cover/resolve/good-not-found", test_resolve_good_not_found);
+ g_test_add_func ("/spotify-cover/resolve/missing-key", test_resolve_missing_key);
gint result = g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]