From 76bfce36a4808e71aec27fdc2f7f8cef8462500f Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Fri, 23 Jan 2015 23:41:13 -0200 Subject: Add tests for sx-request-get-... --- test/test-api.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/test-api.el') diff --git a/test/test-api.el b/test/test-api.el index b7d5dbb..30590d7 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -14,3 +14,11 @@ (ert-deftest test-method-get-all () "Tests sx-method interface to `sx-request-all-items'" (should (< 250 (length (sx-method-call 'sites :get-all t))))) + +(ert-deftest request-get () + (should (sx-request-get-url "http://google.com")) + (should-error (sx-request-get-url "http://github.com/Bruce-Connor/does-not-exist")) + (should-error (sx-request-get-data "tags/emacs-does-not-exist")) + (let ((emacs-tags (length (sx-request-get-data 'tags/emacs)))) + (should (> emacs-tags 450)) + (should (not (cl-remove-if #'stringp emacs-tags))))) -- cgit v1.2.3 From a7a83411ccf68114847112bf27dced3d833cd524 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 24 Jan 2015 00:52:03 -0200 Subject: Test downloading image. --- test/test-api.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'test/test-api.el') diff --git a/test/test-api.el b/test/test-api.el index 30590d7..f7f54c1 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -21,4 +21,10 @@ (should-error (sx-request-get-data "tags/emacs-does-not-exist")) (let ((emacs-tags (length (sx-request-get-data 'tags/emacs)))) (should (> emacs-tags 450)) - (should (not (cl-remove-if #'stringp emacs-tags))))) + (should (not (cl-remove-if #'stringp emacs-tags)))) + (should + ;; If image is not recognized, this returns nil. + (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png") + 'imagemagick t + :width (min sx-question-mode-image-max-width + (window-body-width nil 'pixel))))) -- cgit v1.2.3 From 458231a11d0d54f8d7011addd9246661898cb2e0 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Sat, 24 Jan 2015 01:58:32 -0200 Subject: Fix and reorganize tests --- test/test-api.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/test-api.el') diff --git a/test/test-api.el b/test/test-api.el index f7f54c1..0715a2e 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -15,16 +15,18 @@ "Tests sx-method interface to `sx-request-all-items'" (should (< 250 (length (sx-method-call 'sites :get-all t))))) -(ert-deftest request-get () +(ert-deftest request-get-url () (should (sx-request-get-url "http://google.com")) (should-error (sx-request-get-url "http://github.com/Bruce-Connor/does-not-exist")) - (should-error (sx-request-get-data "tags/emacs-does-not-exist")) - (let ((emacs-tags (length (sx-request-get-data 'tags/emacs)))) - (should (> emacs-tags 450)) - (should (not (cl-remove-if #'stringp emacs-tags)))) (should ;; If image is not recognized, this returns nil. (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png") 'imagemagick t :width (min sx-question-mode-image-max-width (window-body-width nil 'pixel))))) + +(ert-deftest request-get-data () + (should-error (sx-request-get-data "tags/emacs-does-not-exist")) + (let ((emacs-tags (sx-request-get-data 'tags/emacs))) + (should (> (length emacs-tags) 450)) + (should (not (cl-remove-if #'stringp emacs-tags))))) -- cgit v1.2.3 From 75c4a7d4e02e81c42a4914e2b798f60415a3b505 Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 26 Jan 2015 15:28:19 -0200 Subject: Check image-type-available-p in the tests --- test/test-api.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'test/test-api.el') diff --git a/test/test-api.el b/test/test-api.el index 0715a2e..faf2e0a 100644 --- a/test/test-api.el +++ b/test/test-api.el @@ -18,12 +18,19 @@ (ert-deftest request-get-url () (should (sx-request-get-url "http://google.com")) (should-error (sx-request-get-url "http://github.com/Bruce-Connor/does-not-exist")) - (should - ;; If image is not recognized, this returns nil. - (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png") - 'imagemagick t - :width (min sx-question-mode-image-max-width - (window-body-width nil 'pixel))))) + (when sx-question-mode-use-images + (should + ;; If image is not recognized, this returns nil. + (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png") + 'imagemagick t + :width sx-question-mode-image-max-width))) + ;; In case imagemacgick is not available, let's try png so we at + ;; least test the function. + (when (image-type-available-p 'png) + (should + (create-image (sx-request-get-url "https://raw.githubusercontent.com/vermiculus/sx.el/master/list-and-question.png") + 'png t + :width sx-question-mode-image-max-width)))) (ert-deftest request-get-data () (should-error (sx-request-get-data "tags/emacs-does-not-exist")) -- cgit v1.2.3