From 03365c8fbaac2c71e6bbfed731ae88d551175c2c Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Tue, 28 Dec 2021 14:58:44 +0530 Subject: abstract Mastodon API request info Mastodon API requires some info that needs to be passed during app registration and user authentication. Those info were hard coded into various functions. Introduce three variables (defvars): 1. mastodon-client-scopes 2. mastodon-client-website 3. mastodon-client-redirect-uri use them to abstract those info. Also refactor `mastodon-client--register' function in terms of these variables. --- lisp/mastodon-client.el | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index b27d434..9fb45f7 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -46,14 +46,23 @@ (defvar mastodon-client--client-details-alist nil "An alist of Client id and secrets keyed by the instance url.") +(defvar mastodon-client-scopes "read write follow" + "Scopes to pass to oauth during registration.") + +(defvar mastodon-client-website "https://codeberg.org/martianh/mastodon.el" + "Website of mastodon.el.") + +(defvar mastodon-client-redirect-uri "urn:ietf:wg:oauth:2.0:oob" + "Redirect_uri as required by oauth.") + (defun mastodon-client--register () "POST client to Mastodon." (mastodon-http--post (mastodon-http--api "apps") - '(("client_name" . "mastodon.el") - ("redirect_uris" . "urn:ietf:wg:oauth:2.0:oob") - ("scopes" . "read write follow") - ("website" . "https://github.com/jdenen/mastodon.el")) + `(("client_name" . "mastodon.el") + ("redirect_uris" . ,mastodon-client-redirect-uri) + ("scopes" . ,mastodon-client-scopes) + ("website" . ,mastodon-client-website)) nil :unauthenticated)) -- cgit v1.2.3 From cd03ff5319dc60b4aa4f6d42f57b737e002cd923 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 19:31:55 +0530 Subject: abstract plstore implementation details of getting value Introduce a new function `mastodon-client--remove-key-from-plstore' which removes "key" part from a plstore item. Refactor `mastodon-client--read' to use `mastodon-client--remove-key-from-plstore'. --- lisp/mastodon-client.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 9fb45f7..04a26ce 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -97,11 +97,17 @@ Make `mastodon-client--fetch' call to determine client values." (plstore-close plstore) client)) +(defun mastodon-client--remove-key-from-plstore (plstore) + "Remove KEY from PLSTORE." + (cdr plstore)) + +;; Actually it returns a plist with client-details if such details are +;; already stored in mastodon.plstore (defun mastodon-client--read () "Retrieve client_id and client_secret from `mastodon-client--token-file'." (let* ((plstore (plstore-open (mastodon-client--token-file))) (mastodon (plstore-get plstore (concat "mastodon-" mastodon-instance-url)))) - (cdr mastodon))) + (mastodon-client--remove-key-from-plstore mastodon))) (defun mastodon-client () "Return variable client secrets to use for `mastodon-instance-url'. -- cgit v1.2.3 From 8e36abecbb8fa0df1aba30b1100130e5e382b92b Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 19:40:59 +0530 Subject: introduce a general plstore reading function Introduce a general version of `mastodon-client--read'[1] with the name `mastodon-client--general-read'[2] as [1] is too specific. [2] can be called with with a plstore "key" to retrieve the item keyed by that KEY. --- lisp/mastodon-client.el | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 04a26ce..7a857a2 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -109,6 +109,13 @@ Make `mastodon-client--fetch' call to determine client values." (mastodon (plstore-get plstore (concat "mastodon-" mastodon-instance-url)))) (mastodon-client--remove-key-from-plstore mastodon))) +(defun mastodon-client--general-read (key) + "Retrieve the plstore item keyed by KEY. +Return plist without the KEY." + (let* ((plstore (plstore-open (mastodon-client--token-file))) + (plstore-item (plstore-get plstore key))) + (mastodon-client--remove-key-from-plstore plstore-item))) + (defun mastodon-client () "Return variable client secrets to use for `mastodon-instance-url'. -- cgit v1.2.3 From a80bd14c4c22bf5aeda7b37e6f0631a9f4912384 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 19:55:33 +0530 Subject: get account ID from user variables specified in the init file Get user account ID from the mastodon variables specified in the init file by introducing the function `mastodon-client-form-user-from-vars'. Return user account ID in the form "user@instance.com" when the values of `mastodon-active-user' and `mastodon-instance-url' are "user" and "https://instance.com" respectively. --- lisp/mastodon-client.el | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 7a857a2..f7d06a5 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -116,6 +116,15 @@ Return plist without the KEY." (plstore-item (plstore-get plstore key))) (mastodon-client--remove-key-from-plstore plstore-item))) +(defun mastodon-client-form-user-from-vars () + "Create a username from user variable. Return that username. + +Username in the form user@instance.com is formed from the +variables `mastodon-instance-url' and `mastodon-active-user'." + (concat mastodon-active-user + "@" + (url-host (url-generic-parse-url mastodon-instance-url)))) + (defun mastodon-client () "Return variable client secrets to use for `mastodon-instance-url'. -- cgit v1.2.3 From ebb4bfcee21020cec5cae08955cf2a8c57d3532c Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 20:03:01 +0530 Subject: store access token in plstore of the current user Store access token in the plstore of the current user. To do that introduce the function `mastodon-client-store-access-token' of one argument TOKEN. Also define a helper function `mastodon-client--make-user-details-plist' which creates a plist with current users details and returns it. --- lisp/mastodon-client.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index f7d06a5..1c3b2e1 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -116,6 +116,28 @@ Return plist without the KEY." (plstore-item (plstore-get plstore key))) (mastodon-client--remove-key-from-plstore plstore-item))) +(defun mastodon-client--make-user-details-plist () + "Make a plist with current user details. Return it." + `(:username ,(mastodon-client-form-user-from-vars) + :instance ,mastodon-instance-url + :client_id ,(plist-get (mastodon-client) :client_id) + :client_secret ,(plist-get (mastodon-client) :client_secret))) + +(defun mastodon-client-store-access-token (token) + "Save TOKEN as :access_token in plstore of the current user. +Return the plist after the operation." + (let* ((user-details (mastodon-client--make-user-details-plist)) + (plstore (plstore-open (mastodon-client--token-file))) + (username (plist-get user-details :username)) + (plstore-value (setq user-details + (plist-put user-details :access_token token))) + (print-length nil) + (print-level nil)) + (plstore-put plstore (concat "user-" username) plstore-value nil) + (plstore-save plstore) + (plstore-close plstore) + plstore-value)) + (defun mastodon-client-form-user-from-vars () "Create a username from user variable. Return that username. -- cgit v1.2.3 From 6305a5b809fc9185626c2cbcdf43ba4416efeb11 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 20:15:28 +0530 Subject: functions for making/checking active users Define functions for like: * mastodon-client-make-user-active: Take one argument USER-DETAILS and make it the user details of the active user. * mastodon-client--make-current-user-active: Make the user details specified in the init file the current user. * mastodon-client--current-user-active-p: Return user-details if the current user is active, otherwise return nil. --- lisp/mastodon-client.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 1c3b2e1..d622e52 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -138,6 +138,15 @@ Return the plist after the operation." (plstore-close plstore) plstore-value)) +(defun mastodon-client-make-user-active (user-details) + "USER-DETAILS is a plist consisting of user details." + (let ((plstore (plstore-open (mastodon-client--token-file))) + (print-length nil) + (print-level nil)) + (plstore-put plstore "active-user" user-details nil) + (plstore-save plstore) + (plstore-close plstore))) + (defun mastodon-client-form-user-from-vars () "Create a username from user variable. Return that username. @@ -147,6 +156,24 @@ variables `mastodon-instance-url' and `mastodon-active-user'." "@" (url-host (url-generic-parse-url mastodon-instance-url)))) +(defun mastodon-client--make-current-user-active () + "Make the user specified by user variables active user. +Return the details (plist)." + (let ((username (mastodon-client-form-user-from-vars)) + user-plist) + (when (setq user-plist + (mastodon-client--general-read (concat "user-" username))) + (mastodon-client-make-user-active user-plist)) + user-plist)) + +(defun mastodon-client--current-user-active-p () + "Return user-details if the current user is active. +Otherwise return nil." + (let ((username (mastodon-client-form-user-from-vars)) + (user-details (mastodon-client--general-read "active-user"))) + (when (and user-details + (equal (plist-get user-details :username) username)) + user-details))) (defun mastodon-client () "Return variable client secrets to use for `mastodon-instance-url'. -- cgit v1.2.3 From 639f89eb714efea5062bdbf21995033f57ea5207 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 20:23:22 +0530 Subject: make a public interface for accessing user details Introduce the function `mastodon-client-active-user' for public use which returns the details of the currently active users. It performs similar function as that of the function `mastodon-client'. --- lisp/mastodon-client.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index d622e52..e0ae34c 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -46,6 +46,9 @@ (defvar mastodon-client--client-details-alist nil "An alist of Client id and secrets keyed by the instance url.") +(defvar mastodon-client--active-user-details-plist nil + "A plist of active user details.") + (defvar mastodon-client-scopes "read write follow" "Scopes to pass to oauth during registration.") @@ -174,6 +177,20 @@ Otherwise return nil." (when (and user-details (equal (plist-get user-details :username) username)) user-details))) + +(defun mastodon-client-active-user () + "Return the details of the currently active user. + +Details is a plist." + (let ((active-user-details mastodon-client--active-user-details-plist)) + (unless active-user-details + (setq active-user-details + (or (mastodon-client--current-user-active-p) + (mastodon-client--make-current-user-active))) + (setq mastodon-client--active-user-details-plist + active-user-details)) + active-user-details)) + (defun mastodon-client () "Return variable client secrets to use for `mastodon-instance-url'. -- cgit v1.2.3 From 257209846e30e9ad7ac410e7dc7c72ecddb0b6ad Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Tue, 28 Dec 2021 18:51:39 +0530 Subject: define autoloads and defvars to silence the byte compiler --- lisp/mastodon-auth.el | 7 +++++++ lisp/mastodon-client.el | 2 ++ 2 files changed, 9 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 71f790a..72c0333 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -39,7 +39,14 @@ (autoload 'mastodon-http--api "mastodon-http") (autoload 'mastodon-http--get-json "mastodon-http") (autoload 'mastodon-http--post "mastodon-http") +(autoload 'mastodon-http-append-query-string "mastodon-http") +(autoload 'mastodon-client-store-access-token "mastodon-client") +(autoload 'mastodon-client-active-user "mastodon-client") +(autoload 'mastodon-client-make-user-active "mastodon-client") +(autoload 'mastodon-client-form-user-from-vars "mastodon-client") (defvar mastodon-instance-url) +(defvar mastodon-client-scopes) +(defvar mastodon-client-redirect-uri) (defgroup mastodon-auth nil "Authenticate with Mastodon." diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index e0ae34c..13e0150 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -32,8 +32,10 @@ (require 'plstore) (require 'json) +(require 'url) (defvar mastodon-instance-url) +(defvar mastodon-active-user) (autoload 'mastodon-http--api "mastodon-http") (autoload 'mastodon-http--post "mastodon-http") -- cgit v1.2.3 From f037340225fecb16ed7bb92c26a56e0a96c8aee6 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Tue, 28 Dec 2021 19:29:40 +0530 Subject: update copyright holder info Update Copyright holder info for files that have undergone non trivial changes. --- lisp/mastodon-auth.el | 1 + lisp/mastodon-client.el | 1 + lisp/mastodon.el | 1 + 3 files changed, 3 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 72c0333..c09dfdf 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -1,6 +1,7 @@ ;;; mastodon-auth.el --- Auth functions for mastodon.el -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 13e0150..c577fec 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -1,6 +1,7 @@ ;;; mastodon-client.el --- Client functions for mastodon.el -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 2758f9d..d22c842 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -1,6 +1,7 @@ ;;; mastodon.el --- Client for Mastodon -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 -- cgit v1.2.3 From 0af5b491d14d521c03ebc48d82608afd65166e90 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Wed, 23 Feb 2022 14:24:37 +0530 Subject: change '-' to '--' in between function and namespace names mastodon.el currently follows the convention where all function names should have two dashes (not one dash) in between function and namespace names. Update all function names to follow this convention. See issue #205 and pull request #255 --- lisp/mastodon-auth.el | 20 ++++++++++---------- lisp/mastodon-client.el | 16 ++++++++-------- lisp/mastodon-http.el | 2 +- test/mastodon-auth-tests.el | 4 ++-- test/mastodon-client-tests.el | 16 ++++++++-------- 5 files changed, 29 insertions(+), 29 deletions(-) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index c09dfdf..2540598 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -40,11 +40,11 @@ (autoload 'mastodon-http--api "mastodon-http") (autoload 'mastodon-http--get-json "mastodon-http") (autoload 'mastodon-http--post "mastodon-http") -(autoload 'mastodon-http-append-query-string "mastodon-http") -(autoload 'mastodon-client-store-access-token "mastodon-client") -(autoload 'mastodon-client-active-user "mastodon-client") -(autoload 'mastodon-client-make-user-active "mastodon-client") -(autoload 'mastodon-client-form-user-from-vars "mastodon-client") +(autoload 'mastodon-http--append-query-string "mastodon-http") +(autoload 'mastodon-client--store-access-token "mastodon-client") +(autoload 'mastodon-client--active-user "mastodon-client") +(autoload 'mastodon-client--make-user-active "mastodon-client") +(autoload 'mastodon-client--form-user-from-vars "mastodon-client") (defvar mastodon-instance-url) (defvar mastodon-client-scopes) (defvar mastodon-client-redirect-uri) @@ -71,7 +71,7 @@ if you are happy with unencryped storage use e.g. \"~/authinfo\"." (defun mastodon-auth--get-browser-login-url () "Return properly formed browser login url." - (mastodon-http-append-query-string + (mastodon-http--append-query-string (concat mastodon-instance-url "/oauth/authorize/") `(("response_type" "code") ("redirect_uri" ,mastodon-client-redirect-uri) @@ -127,11 +127,11 @@ Generate/save token if none known yet." ;; initialised already. (alist-get mastodon-instance-url mastodon-auth--token-alist nil nil 'equal)) - ((plist-get (mastodon-client-active-user) :access_token) + ((plist-get (mastodon-client--active-user) :access_token) ;; user variables needs to initialised by reading from ;; plstore. (push (cons mastodon-instance-url - (plist-get (mastodon-client-active-user) :access_token)) + (plist-get (mastodon-client--active-user) :access_token)) mastodon-auth--token-alist) (alist-get mastodon-instance-url mastodon-auth--token-alist nil nil 'equal)) @@ -149,8 +149,8 @@ Handle any errors from the server." (pcase response ((and (let token (plist-get response :access_token)) (guard token)) - (mastodon-client-make-user-active - (mastodon-client-store-access-token token)) + (mastodon-client--make-user-active + (mastodon-client--store-access-token token)) (cdar (push (cons mastodon-instance-url token) mastodon-auth--token-alist))) diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index c577fec..80338b1 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -124,12 +124,12 @@ Return plist without the KEY." (defun mastodon-client--make-user-details-plist () "Make a plist with current user details. Return it." - `(:username ,(mastodon-client-form-user-from-vars) + `(:username ,(mastodon-client--form-user-from-vars) :instance ,mastodon-instance-url :client_id ,(plist-get (mastodon-client) :client_id) :client_secret ,(plist-get (mastodon-client) :client_secret))) -(defun mastodon-client-store-access-token (token) +(defun mastodon-client--store-access-token (token) "Save TOKEN as :access_token in plstore of the current user. Return the plist after the operation." (let* ((user-details (mastodon-client--make-user-details-plist)) @@ -144,7 +144,7 @@ Return the plist after the operation." (plstore-close plstore) plstore-value)) -(defun mastodon-client-make-user-active (user-details) +(defun mastodon-client--make-user-active (user-details) "USER-DETAILS is a plist consisting of user details." (let ((plstore (plstore-open (mastodon-client--token-file))) (print-length nil) @@ -153,7 +153,7 @@ Return the plist after the operation." (plstore-save plstore) (plstore-close plstore))) -(defun mastodon-client-form-user-from-vars () +(defun mastodon-client--form-user-from-vars () "Create a username from user variable. Return that username. Username in the form user@instance.com is formed from the @@ -165,23 +165,23 @@ variables `mastodon-instance-url' and `mastodon-active-user'." (defun mastodon-client--make-current-user-active () "Make the user specified by user variables active user. Return the details (plist)." - (let ((username (mastodon-client-form-user-from-vars)) + (let ((username (mastodon-client--form-user-from-vars)) user-plist) (when (setq user-plist (mastodon-client--general-read (concat "user-" username))) - (mastodon-client-make-user-active user-plist)) + (mastodon-client--make-user-active user-plist)) user-plist)) (defun mastodon-client--current-user-active-p () "Return user-details if the current user is active. Otherwise return nil." - (let ((username (mastodon-client-form-user-from-vars)) + (let ((username (mastodon-client--form-user-from-vars)) (user-details (mastodon-client--general-read "active-user"))) (when (and user-details (equal (plist-get user-details :username) username)) user-details))) -(defun mastodon-client-active-user () +(defun mastodon-client--active-user () "Return the details of the currently active user. Details is a plist." diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 8e96b39..05c9d2e 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -157,7 +157,7 @@ Pass response buffer to CALLBACK function." (with-temp-buffer (mastodon-http--url-retrieve-synchronously url)))) -(defun mastodon-http-append-query-string (url params) +(defun mastodon-http--append-query-string (url params) "Append PARAMS to URL as query strings and return it. PARAMS should be an alist as required `url-build-query-string'." diff --git a/test/mastodon-auth-tests.el b/test/mastodon-auth-tests.el index 3ff745f..3bf65b2 100644 --- a/test/mastodon-auth-tests.el +++ b/test/mastodon-auth-tests.el @@ -56,8 +56,8 @@ (mastodon-auth--token-alist nil)) (with-mock (mock (mastodon-auth--get-token) => '(:access_token "foobaz")) - (mock (mastodon-client-store-access-token "foobaz")) - (stub mastodon-client-make-user-active) + (mock (mastodon-client--store-access-token "foobaz")) + (stub mastodon-client--make-user-active) (should (string= (mastodon-auth--access-token) "foobaz")) diff --git a/test/mastodon-client-tests.el b/test/mastodon-client-tests.el index c2ec50c..b302ed6 100644 --- a/test/mastodon-client-tests.el +++ b/test/mastodon-client-tests.el @@ -122,11 +122,11 @@ (should (equal mastodon-client--client-details-alist '(("http://mastodon.example" :client_id "foo" :client_secret "baz"))))))) -(ert-deftest mastodon-client-form-user-from-vars () +(ert-deftest mastodon-client--form-user-from-vars () (let ((mastodon-active-user "test9000") (mastodon-instance-url "https://mastodon.example")) (should - (equal (mastodon-client-form-user-from-vars) + (equal (mastodon-client--form-user-from-vars) "test9000@mastodon.example")))) (ert-deftest mastodon-client--current-user-active-p () @@ -142,7 +142,7 @@ (mock (mastodon-client--general-read "active-user") => '(:username "user@other.example" :client_id "id1")) (should (null (mastodon-client--current-user-active-p)))))) -(ert-deftest mastodon-client-store-access-token () +(ert-deftest mastodon-client--store-access-token () (let ((mastodon-instance-url "https://mastodon.example") (mastodon-active-user "test8000") (user-details @@ -150,14 +150,14 @@ :instance "https://mastodon.example" :client_id "id" :client_secret "secret" :access_token "token"))) - ;; test if mastodon-client-store-access-token /returns/ right + ;; 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") + (should (equal (mastodon-client--store-access-token "token") user-details))) - ;; test if mastodon-client-store-access-token /stores/ right value + ;; 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 @@ -165,10 +165,10 @@ user-details))) (delete-file "stubfile.plstore"))) -(ert-deftest mastodon-client-make-user-active () +(ert-deftest mastodon-client--make-user-active () (let ((user-details '(:username "test@mastodon.example"))) (with-mock (mock (mastodon-client--token-file) => "stubfile.plstore") - (mastodon-client-make-user-active user-details) + (mastodon-client--make-user-active user-details) (should (equal (mastodon-client--general-read "active-user") user-details))))) -- cgit v1.2.3