From e7c7da386c812f9452b072567e822077180f3dc5 Mon Sep 17 00:00:00 2001 From: Holger Dürer Date: Mon, 1 Nov 2021 15:53:37 +0100 Subject: Fix tests. These needed a bit of tender love and care to get back into passing state. - Move the auth tests to the `test` directory. No idea what it was doing in `lisp`. - Image tests are mostly broken because with later Emacsen we no longer need the `imagemagic` option on create-image. - Some method signatures have changed and mocking calls needed to follow suit. --- test/ert-helper.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'test/ert-helper.el') diff --git a/test/ert-helper.el b/test/ert-helper.el index 6979837..d3e0016 100644 --- a/test/ert-helper.el +++ b/test/ert-helper.el @@ -1,8 +1,13 @@ +(load-file "lisp/mastodon-async.el") (load-file "lisp/mastodon-http.el") -(load-file "lisp/mastodon-client.el") (load-file "lisp/mastodon-auth.el") -(load-file "lisp/mastodon-toot.el") +(load-file "lisp/mastodon-client.el") +(load-file "lisp/mastodon-discover.el") +(load-file "lisp/mastodon-inspect.el") (load-file "lisp/mastodon-media.el") -(load-file "lisp/mastodon-tl.el") (load-file "lisp/mastodon-notifications.el") +(load-file "lisp/mastodon-profile.el") +(load-file "lisp/mastodon-search.el") +(load-file "lisp/mastodon-tl.el") +(load-file "lisp/mastodon-toot.el") (load-file "lisp/mastodon.el") -- cgit v1.2.3 From 14476572dafe12454015189f67d8f29f50b25ccb Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 6 Nov 2021 14:53:24 +0100 Subject: add tests for -search.el --- test/ert-helper.el | 1 + test/mastodon-search-tests.el | 141 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 test/mastodon-search-tests.el (limited to 'test/ert-helper.el') diff --git a/test/ert-helper.el b/test/ert-helper.el index d3e0016..a6d6692 100644 --- a/test/ert-helper.el +++ b/test/ert-helper.el @@ -1,3 +1,4 @@ +(load-file "lisp/mastodon-search.el") (load-file "lisp/mastodon-async.el") (load-file "lisp/mastodon-http.el") (load-file "lisp/mastodon-auth.el") diff --git a/test/mastodon-search-tests.el b/test/mastodon-search-tests.el new file mode 100644 index 0000000..b8521f3 --- /dev/null +++ b/test/mastodon-search-tests.el @@ -0,0 +1,141 @@ + + +(defconst mastodon-search--single-account-query + '((id . "242971") + (username . "mousebot") + (acct . "mousebot") + (display_name . ": ( ) { : | : & } ; :") + (locked . t) + (bot . :json-false) + (discoverable . t) + (group . :json-false) + (created_at . "2020-04-14T00:00:00.000Z") + (note . "

poetry, writing, dmt, desertion, trash, black metal, translation, hegel, language, autonomia....

https://anarchive.mooo.com
https://pleasantlybabykid.tumblr.com/
IG: https://bibliogram.snopyta.org/u/martianhiatus
photos alt: @goosebot
git: https://git.blast.noho.st/mouse

want to trade chapbooks or zines? hmu!

he/him or they/them

") + (url . "https://todon.nl/@mousebot") + (avatar . "https://todon.nl/system/accounts/avatars/000/242/971/original/0a5e801576af597b.jpg") + (avatar_static . "https://todon.nl/system/accounts/avatars/000/242/971/original/0a5e801576af597b.jpg") + (header . "https://todon.nl/system/accounts/headers/000/242/971/original/f85f7f1048237fd4.jpg") + (header_static . "https://todon.nl/system/accounts/headers/000/242/971/original/f85f7f1048237fd4.jpg") + (followers_count . 226) + (following_count . 634) + (statuses_count . 3807) + (last_status_at . "2021-11-05") + (emojis . + []) + (fields . + [((name . "dark to") + (value . "themselves") + (verified_at)) + ((name . "its raining") + (value . "plastic") + (verified_at)) + ((name . "dis") + (value . "integration") + (verified_at)) + ((name . "ungleichzeitigkeit und") + (value . "gleichzeitigkeit, philosophisch") + (verified_at))])) + "A sample mastodon account search result (parsed json)") + +(defconst mastodon-search-test-single-tag + '((name . "TeamBringBackVisibleScrollbars") (url . "https://todon.nl/tags/TeamBringBackVisibleScrollbars") (history . [((day . "1636156800") (uses . "0") (accounts . "0")) ((day . "1636070400") (uses . "0") (accounts . "0")) ((day . "1635984000") (uses . "0") (accounts . "0")) ((day . "1635897600") (uses . "0") (accounts . "0")) ((day . "1635811200") (uses . "0") (accounts . "0")) ((day . "1635724800") (uses . "0") (accounts . "0")) ((day . "1635638400") (uses . "0") (accounts . "0"))]))) + +(defconst mastodon-search-test-single-status + '((id . "107230316503209282") + (created_at . "2021-11-06T13:19:40.628Z") + (in_reply_to_id) + (in_reply_to_account_id) + (sensitive . :json-false) + (spoiler_text . "") + (visibility . "direct") + (language . "en") + (uri . "https://todon.nl/users/mousebot/statuses/107230316503209282") + (url . "https://todon.nl/@mousebot/107230316503209282") + (replies_count . 0) + (reblogs_count . 0) + (favourites_count . 0) + (favourited . :json-false) + (reblogged . :json-false) + (muted . :json-false) + (bookmarked . :json-false) + (content . "

This is a nice test toot, for testing purposes. Thank you.

") + (reblog) + (application + (name . "mastodon.el") + (website . "https://github.com/jdenen/mastodon.el")) + (account + (id . "242971") + (username . "mousebot") + (acct . "mousebot") + (display_name . ": ( ) { : | : & } ; :") + (locked . t) + (bot . :json-false) + (discoverable . t) + (group . :json-false) + (created_at . "2020-04-14T00:00:00.000Z") + (note . "

poetry, writing, dmt, desertion, trash, black metal, translation, hegel, language, autonomia....

https://anarchive.mooo.com
https://pleasantlybabykid.tumblr.com/
IG: https://bibliogram.snopyta.org/u/martianhiatus
photos alt: @goosebot
git: https://git.blast.noho.st/mouse

want to trade chapbooks or zines? hmu!

he/him or they/them

") + (url . "https://todon.nl/@mousebot") + (avatar . "https://todon.nl/system/accounts/avatars/000/242/971/original/0a5e801576af597b.jpg") + (avatar_static . "https://todon.nl/system/accounts/avatars/000/242/971/original/0a5e801576af597b.jpg") + (header . "https://todon.nl/system/accounts/headers/000/242/971/original/f85f7f1048237fd4.jpg") + (header_static . "https://todon.nl/system/accounts/headers/000/242/971/original/f85f7f1048237fd4.jpg") + (followers_count . 226) + (following_count . 634) + (statuses_count . 3807) + (last_status_at . "2021-11-05") + (emojis . + []) + (fields . + [((name . "dark to") + (value . "themselves") + (verified_at)) + ((name . "its raining") + (value . "plastic") + (verified_at)) + ((name . "dis") + (value . "integration") + (verified_at)) + ((name . "ungleichzeitigkeit und") + (value . "gleichzeitigkeit, philosophisch") + (verified_at))])) + (media_attachments . + []) + (mentions . + [((id . "242971") + (username . "mousebot") + (url . "https://todon.nl/@mousebot") + (acct . "mousebot"))]) + (tags . + []) + (emojis . + []) + (card) + (poll))) + +(ert-deftest mastodon-search-test-get-user-info-@ () + "Should build a list from a single account for company completion." + (let ((account mastodon-search--single-account-query)) + (should (equal (mastodon-search--get-user-info-@ account) + '(": ( ) { : | : & } ; :" "@mousebot" "https://todon.nl/@mousebot"))))) + +(ert-deftest mastodon-search-test-get-user-info () + "Should build a list from a single account for company completion." + (let ((account mastodon-search--single-account-query)) + (should (equal (mastodon-search--get-user-info account) + '(": ( ) { : | : & } ; :" "mousebot" "https://todon.nl/@mousebot"))))) + +(ert-deftest mastodon-search-test-get-hashtag-info () + "Should build a list of hashtag name and URL." + (let ((tag mastodon-search-test-single-tag)) + (should (equal (mastodon-search--get-hashtag-info tag) + '("TeamBringBackVisibleScrollbars" + "https://todon.nl/tags/TeamBringBackVisibleScrollbars"))))) + +(ert-deftest mastodon-search-test-get-status-info () + "Should return a list of ID, timestamp, content, and spoiler." + (let ((status mastodon-search-test-single-status)) + (should (equal (mastodon-search--get-status-info status) + '("107230316503209282" + "2021-11-06T13:19:40.628Z" + "" + "

This is a nice test toot, for testing purposes. Thank you.

"))))) -- cgit v1.2.3