From 0d92a718516a47088e87d1a69aab5aa268255d7f Mon Sep 17 00:00:00 2001 From: Torkus <48141663+ogri-la@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:25:27 +0930 Subject: [PATCH 01/13] adding more wowi tests, updating wowi test fixtures --- src/scb/main.clj | 4 +- src/scb/specs.clj | 2 +- src/scb/tags.clj | 6 +- src/scb/user.clj | 14 +- src/scb/utils.clj | 11 +- src/scb/wowi.clj | 3 +- ...detail--multiple-downloads--no-tabber.html | 1884 ++++++++++++----- ...on-detail--multiple-downloads--tabber.html | 1292 ++++++----- test/scb/core_test.clj | 1 - test/scb/tags_test.clj | 3 +- test/scb/wowi_test.clj | 390 +++- update-fixtures.sh | 6 + 12 files changed, 2463 insertions(+), 1153 deletions(-) create mode 100755 update-fixtures.sh diff --git a/src/scb/main.clj b/src/scb/main.clj index fbc1011..f29a544 100644 --- a/src/scb/main.clj +++ b/src/scb/main.clj @@ -15,9 +15,7 @@ :scrape-catalogue #(user/daily-addon-update) :scrape-wowinterface-catalogue #(user/daily-addon-update {:source-list [:wowinterface]}) ;; no distinction between scraping and writing - :scrape-github-catalogue #(user/daily-addon-update {:source-list [:github]}) - - }) + :scrape-github-catalogue #(user/daily-addon-update {:source-list [:github]})}) (defn start [{:keys [action]}] diff --git a/src/scb/specs.clj b/src/scb/specs.clj index 06c44c8..389b5b5 100644 --- a/src/scb/specs.clj +++ b/src/scb/specs.clj @@ -53,7 +53,7 @@ ;; -(s/def ::game-track #{:retail :classic :classic-tbc :classic-wotlk}) +(s/def ::game-track #{:retail :classic :classic-tbc :classic-wotlk :classic-cata}) (s/def ::game-track-list (s/coll-of ::game-track :distinct true)) (s/def ::interface-version int?) ;; 90005, 11307, 20501 diff --git a/src/scb/tags.clj b/src/scb/tags.clj index c38067d..827b460 100644 --- a/src/scb/tags.clj +++ b/src/scb/tags.clj @@ -121,13 +121,11 @@ sp/placeholder (def replacement-map {:wowinterface (merge general-replacements wowi-replacements) - :curseforge (merge general-replacements curse-replacements) - }) + :curseforge (merge general-replacements curse-replacements)}) (def supplement-map {:wowinterface (merge general-supplements wowi-supplements) - :curseforge (merge general-supplements curse-supplements) - }) + :curseforge (merge general-supplements curse-supplements)}) ;; diff --git a/src/scb/user.clj b/src/scb/user.clj index 6ee0a42..555a071 100644 --- a/src/scb/user.clj +++ b/src/scb/user.clj @@ -1,10 +1,11 @@ (ns scb.user + (:refer-clojure :exclude [test]) (:require [orchestra.core :refer [defn-spec]] [taoensso.timbre :as timbre :refer [debug info warn error spy]] ;;[net.cgrand.enlive-html :as html :refer [select]] ;;[clojure.pprint] - [clojure.test :as clj-test] + [clojure.test] [me.raynes.fs :as fs] [gui.diff :refer [with-gui-diff]] [scb @@ -22,8 +23,7 @@ (def ns-list [:core :utils :tags - :wowi :github - ]) + :wowi :github]) (defn test [& [ns-kw fn-kw]] @@ -61,9 +61,9 @@ (if fn-kw ;; `test-vars` will run the test but not give feedback if test passes OR test not found ;; slightly better than nothing - (clj-test/test-vars [(resolve (symbol (str "scb." (name ns-kw) "-test") (name fn-kw)))]) - (clj-test/run-all-tests (re-pattern (str "scb." (name ns-kw) "-test")))))) - (clj-test/run-all-tests #"scb\..*-test")))) + (clojure.test/test-vars [(resolve (symbol (str "scb." (name ns-kw) "-test") (name fn-kw)))]) + (clojure.test/run-all-tests (re-pattern (str "scb." (name ns-kw) "-test")))))) + (clojure.test/run-all-tests #"scb\..*-test")))) (finally ;; use case: we run the tests from the repl and afterwards we call `restart` to start the app. ;; `stop` inside `restart` will be outside of `with-redefs` and still have logging `:min-level` set to `:debug` @@ -80,7 +80,7 @@ ;;http/*default-attempts* 1 ] (with-gui-diff - (clj-test/run-all-tests #"scb\..*-test"))) + (clojure.test/run-all-tests #"scb\..*-test"))) (finally nil))) diff --git a/src/scb/utils.clj b/src/scb/utils.clj index a5690c2..cb6b4e5 100644 --- a/src/scb/utils.clj +++ b/src/scb/utils.clj @@ -161,6 +161,8 @@ "2." :classic-tbc ;; 3.x.x == classic (wrath of the lich king) "3." :classic-wotlk + ;; 4.x.x == classic (cata) + "4." :classic-cata :retail))) (defn-spec dump-json-file ::sp/extant-file @@ -237,12 +239,14 @@ (-> unix-time jt/instant str)) (defn-spec guess-game-track (s/nilable ::sp/game-track) - "returns the first game track it finds in the given string, preferring `:classic-tbc`, then `:classic`, then `:retail` (most to least specific). + "returns the first game track it finds in the given string, preferring most to least specific. returns `nil` if no game track found." [string (s/nilable string?)] (when string - (let [;; matches 'classic-wotlk', 'classic_wotlk', 'classic-wrath', 'classic_wrath', 'wotlk', 'wrath' - classic-wotlk-regex #"(?i)(classic[\W_])?(wrath|wotlk){1}\W?" + (let [;; matches 'cata'. less variation this time around. + classic-cata-regex #"(?i)[\W_]?cata([\W_]?|$)" + ;; matches 'classic-wotlk', 'classic_wotlk', 'classic-wrath', 'classic_wrath', 'wotlk', 'wrath' + classic-wotlk-regex #"(?i)(classic[\W_])?(wrath|wotlk)([\W_]|$)?" ;; matches 'classic-tbc', 'classic-bc', 'classic-bcc', 'classic_tbc', 'classic_bc', 'classic_bcc', 'tbc', 'tbcc', 'bc', 'bcc' ;; but not 'classictbc' or 'classicbc' or 'classicbcc' ;; see tests. @@ -250,6 +254,7 @@ classic-regex #"(?i)classic|vanilla" retail-regex #"(?i)retail|mainline"] (cond + (re-find classic-cata-regex string) :classic-cata (re-find classic-wotlk-regex string) :classic-wotlk (re-find classic-tbc-regex string) :classic-tbc (re-find classic-regex string) :classic diff --git a/src/scb/wowi.clj b/src/scb/wowi.clj index 84819a2..68f6640 100644 --- a/src/scb/wowi.clj +++ b/src/scb/wowi.clj @@ -101,7 +101,8 @@ (defn extract-source-id-2 [s] - (utils/str-to-int (last (re-find (re-matcher #"info(\d+)" s))))) + (when s + (utils/str-to-int (last (re-find (re-matcher #"info(\d+)" s)))))) (defn-spec web-addon-url ::sp/url [source-id :addon/source-id] diff --git a/test/fixtures/wowinterface--addon-detail--multiple-downloads--no-tabber.html b/test/fixtures/wowinterface--addon-detail--multiple-downloads--no-tabber.html index 73e4732..351f3dd 100644 --- a/test/fixtures/wowinterface--addon-detail--multiple-downloads--no-tabber.html +++ b/test/fixtures/wowinterface--addon-detail--multiple-downloads--no-tabber.html @@ -9,12 +9,12 @@ - + - - @@ -58,46 +47,9 @@ - - - - - - - - + + + - - + +
@@ -156,36 +123,36 @@
-