diff options
| author | eltrac <hi@eltr.ac> | 2026-10-13 15:02:58 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-10-13 16:39:43 +0800 |
| commit | e26cc530c5e51154117883894ff5779c8a8e3ba3 (patch) | |
| tree | 4f378d888b40ac7d8d4370a2e7619118de95fb7b /test | |
| parent | fdb8d750ee5ce2767d0368686200b82b880b27c1 (diff) | |
retriever, test: refactor retriever; accurate MF type matching
- microformats type inferring is more accurate
- before: check if microformats h-entry has a type key (:like-of,
:in-reply-to...)
- now: check if such key's value equals to target URL, so it makes
sure this like/reply/repost/rsvp is sent to this target
- use ring.util.http-response to simplify response
- `?mftype=` filter no longer depends on microformats reduction
- retriever.clj is overall cleaner
Diffstat (limited to 'test')
| -rw-r--r-- | test/weepinbell/microformats_test.clj | 8 | ||||
| -rw-r--r-- | test/weepinbell/retriever_test.clj | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/test/weepinbell/microformats_test.clj b/test/weepinbell/microformats_test.clj index a307c75..c7b41de 100644 --- a/test/weepinbell/microformats_test.clj +++ b/test/weepinbell/microformats_test.clj @@ -5,7 +5,8 @@ [clojure.test :refer [deftest testing is]]))
(def testdata
- [{:in {:items [{:type ["h-entry"]
+ [{:target "https://test.com/"
+ :in {:items [{:type ["h-entry"]
:properties {:content [{:html "<div>test</div>"
:text "test"}]
:in-reply-to ["https://test.com"]
@@ -23,7 +24,8 @@ :type :in-reply-to,
:published 52341243232,
:content {:html "<div>test</div>", :text "test"}}}
- {:in {:items [{:type ["h-entry"]
+ {:target ""
+ :in {:items [{:type ["h-entry"]
:properties {:content [{:html "<div>test</div>"
:text "test"}]
:published [52341243232]}}
@@ -45,7 +47,7 @@ (deftest reducer-test
(testing "Normal microformats reduction"
(->> testdata
- (map #(let [reduced (reduce-mf (:in %))]
+ (map #(let [reduced (reduce-mf (:target %) (:in %))]
(is (= reduced (:out %)))
(is (spec-check reduced))))
doall))
diff --git a/test/weepinbell/retriever_test.clj b/test/weepinbell/retriever_test.clj index 7b5614d..c4044ed 100644 --- a/test/weepinbell/retriever_test.clj +++ b/test/weepinbell/retriever_test.clj @@ -13,13 +13,15 @@ resp1 (ret/by-domain "" 1 mock-store {})]
(is (= page-size (count (:body resp0))))
(is (= page-size (count (:body resp1)))))))
- (testing "by-domain handle invalid page number"
+ (testing "by-domain: if page is not number, return the last page frame"
(with-redefs [weepinbell.webserver.retriever/default-page-size page-size]
(let [mock-data [{:webmention {:source "1" :target "1"}}
{:webmention {:source "2" :target "2"}}]
mock-store {:get-by-domain (fn [& _] mock-data)}
resp (ret/by-domain "" true mock-store {})]
- (is (= 400 (:status resp))))))
+ (is (= 200 (:status resp)))
+ (is (= (-> mock-data last :webmention)
+ (-> resp :body last :webmention))))))
(testing "by-domain return 404 when list is empty"
(let [mock-store {:get-by-domain (fn [& _] [])}
resp (ret/by-domain "" nil mock-store {})]
|
