branch: elpa/mastodon
commit dc43b80730423b3d6a2115e2cb42300dc2c09c11
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
reindent client-tests.el
---
test/mastodon-client-tests.el | 114 +++++++++++++++++++++---------------------
1 file changed, 57 insertions(+), 57 deletions(-)
diff --git a/test/mastodon-client-tests.el b/test/mastodon-client-tests.el
index 7aee5a1657..97ac11ce5b 100644
--- a/test/mastodon-client-tests.el
+++ b/test/mastodon-client-tests.el
@@ -24,10 +24,10 @@
"Should return client registration JSON."
(with-temp-buffer
(with-mock
- (mock (mastodon-client--register) => (progn
- (insert "\n\n{\"foo\":\"bar\"}")
- (current-buffer)))
- (should (equal (mastodon-client--fetch) '(:foo "bar"))))))
+ (mock (mastodon-client--register) => (progn
+ (insert "\n\n{\"foo\":\"bar\"}")
+ (current-buffer)))
+ (should (equal (mastodon-client--fetch) '(:foo "bar"))))))
;; FIXME: broken by new encrypted plstore flow
;; (asks for gpg passphrase)
@@ -37,9 +37,9 @@
(let ((mastodon-instance-url "http://mastodon.example")
(plist '(:client_id "id" :client_secret "secret")))
(with-mock
- (mock (mastodon-client--token-file) => "stubfile.plstore")
- (mock (mastodon-client--fetch) => plist)
- (should (equal (mastodon-client--store) plist)))
+ (mock (mastodon-client--token-file) => "stubfile.plstore")
+ (mock (mastodon-client--fetch) => plist)
+ (should (equal (mastodon-client--store) plist)))
(let* ((plstore (plstore-open "stubfile.plstore"))
(client (mastodon-client--remove-key-from-plstore
(plstore-get plstore "mastodon-http://mastodon.example"))))
@@ -52,43 +52,43 @@
"Should return mastodon client from `mastodon-token-file' if it exists."
(let ((mastodon-instance-url "http://mastodon.example"))
(with-mock
- (mock (mastodon-client--token-file) => "fixture/client.plstore")
- (should (equal (mastodon-client--read)
- '(:client_id "id2" :client_secret "secret2"))))))
+ (mock (mastodon-client--token-file) => "fixture/client.plstore")
+ (should (equal (mastodon-client--read)
+ '(:client_id "id2" :client_secret "secret2"))))))
(ert-deftest mastodon-client--general-read-finds-match ()
(with-mock
- (mock (mastodon-client--token-file) => "fixture/client.plstore")
- (should (equal (mastodon-client--general-read
"[email protected]")
- '(:username "[email protected]"
- :instance "http://mastodon.example"
- :client_id "id2" :client_secret "secret2"
- :access_token "token2")))))
+ (mock (mastodon-client--token-file) => "fixture/client.plstore")
+ (should (equal (mastodon-client--general-read
"[email protected]")
+ '(:username "[email protected]"
+ :instance "http://mastodon.example"
+ :client_id "id2" :client_secret "secret2"
+ :access_token "token2")))))
(ert-deftest mastodon-client--general-read-finds-no-match ()
(with-mock
- (mock (mastodon-client--token-file) => "fixture/client.plstore")
- (should (equal (mastodon-client--general-read "nonexistant-key")
- nil))))
+ (mock (mastodon-client--token-file) => "fixture/client.plstore")
+ (should (equal (mastodon-client--general-read "nonexistant-key")
+ nil))))
(ert-deftest mastodon-client--general-read-empty-store ()
(with-mock
- (mock (mastodon-client--token-file) => "fixture/empty.plstore")
- (should (equal (mastodon-client--general-read "something")
- nil))))
+ (mock (mastodon-client--token-file) => "fixture/empty.plstore")
+ (should (equal (mastodon-client--general-read "something")
+ nil))))
(ert-deftest mastodon-client--read-finds-no-match ()
"Should return mastodon client from `mastodon-token-file' if it exists."
(let ((mastodon-instance-url "http://mastodon.social"))
(with-mock
- (mock (mastodon-client--token-file) => "fixture/client.plstore")
- (should (equal (mastodon-client--read) nil)))))
+ (mock (mastodon-client--token-file) => "fixture/client.plstore")
+ (should (equal (mastodon-client--read) nil)))))
(ert-deftest mastodon-client--read-empty-store ()
"Should return nil if mastodon client is not present in the plstore."
(with-mock
- (mock (mastodon-client--token-file) => "fixture/empty.plstore")
- (should (equal (mastodon-client--read) nil))))
+ (mock (mastodon-client--token-file) => "fixture/empty.plstore")
+ (should (equal (mastodon-client--read) nil))))
(ert-deftest mastodon-client--client-set-and-matching ()
"Should return `mastondon-client' if `mastodon-client--client-details-alist'
is non-nil and instance url is included."
@@ -102,32 +102,32 @@
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist '(("http://other.example"
:wrong))))
(with-mock
- (mock (mastodon-client--read) => '(:client_id "foo" :client_secret "bar"))
- (should (equal (mastodon-client) '(:client_id "foo" :client_secret
"bar")))
- (should (equal mastodon-client--client-details-alist
- '(("http://mastodon.example" :client_id "foo"
:client_secret "bar")
- ("http://other.example" :wrong)))))))
+ (mock (mastodon-client--read) => '(:client_id "foo" :client_secret
"bar"))
+ (should (equal (mastodon-client) '(:client_id "foo" :client_secret
"bar")))
+ (should (equal mastodon-client--client-details-alist
+ '(("http://mastodon.example" :client_id "foo"
:client_secret "bar")
+ ("http://other.example" :wrong)))))))
(ert-deftest mastodon-client--client-unset ()
"Should read from `mastodon-token-file' if available."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist nil))
(with-mock
- (mock (mastodon-client--read) => '(:client_id "foo" :client_secret "bar"))
- (should (equal (mastodon-client) '(:client_id "foo" :client_secret
"bar")))
- (should (equal mastodon-client--client-details-alist
- '(("http://mastodon.example" :client_id "foo"
:client_secret "bar")))))))
+ (mock (mastodon-client--read) => '(:client_id "foo" :client_secret
"bar"))
+ (should (equal (mastodon-client) '(:client_id "foo" :client_secret
"bar")))
+ (should (equal mastodon-client--client-details-alist
+ '(("http://mastodon.example" :client_id "foo"
:client_secret "bar")))))))
(ert-deftest mastodon-client--client-unset-and-not-in-storage ()
"Should store client data in plstore if it can't be read."
(let ((mastodon-instance-url "http://mastodon.example")
(mastodon-client--client-details-alist nil))
(with-mock
- (mock (mastodon-client--read))
- (mock (mastodon-client--store) => '(:client_id "foo" :client_secret
"baz"))
- (should (equal (mastodon-client) '(:client_id "foo" :client_secret
"baz")))
- (should (equal mastodon-client--client-details-alist
- '(("http://mastodon.example" :client_id "foo"
:client_secret "baz")))))))
+ (mock (mastodon-client--read))
+ (mock (mastodon-client--store) => '(:client_id "foo" :client_secret
"baz"))
+ (should (equal (mastodon-client) '(:client_id "foo" :client_secret
"baz")))
+ (should (equal mastodon-client--client-details-alist
+ '(("http://mastodon.example" :client_id "foo"
:client_secret "baz")))))))
(ert-deftest mastodon-client--form-user-from-vars ()
(let ((mastodon-active-user "test9000")
@@ -141,13 +141,13 @@
(mastodon-instance-url "https://mastodon.example"))
;; when the current user /is/ the active user
(with-mock
- (mock (mastodon-client--general-read "active-user") => '(:username
"[email protected]" :client_id "id1"))
- (should (equal (mastodon-client--current-user-active-p)
- '(:username "[email protected]" :client_id
"id1"))))
+ (mock (mastodon-client--general-read "active-user") => '(:username
"[email protected]" :client_id "id1"))
+ (should (equal (mastodon-client--current-user-active-p)
+ '(:username "[email protected]" :client_id
"id1"))))
;; when the current user is /not/ the active user
(with-mock
- (mock (mastodon-client--general-read "active-user") => '(:username
"[email protected]" :client_id "id1"))
- (should (null (mastodon-client--current-user-active-p))))))
+ (mock (mastodon-client--general-read "active-user") => '(:username
"[email protected]" :client_id "id1"))
+ (should (null (mastodon-client--current-user-active-p))))))
;; FIXME: broken by new encrypted plstore flow
;; (asks for gpg passphrase)
@@ -164,16 +164,16 @@
;; test if mastodon-client--store-access-token /returns/ right
;; value
(with-mock
- (mock (mastodon-client) => '(:client_id "id" :client_secret "secret"))
- (mock (mastodon-client--token-file) => "stubfile.plstore")
- (should (equal (mastodon-client--store-access-token "token")
- user-details)))
+ (mock (mastodon-client) => '(:client_id "id" :client_secret "secret"))
+ (mock (mastodon-client--token-file) => "stubfile.plstore")
+ (should (equal (mastodon-client--store-access-token "token")
+ user-details)))
;; test if mastodon-client--store-access-token /stores/ right value
(with-mock
- (mock (mastodon-client--token-file) => "stubfile.plstore")
- (should (equal (mastodon-client--general-read
- "[email protected]")
- user-details)))
+ (mock (mastodon-client--token-file) => "stubfile.plstore")
+ (should (equal (mastodon-client--general-read
+ "[email protected]")
+ user-details)))
(delete-file "stubfile.plstore")))
;; FIXME: broken by new encrypted plstore flow
@@ -187,8 +187,8 @@
:username "[email protected]"))
(mastodon-auth-use-auth-source nil)) ;; FIXME: test auth source
(with-mock
- (mock (mastodon-client--token-file) => "stubfile.plstore")
- (mastodon-client--make-user-active user-details)
- (should (equal (mastodon-client--general-read "active-user")
- user-details)))
+ (mock (mastodon-client--token-file) => "stubfile.plstore")
+ (mastodon-client--make-user-active user-details)
+ (should (equal (mastodon-client--general-read "active-user")
+ user-details)))
(delete-file "stubfile.plstore")))