Coverage report: /home/samppa/personal/opiskelu/ohtuprojekti/pulsu/trunk/newest.lisp
Kind | Covered | All | % |
expression | 16 | 89 | 18.0 |
branch | 2 | 18 | 11.1 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
5
(defpage (newest-unified-cases :uri "/newest")
6
((number-of-cases :parameter-type 'INTEGER :init-form 25)
7
(page :parameter-type 'INTEGER :init-form 0)
8
(search :parameter-type 'STRING :init-form "nil") ;;"((:disease_name \"AIDS\"))"))
9
(verify :parameter-type 'STRING :init-form "all"))
10
;; "Newest unified cases page. number-of-cases tells how many unified cases groups are listed. Page tells which list page is shown."
11
(puls.controller::authenticate-user)
12
(render-mainview number-of-cases page "newest" (read-from-string search) verify));(string= "true" verify)))
14
(defpage (newest-cases :uri "/newest.cases")
15
((number-of-cases :parameter-type 'INTEGER :init-form 25)
16
(page :parameter-type 'INTEGER :init-form 0)
17
(search :parameter-type 'STRING :init-form "nil")
18
(verify :parameter-type 'STRING :init-form "all"))
19
;;"Newest cases page. number-of-cases tells how many cases are listed. Page tells which list page is shown."
20
(puls.controller::authenticate-user)
21
(render-mainview number-of-cases page "newest.cases" (read-from-string search) verify));(string= "true" verify)))
23
(defhtml render-mainview (number-of-cases page view filter verify)
24
;;"render mainview. This is called by newest-unified-cases and newest-cases"
26
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
28
:xmlns "http://www.w3.org/1999/xhtml"
32
(:meta :http-equiv "Content-Type"
33
:content "text/html;charset=iso-8859-1")
34
(:title "Newest cases")
35
(:link :href "static/headerstyle.css"
38
(:link :href "static/searchstyle.css"
41
(:link :href "static/indexstyle.css"
44
(:script :language "JavaScript"
45
:type "text/javascript"
46
:src "static/SpryEffects.js")
47
(:script :language "JavaScript"
48
:type "text/javascript"
49
:src "static/showhide.js")
50
(:script :language "JavaScript"
51
:type "text/javascript"
52
:src "static/prototype-1.6.0.3.js")
53
(:script :language "JavaScript"
54
:type "text/javascript"
55
:src "static/scriptaculous/scriptaculous.js")
56
(:script :language "JavaScript"
57
:type "text/javascript"
58
:src "static/search.js")
59
(:script :language "JavaScript"
60
:type "text/javascript"
61
:src "static/scriptaculous/complete.js"))
62
(:body :class "layout"
63
:onload "getFilters()"
66
(:div :id "main_content"
67
(if (string= view "newest.cases")
68
(htm (:h2 "Newest Cases"))
69
(htm (:h2 "Newest Unified Cases")))
70
(if (equal "on" (get-parameter "snippet"))
71
(link/keep-state* (html () (:img :src "static/info_button.jpg" :id "snippet_info" :alt "info button")) view :snippet "off")
72
(link/keep-state* (html () (:img :src "static/info_button.jpg" :id "snippet_info" :alt "info button")) view :snippet "on"))
73
(:div (make-pager page 'page 30))
74
(if (string= view "newest.cases")
76
(loop for listed-events
77
in (puls.controller::get-newest-events
78
:skip (* page number-of-cases)
79
:n number-of-cases :show-accepted verify :filter filter) ;(/= accepted 0))
81
(htm (:img :src "static/line.png"
84
(render-cases listed-events view))))
86
(if (string= view "newest")
88
(loop for unified-cases
89
in (puls.controller::get-newest-unified-cases
90
:skip (* page number-of-cases)
91
:n number-of-cases :show-accepted verify :filter filter) ; (/= accepted 0))
93
do (render-group unified-cases view filter verify))))
95
(:div (make-pager page 'page 30)))
98
(defhtml render-group (unified-cases view filter verify)
99
;;"render one unified case group to page. This is used in newest-unified-cases"
104
(:img :src "static/line.png"
108
;; shows icon if unified group is verified
111
(lambda (x) (null (getf x :verify)))
113
(getf (first unified-cases) :group_number) :show-accepted verify :filter filter))
114
(htm (:img :src "static/un_ver_group.jpg" :alt "unverified"))
115
(htm (:img :src "static/ver_group.jpg" :alt "verified")))
117
(if (> (length unified-cases) 1)
119
(htm (:a :onclick (format nil "switchid('cases~a');" *id*)
120
(:img :class "arrows"
121
:id (format nil "cases~a_arrow" *id*)
122
:src "static/arrow1.png"
124
(str (length unified-cases))))
126
(:div :class "group_header"
127
(str (puls.controller:get-unified-case-title unified-cases)))
128
(:div :class "unified_cases"
129
(render-cases (elt unified-cases 0) view
130
(getf (first unified-cases) :group_number)))
131
(:div :class "unified_cases_h" :id (format nil "cases~a" *id*)
132
(loop for case in (cdr unified-cases)
136
(getf (first unified-cases) :group_number))))))))
138
(defhtml render-cases (case view &optional (group nil))
139
;;"render one case to list. This is used in newest-unified-cases and newest-cases views."
140
(if (null (getf case :verify))
141
(htm (:img :src "static/un_ver_case.jpg" :alt "unverified"))
142
(htm (:img :src "static/ver_case.jpg" :alt "verified")
143
(str (getf case :verify))))
144
(link/keep-state* (get-document-title (getf case :docno))
146
'n (getf case :docno)
147
'c (getf case :event_id)
150
'snippet (get-parameter "snippet")
151
'page (get-parameter "page"))
152
(if (equal "on" (get-parameter "snippet"))
153
(htm (:div :class "snippet"
154
(str (get-snippet case))))
155
(htm (:div :class "snippet"))))
158
(deftest test-newest ()
160
; (test-render-group)
161
; (test2-render-group)
163
; (test1-render-cases)
164
; (test2-render-cases)
165
; (test1-newest-cases)
166
; (test2-newest-cases)
167
; (test1-newest-unified-cases)
170
;; 2 cases in group (more than 1 case)
171
(deftest test-render-group ()
173
(check (equal (with-output-to-string (*http-stream*) (render-group (first *mock-unified*) "test" nil
174
(read-from-string "nil")))
176
<div class=\"group\">
177
<img src=\"static/line.png\" class=\"line\" alt=\"line image\" />
178
<div class=\"icons\">
179
<a onclick=\"switchid('cases1');\">
180
<img class=\"arrows\" id=\"cases1_arrow\" src=\"static/arrow1.png\" alt=\"expand\" />
183
<div class=\"group_header\">(Avian Influenza) in (Philippines)
185
<div class=\"unified_cases\">
186
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
187
<a href=\"/dv?n=20051231_NEWScomAU_73ef10bed6da82fc1bba1c8c779c133a&c=1&b=2&a=1&back=test\">Two people died
191
<div class=\"unified_cases_h\" id=\"cases1\">
192
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
193
<a href=\"/dv?n=20051231_TheAustralian_0c5cfe218c0da516616cec1bdfa58cf5&c=1&b=2&a=1&back=test\">Two people died
200
(deftest test2-render-group ()
202
(check (equal (with-output-to-string (*http-stream*) (render-group (second *mock-unified*) "test" nil
203
(read-from-string "nil")))
205
<div class=\"group\">
206
<img src=\"static/line.png\" class=\"line\" alt=\"line image\" />
207
<div class=\"icons\">
210
<div class=\"group_header\">(HIV) in (Malaysia)
212
<div class=\"unified_cases\">
213
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
214
<a href=\"/dv?n=20051230_africaFM_0cff88d0437805a89607e5858c68eb40&c=2&b=2&a=1\&back=test\">and never got sick
218
<div class=\"unified_cases_h\" id=\"cases1\">
222
;; send nil to render-group
223
(deftest test3-render-group ()
224
(check (equal (with-output-to-string (*http-stream*) (render-group nil "test" nil nil))
227
;; why these come? &b=2&a=1\
228
(deftest test1-render-cases ()
229
(check (equal (with-output-to-string (*http-stream*) (render-cases (first (first *mock-unified*)) "test"))
231
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
232
<a href=\"/dv?n=20051231_NEWScomAU_73ef10bed6da82fc1bba1c8c779c133a&c=1&b=2&a=1&back=test\">Two people died
236
(deftest test2-render-cases ()
237
(check (equal (with-output-to-string (*http-stream*) (render-cases (second (first *mock-unified*)) "test"))
239
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
240
<a href=\"/dv?n=20051231_TheAustralian_0c5cfe218c0da516616cec1bdfa58cf5&c=1&b=2&a=1&back=test\">Two people died
244
;; comes error in render-cases if argument is nil
246
(deftest test1-newest-cases ()
247
(check (equal (newest-cases :number-of-cases 1)
250
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
251
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fi\" lang=\"fi\">
253
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=iso-8859-1\" />
257
<link href=\"static/headerstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
258
<link href=\"static/searchstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
259
<link href=\"static/indexstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
260
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/SpryEffects.js\"></script>
261
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/showhide.js\"></script>
262
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/prototype-1.6.0.3.js\"></script>
263
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/scriptaculous/scriptaculous.js\"></script>
264
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/search.js\"></script>
265
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/complete.js\"></script>
267
<body class=\"layout\">
269
<div id=\"header_left\">
271
<img id=\"logo\" src=\"static/new-puls-logo.png\" alt=\"Puls logo\" />
272
<a href=\"/newest\">unified cases
274
<a href=\"/newest.cases\">cases
280
<div id=\"header_right\">
281
<form method=\"get\" action=\"/login\">
282
<input type=\"text\" size=\"20\" name=\"name\" />
283
<input type=\"text\" size=\"20\" name=\"passwd\" />
284
<input type=\"submit\" value=\"login\" name=\"login\" />
288
<div id=\"main_content\">
292
<div id=\"pager\"><span class='pager'>
296
<a href=\"/foo?page=1&c=3&b=2&a=1\"> 2
299
<a href=\"/foo?page=2&c=3&b=2&a=1\"> 3
303
<a href=\"/foo?page=27&c=3&b=2&a=1\"> 28
306
<a href=\"/foo?page=28&c=3&b=2&a=1\"> 29
309
<a href=\"/foo?page=29&c=3&b=2&a=1\"> 30
312
<a href=\"/foo?page=1&c=3&b=2&a=1\"> >>
315
<img src=\"static/line.png\" class=\"line\" alt=\"line image\" />
316
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
317
<a href=\"/dv?n=20051231_khaleejtimes_3a184ca0f6a2ad55e5879bfb53201b3b&c=1&b=2&a=1\">dozens of people killed by the deadly virus in Asia in 2005,
320
<div id=\"pager\"><span class='pager'>
324
<a href=\"/foo?page=1&c=3&b=2&a=1\"> 2
327
<a href=\"/foo?page=2&c=3&b=2&a=1\"> 3
331
<a href=\"/foo?page=27&c=3&b=2&a=1\"> 28
334
<a href=\"/foo?page=28&c=3&b=2&a=1\"> 29
337
<a href=\"/foo?page=29&c=3&b=2&a=1\"> 30
340
<a href=\"/foo?page=1&c=3&b=2&a=1\"> >>
352
(deftest test2-newest-cases ()
353
(check (equal (newest-cases :number-of-cases 2)
355
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
356
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fi\" lang=\"fi\">
358
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=iso-8859-1\" />
362
<link href=\"static/headerstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
363
<link href=\"static/searchstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
364
<link href=\"static/indexstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
365
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/SpryEffects.js\"></script>
366
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/showhide.js\"></script>
367
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/prototype-1.6.0.3.js\"></script>
368
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/scriptaculous/scriptaculous.js\"></script>
369
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/search.js\"></script>
370
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/complete.js\"></script>
372
<body class=\"layout\">
374
<div id=\"header_left\">
376
<img id=\"logo\" src=\"static/new-puls-logo.png\" alt=\"Puls logo\" />
377
<a href=\"/newest\">unified cases
379
<a href=\"/newest.cases\">cases
385
<div id=\"header_right\">
386
<form method=\"get\" action=\"/login\">
387
<input type=\"text\" size=\"20\" name=\"name\" />
388
<input type=\"text\" size=\"20\" name=\"passwd\" />
389
<input type=\"submit\" value=\"login\" name=\"login\" />
393
<div id=\"main_content\">
397
<div id=\"pager\"><span class='pager'>
401
<a href=\"/foo?page=1&c=3&b=2&a=1\"> 2
404
<a href=\"/foo?page=2&c=3&b=2&a=1\"> 3
408
<a href=\"/foo?page=27&c=3&b=2&a=1\"> 28
411
<a href=\"/foo?page=28&c=3&b=2&a=1\"> 29
414
<a href=\"/foo?page=29&c=3&b=2&a=1\"> 30
417
<a href=\"/foo?page=1&c=3&b=2&a=1\"> >>
420
<img src=\"static/line.png\" class=\"line\" alt=\"line image\" />
421
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
422
<a href=\"/dv?n=20051231_khaleejtimes_3a184ca0f6a2ad55e5879bfb53201b3b&c=1&b=2&a=1\">dozens of people killed by the deadly virus in Asia in 2005,
425
<img src=\"static/line.png\" class=\"line\" alt=\"line image\" />Mui.
426
<img src=\"static/check.png\" alt=\"verified\" />
427
<a href=\"/dv?n=20051231_TheAustralian_0c5cfe218c0da516616cec1bdfa58cf5&c=1&b=2&a=1\">Two people died
430
<div id=\"pager\"><span class='pager'>
434
<a href=\"/foo?page=1&c=3&b=2&a=1\"> 2
437
<a href=\"/foo?page=2&c=3&b=2&a=1\"> 3
441
<a href=\"/foo?page=27&c=3&b=2&a=1\"> 28
444
<a href=\"/foo?page=28&c=3&b=2&a=1\"> 29
447
<a href=\"/foo?page=29&c=3&b=2&a=1\"> 30
450
<a href=\"/foo?page=1&c=3&b=2&a=1\"> >>
462
(deftest test1-newest-unified-cases ()
463
(check (equal (newest-cases :number-of-cases 1)
465
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
466
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fi\" lang=\"fi\">
468
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=iso-8859-1\" />
472
<link href=\"static/headerstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
473
<link href=\"static/searchstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
474
<link href=\"static/indexstyle.css\" rel=\"stylesheet\" type=\"text/css\" />
475
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/SpryEffects.js\"></script>
476
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/showhide.js\"></script>
477
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/prototype-1.6.0.3.js\"></script>
478
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/scriptaculous/scriptaculous.js\"></script>
479
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/search.js\"></script>
480
<script language=\"JavaScript\" type=\"text/javascript\" src=\"static/complete.js\"></script>
482
<body class=\"layout\">
484
<div id=\"header_left\">
486
<img id=\"logo\" src=\"static/new-puls-logo.png\" alt=\"Puls logo\" />
487
<a href=\"/newest\">unified cases
489
<a href=\"/newest.cases\">cases
495
<div id=\"header_right\">
496
<form method=\"get\" action=\"/login\">
497
<input type=\"text\" size=\"20\" name=\"name\" />
498
<input type=\"text\" size=\"20\" name=\"passwd\" />
499
<input type=\"submit\" value=\"login\" name=\"login\" />
503
<div id=\"main_content\">
507
<div id=\"pager\"><span class='pager'>
511
<a href=\"/foo?page=1&c=3&b=2&a=1\"> 2
514
<a href=\"/foo?page=2&c=3&b=2&a=1\"> 3
518
<a href=\"/foo?page=27&c=3&b=2&a=1\"> 28
521
<a href=\"/foo?page=28&c=3&b=2&a=1\"> 29
524
<a href=\"/foo?page=29&c=3&b=2&a=1\"> 30
527
<a href=\"/foo?page=1&c=3&b=2&a=1\"> >>
530
<img src=\"static/line.png\" class=\"line\" alt=\"line image\" />
531
<img src=\"static/check_spacer.png\" alt=\"not verified\" />
532
<a href=\"/dv?n=20051231_khaleejtimes_3a184ca0f6a2ad55e5879bfb53201b3b&c=1&b=2&a=1\">dozens of people killed by the deadly virus in Asia in 2005,
535
<div id=\"pager\"><span class='pager'>
539
<a href=\"/foo?page=1&c=3&b=2&a=1\"> 2
542
<a href=\"/foo?page=2&c=3&b=2&a=1\"> 3
546
<a href=\"/foo?page=27&c=3&b=2&a=1\"> 28
549
<a href=\"/foo?page=28&c=3&b=2&a=1\"> 29
552
<a href=\"/foo?page=29&c=3&b=2&a=1\"> 30
555
<a href=\"/foo?page=1&c=3&b=2&a=1\"> >>