Repository navigation
Expand file tree
/
Copy pathminuteman_test.clj
More file actions
51 lines (48 loc) · 2.4 KB
/
Copy pathminuteman_test.clj
File metadata and controls
51 lines (48 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(ns lyeberry.minuteman-test
(:use midje.sweet)
(:use [lyeberry.minuteman]))
(def multiple-copies-book {:author "Toast" :title "Charles Stross"})
(def toast-html (slurp "test/lyeberry/toast-charles-stross.html"))
(def black-prism-html (slurp "test/lyeberry/black-prism-brent-weeks.html"))
(facts "about extract-books"
(let [books (extract-books toast-html)]
(fact "it return a vector of copies"
books => (contains {:title "Supermen : tales of the posthuman future"
:author "[edited by] Gardner Dozois"
:status "AVAILABLE"
:location "Newton"
:url ""
:call_number "Short Stories S959D" })
books => (contains {:title "Toast"
:author "Charles Stross"
:status "Out"
:location "Cambridge"
:url ""
:call_number "SCI FIC Stross, Charles" })
books => (contains {:title "Toast"
:author "Charles Stross"
:status "AVAILABLE"
:location "Newton"
:url ""
:call_number "Fic"})
))
(let [books (extract-books black-prism-html)]
(fact "it strips interior whitespace from call_number"
(map :call_number books) => '( "Fic Weeks"
"Fiction/Weeks"
"SCI FIC Weeks, Brent"
"FICTION WEEKS"
"SF"
"FICTION / Weeks"
"FICTION Weeks"
"FIC WEE 1"
"Science Fiction/Weeks. B. SERIES : Lightbringer 1"
"SF Pb"
"SCI FIC Weeks, Brent"
"PB FANTASY Weeks"
"SF Pb"
"SCIENCE FICTION PAPERBACK Weeks, B."))))
(facts "about search-url"
(fact "it returns the start search url for the given book"
(search-url {:title "Toast" :author "Charles Stross"})
=> "https://find.minlib.net/iii/encore/search/C__Stoast%20charles%20stross__Orightresult__U?lang=eng&suite=cobalt"))