-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.clj
250 lines (244 loc) · 12.5 KB
/
test.clj
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
(ns michmusic.test
(:require [cupboard.core :as cb]
[michmusic.controller :as c]
[michmusic.database :as db]
[michmusic.html :as h])
(:use [clojure.contrib.def :only (defvar-)]
clojure.contrib.test-is))
(deftest t-import
(cb/with-open-cupboard ["/tmp/test_songs"]
(cb/clear-shelf)
(db/import-file (java.io.File. "test/test.mp3"))
(is (= (cb/query)
[{:title "Intro"
:track 1
:album "Devin Dazzle and the Neon Fever"
:artist "Felix da Housecat"
:sha "92d69686d9766cfb77c25c1c786cebce39a561b1"
:year nil
:path "test/test.mp3"}]))))
(deftest t-song-path
(cb/with-open-cupboard ["/tmp/test_songs"]
(cb/clear-shelf)
(db/import-file (java.io.File. "test/test.mp3"))
(is (= (db/song-path "92d69686d9766cfb77c25c1c786cebce39a561b1")
"test/test.mp3"))))
(deftest t-album-display
(let [songs-by-album
[["Antidotes" 2008]
[{:title "B" :track 9 :album "Antidotes" :artist "Foals" :year 2008 :sha "bob"}
{:title "H" :track 7 :album "Antidotes" :artist "Foals" :year 2008 :sha "bob"}]]
html [[:div.album-header [:h3 [:span.year 2008] "Antidotes"]]
[:ul
[[:li 9 " "
[:span.play-button "play"] " "
[:a {:href "/file/bob/Foals_B.mp3"} ["B"]]]
[:li 7 " "
[:span.play-button "play"] " "
[:a {:href "/file/bob/Foals_H.mp3"} ["H"]]]]]]]
(is (= (h/album-display songs-by-album) html))))
(defvar- json-response)
(deftest t-artist-info
(let [[summary pic-url] (c/artist-info (fn [url] json-response)
"Tycho")]
(is (= (apply str (take 10 summary)) "Tycho is t"))
(is (= pic-url "http://userserve-ak.last.fm/serve/252/3463494.jpg"))))
(def json-response
{:body-seq "{
\"artist\": {
\"bio\": {
\"content\": \"<strong>Tycho</strong> is the music project of San Francisco based artist and producer Scott Hansen. Hansen began his foray into electronic music with 2002's <em><a title=\\\"Tycho - The Science of Patterns EP\\\" href=\\\"http://ws.audioscrobbler.com/music/Tycho/The+Science+of+Patterns+EP\\\" class=\\\"bbcode_album\\\">The Science of Patterns EP</a></em> which was followed in 2004 by his first full length, <em><a title=\\\"Tycho - Sunrise Projector\\\" href=\\\"http://ws.audioscrobbler.com/music/Tycho/Sunrise+Projector\\\" class=\\\"bbcode_album\\\">Sunrise Projector</a></em>. 2006 saw the release of <em><a title=\\\"Tycho - Past is Prologue\\\" href=\\\"http://ws.audioscrobbler.com/music/Tycho/Past+is+Prologue\\\" class=\\\"bbcode_album\\\">Past is Prologue</a></em> on the now defunkt IDM label <a href=\\\"http://ws.audioscrobbler.com/label/Merck+Records/\\\" class=\\\"bbcode_label\\\">Merck Records</a>. In 2007 <a href=\\\"http://ws.audioscrobbler.com/label/Ghostly+International/\\\" class=\\\"bbcode_label\\\">Ghostly International</a> released Tycho's first single under that imprint, "The Daydream / The Disconnect". A new full length album on Ghostly is in the works and slated for a 2009 release.\n \n \n AUDIO: <a href=\\\"http://www.tychomusic.com\\\" rel=\\\"nofollow\\\">www.tychomusic.com</a>\n VISUAL: <a href=\\\"http://www.iso50.com/\\\" rel=\\\"nofollow\\\">ISO50.com</a>\n GHOSTLY: <a href=\\\"http://www.ghostly.com/1.0/artists/tycho/index.shtml\\\" rel=\\\"nofollow\\\">Artist Page</a>\n MYSPACE: <a href=\\\"http://www.myspace.com/tycho\\\" rel=\\\"nofollow\\\">Myspace.com/tycho</a>\",
\"published\": \"Fri, 3 Apr 2009 11:36:48 +0000\",
\"summary\": \"Tycho is the music project of San Francisco based artist and producer Scott Hansen. Hansen began his foray into electronic music with 2002's <a title=\\\"Tycho - The Science of Patterns EP\\\" href=\\\"http://ws.audioscrobbler.com/music/Tycho/The+Science+of+Patterns+EP\\\" class=\\\"bbcode_album\\\">The Science of Patterns EP</a> which was followed in 2004 by his first full length, <a title=\\\"Tycho - Sunrise Projector\\\" href=\\\"http://ws.audioscrobbler.com/music/Tycho/Sunrise+Projector\\\" class=\\\"bbcode_album\\\">Sunrise Projector</a>. 2006 saw the release of <a title=\\\"Tycho - Past is Prologue\\\" href=\\\"http://ws.audioscrobbler.com/music/Tycho/Past+is+Prologue\\\" class=\\\"bbcode_album\\\">Past is Prologue</a> on the now defunkt IDM label <a href=\\\"http://ws.audioscrobbler.com/label/Merck+Records/\\\" class=\\\"bbcode_label\\\">Merck Records</a>. In 2007 <a href=\\\"http://ws.audioscrobbler.com/label/Ghostly+International/\\\" class=\\\"bbcode_label\\\">Ghostly International</a> released Tycho's first single under that imprint, "The Daydream / The Disconnect". A new full length album on Ghostly is in the works and slated for a 2009 release. \"
},
\"image\": [
{
\"#text\": \"http://userserve-ak.last.fm/serve/34/3463494.jpg\",
\"size\": \"small\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/64/3463494.jpg\",
\"size\": \"medium\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/126/3463494.jpg\",
\"size\": \"large\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/252/3463494.jpg\",
\"size\": \"extralarge\"
},
{
\"#text\": \"\",
\"size\": \"mega\"
}
],
\"mbid\": \"b36f70be-71b1-44d5-9abc-8cd5cc78eb6e\",
\"name\": \"Tycho\",
\"similar\": {
\"artist\": [
{
\"image\": [
{
\"#text\": \"http://userserve-ak.last.fm/serve/34/2132648.jpg\",
\"size\": \"small\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/64/2132648.jpg>\",
\"size\": \"medium\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/126/2132648.jpg\",
\"size\": \"large\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/252/2132648.jpg\",
\"size\": \"extralarge\"
},
{
\"#text\": \"\",
\"size\": \"mega\"
}
],
\"name\": \"Boards of Canada\",
\"url\": \"http://www.last.fm/music/Boards+of+Canada\"
},
{
\"image\": [
{
\"#text\": \"http://userserve-ak.last.fm/serve/34/22098815.jpg\",
\"size\": \"small\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/64/22098815.jpg>\",
\"size\": \"medium\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/126/22098815.jpg\",
\"size\": \"large\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/252/22098815.jpg\",
\"size\": \"extralarge\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/_/22098815/Ulrich+Schnauss+UlrichSchnauss.jpg\",
\"size\": \"mega\"
}
],
\"name\": \"Ulrich Schnauss\",
\"url\": \"http://www.last.fm/music/Ulrich+Schnauss\"
},
{
\"image\": [
{
\"#text\": \"http://userserve-ak.last.fm/serve/34/25015967.jpg\",
\"size\": \"small\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/64/25015967.jpg>\",
\"size\": \"medium\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/126/25015967.jpg\",
\"size\": \"large\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/252/25015967.jpg\",
\"size\": \"extralarge\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/500/25015967/Milosh+me2.jpg\",
\"size\": \"mega\"
}
],
\"name\": \"Milosh\",
\"url\": \"http://www.last.fm/music/Milosh\"
},
{
\"image\": [
{
\"#text\": \"http://userserve-ak.last.fm/serve/34/21184503.jpg\",
\"size\": \"small\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/64/21184503.jpg>\",
\"size\": \"medium\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/126/21184503.jpg\",
\"size\": \"large\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/252/21184503.jpg\",
\"size\": \"extralarge\"
},
{
\"#text\": \"\",
\"size\": \"mega\"
}
],
\"name\": \"Telefon Tel Aviv\",
\"url\": \"http://www.last.fm/music/Telefon+Tel+Aviv\"
},
{
\"image\": [
{
\"#text\": \"http://userserve-ak.last.fm/serve/34/231962.jpg\",
\"size\": \"small\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/64/231962.jpg>\",
\"size\": \"medium\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/126/231962.jpg\",
\"size\": \"large\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/252/231962.jpg\",
\"size\": \"extralarge\"
},
{
\"#text\": \"http://userserve-ak.last.fm/serve/_/231962/Proem.jpg\",
\"size\": \"mega\"
}
],
\"name\": \"Proem\",
\"url\": \"http://www.last.fm/music/Proem\"
}
]
},
\"stats\": {
\"listeners\": \"108794\",
\"playcount\": \"1936813\"
},
\"streamable\": \"1\",
\"tags\": {
\"tag\": [
{
\"name\": \"ambient\",
\"url\": \"http://www.last.fm/tag/ambient\"
},
{
\"name\": \"idm\",
\"url\": \"http://www.last.fm/tag/idm\"
},
{
\"name\": \"electronic\",
\"url\": \"http://www.last.fm/tag/electronic\"
},
{
\"name\": \"chillout\",
\"url\": \"http://www.last.fm/tag/chillout\"
},
{
\"name\": \"downtempo\",
\"url\": \"http://www.last.fm/tag/downtempo\"
}
]
},
\"url\": \"http://www.last.fm/music/Tycho\"
}
}"})
(run-tests)