restore test for 'replacements'
and add description in the README
This commit is contained in:
parent
09046c0dee
commit
560148efda
4 changed files with 39 additions and 18 deletions
|
@ -67,8 +67,12 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
|
||||||
;; optional keyword filter regexes
|
;; optional keyword filter regexes
|
||||||
;; any posts not matching the regexes will be filtered out
|
;; any posts not matching the regexes will be filtered out
|
||||||
:keyword-filters [".*clojure.*"]
|
:keyword-filters [".*clojure.*"]
|
||||||
;; TODO: Description & example missing here
|
;; optional replacements
|
||||||
:replacements nil}
|
;; When the strings on the left side of this map are encountered in the source,
|
||||||
|
;; they are replaced with the string on the right side of the map:
|
||||||
|
:replacements {
|
||||||
|
"@openSUSE" "@opensuse@fosstodon.org",
|
||||||
|
"@conservancy" "@conservancy@mastodon.technology"}}
|
||||||
|
|
||||||
{:source {:source-type :rss
|
{:source {:source-type :rss
|
||||||
;; add RSS config to follow feeds
|
;; add RSS config to follow feeds
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#!/usr/bin/env lumo
|
(ns mastodon-bot.core-test
|
||||||
|
|
||||||
(ns mastodon-bot.core_test
|
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :refer-macros [deftest is testing run-tests]]
|
[cljs.test :refer-macros [deftest is testing run-tests]]
|
||||||
[cljs.reader :as edn]
|
[cljs.reader :as edn]
|
||||||
|
@ -25,14 +23,3 @@
|
||||||
;; "Daar is 'ie dan! SPAMSPAMSPAM editie 2! Met een samenvatting van wat er in deze eerste twee maanden van 2020 gebeurd en gedaan is binnen @hack42. Lees het via: \nhttps://t.co/O1YzlWTFU3 #hackerspace #nieuws #arnhem #nuarnhem"
|
;; "Daar is 'ie dan! SPAMSPAMSPAM editie 2! Met een samenvatting van wat er in deze eerste twee maanden van 2020 gebeurd en gedaan is binnen @hack42. Lees het via: \nhttps://t.co/O1YzlWTFU3 #hackerspace #nieuws #arnhem #nuarnhem"
|
||||||
;; (:text (core/parse-tweet (readfile "testdata/twitter/normal-tweet.edn")))
|
;; (:text (core/parse-tweet (readfile "testdata/twitter/normal-tweet.edn")))
|
||||||
;; )))
|
;; )))
|
||||||
|
|
||||||
;; (deftest test-replacements
|
|
||||||
;; (is (=
|
|
||||||
;; "💠 Check out what has been going on during March in the world of @ReproBuilds! 💠 https://t.co/k6NsSO115z @opensuse@fosstodon.org @conservancy@mastodon.technology @PrototypeFund@mastodon.social @debian@fosstodon.org "
|
|
||||||
;; (:text (core/perform-replacements (core/parse-tweet (readfile "testdata/twitter/tweet-mentions.edn"))))
|
|
||||||
;; )))
|
|
||||||
|
|
||||||
(cljs.test/run-tests)
|
|
||||||
|
|
||||||
; Don't run core's -main when testing
|
|
||||||
(set! *main-cli-fn* ())
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :refer-macros [deftest is testing run-tests]]
|
[cljs.test :refer-macros [deftest is testing run-tests]]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
[cljs.reader :as edn]
|
||||||
|
["fs" :as fs]
|
||||||
|
[mastodon-bot.core :as core]
|
||||||
|
[mastodon-bot.twitter-api :as twitter]
|
||||||
[mastodon-bot.transform :as sut]
|
[mastodon-bot.transform :as sut]
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -24,3 +28,14 @@
|
||||||
:resolve-urls? true
|
:resolve-urls? true
|
||||||
:content-filters [".*bannedsite.*"]
|
:content-filters [".*bannedsite.*"]
|
||||||
:keyword-filters [".*"]}])))
|
:keyword-filters [".*"]}])))
|
||||||
|
|
||||||
|
(defn readfile [filename]
|
||||||
|
(-> filename (fs/readFileSync #js {:encoding "UTF-8"}) edn/read-string))
|
||||||
|
|
||||||
|
(def testconfig (readfile "test.edn"))
|
||||||
|
|
||||||
|
(deftest test-replacements
|
||||||
|
(is (=
|
||||||
|
"💠 Check out what has been going on during March in the world of @ReproBuilds! 💠 https://t.co/k6NsSO115z @opensuse@fosstodon.org @conservancy@mastodon.technology @PrototypeFund@mastodon.social @debian@fosstodon.org "
|
||||||
|
(:text (sut/perform-replacements (first (:transform testconfig)) (twitter/parse-tweet (readfile "testdata/twitter/tweet-mentions.edn"))))
|
||||||
|
)))
|
19
test.edn
19
test.edn
|
@ -47,8 +47,23 @@
|
||||||
;; optional keyword filter regexes
|
;; optional keyword filter regexes
|
||||||
;; any posts not matching the regexes will be filtered out
|
;; any posts not matching the regexes will be filtered out
|
||||||
:keyword-filters [".*clojure.*"]
|
:keyword-filters [".*clojure.*"]
|
||||||
;; TODO: Description & example missing here
|
;; optional replacements
|
||||||
:replacements nil}
|
;; When the strings on the left side of this map are encountered in the source,
|
||||||
|
;; they are replaced with the string on the right side of the map:
|
||||||
|
:replacements {
|
||||||
|
"@openSUSE " "@opensuse@fosstodon.org ",
|
||||||
|
"@archlinux " "",
|
||||||
|
"@lolamby " "",
|
||||||
|
"@conservancy " "@conservancy@mastodon.technology ",
|
||||||
|
"@prototypefund " "@PrototypeFund@mastodon.social ",
|
||||||
|
"@coreboot_org " "",
|
||||||
|
"@OpenTechFund " "",
|
||||||
|
"@OpenWrtSummit " "",
|
||||||
|
"@OpenMirage " "",
|
||||||
|
"@debian " "@debian@fosstodon.org ",
|
||||||
|
"@nixos_org " "",
|
||||||
|
"@lwnnet " "",
|
||||||
|
"@guixhpc" ""}}
|
||||||
|
|
||||||
{:source {:source-type :rss
|
{:source {:source-type :rss
|
||||||
;; add RSS config to follow feeds
|
;; add RSS config to follow feeds
|
||||||
|
|
Reference in a new issue