[discident-glib] test: Add a test for Amazon EAN lookups
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [discident-glib] test: Add a test for Amazon EAN lookups
- Date: Mon, 21 Dec 2015 22:13:58 +0000 (UTC)
commit bc385e81ddc9e776ca3754c454a436010038d63b
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 21 20:33:17 2015 +0100
test: Add a test for Amazon EAN lookups
discident-glib/test-diglib.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/discident-glib/test-diglib.c b/discident-glib/test-diglib.c
index b57c6ba..7b4b1b9 100644
--- a/discident-glib/test-diglib.c
+++ b/discident-glib/test-diglib.c
@@ -20,6 +20,8 @@ static char *associate_tag = NULL;
static guint num_queries = 0;
static GMainLoop *loop = NULL;
+static GHashTable *create_params (void);
+
static void
test_hash (void)
{
@@ -259,6 +261,44 @@ test_ean_fail (void)
}
static void
+test_ean_amz (void)
+{
+ GHashTable *params;
+ DiscidentEan *ean;
+ gboolean ret;
+ char *title, *img_url;
+ GError *error = NULL;
+
+ params = create_params ();
+ if (!params) {
+ g_test_skip ("Missing Amazon configuration");
+ return;
+ }
+
+ ean = discident_ean_new_full ("amz-fr", params);
+
+ /* Ghost in the shell */
+ ret = discident_ean_lookup_sync (ean, "3388330031138", &title, &img_url, &error);
+ if (ret == FALSE)
+ g_assert_no_error (error);
+ g_assert_cmpstr ("Ghost in the shell", ==, title);
+ g_assert (img_url != NULL);
+ g_free (title);
+ g_free (img_url);
+
+ /* The Little Book of Stress: Calm is for Wimps, Get Real, Get Stressed */
+ ret = discident_ean_lookup_sync (ean, "9780091865856", &title, &img_url, &error);
+ if (ret == FALSE)
+ g_assert_no_error (error);
+ g_assert_cmpstr ("The Little Book Of Stress", ==, title);
+ g_assert (img_url != NULL);
+ g_free (title);
+ g_free (img_url);
+
+ g_object_unref (ean);
+}
+
+static void
discident_title_print (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -510,6 +550,7 @@ int main (int argc, char **argv)
g_test_add_func ("/discident/amz-parse", test_amz_parse);
g_test_add_func ("/discident/ean", test_ean);
g_test_add_func ("/discident/ean_fail", test_ean_fail);
+ g_test_add_func ("/discident/ean-amz", test_ean_amz);
g_test_add_func ("/discident/hash", test_hash);
g_test_add_func ("/discident/file_list", test_file_list);
g_test_add_func ("/discident/json", test_json);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]