diff options
-rw-r--r-- | gn/data/species.scm | 14 | ||||
-rw-r--r-- | test/runner.scm | 8 | ||||
-rwxr-xr-x | web/webserver.scm | 17 |
3 files changed, 21 insertions, 18 deletions
diff --git a/gn/data/species.scm b/gn/data/species.scm index a1eb15f..98ea1b1 100644 --- a/gn/data/species.scm +++ b/gn/data/species.scm @@ -12,6 +12,8 @@ get-species-meta get-species-data get-species-shortnames + get-expanded-taxon-meta + get-expanded-taxon-data )) (define (get-species) @@ -67,7 +69,7 @@ ) (get-species) )) -(define (get-expanded-species1 short-name) +(define (get-expanded-taxon-data short-name) "Here we add information related to one taxonomy species" (call/cc (lambda (return) (for-each (lambda (rec) @@ -110,3 +112,13 @@ ("up" . ,(string-append (prefix) "/")) ("meta-links" . ,(get-species-meta2 recs)) ("links" . ,(get-species-links recs))))) + + +(define (get-expanded-taxon-meta id) + "Get information on a specific species, e.g. mouse" + `(("info" . ,id) + ("doc" . ,(mk-doc id)) + ("meta" . ,(mk-meta id)) + ("data" . ,(mk-data id)) + ("up" . ,(mk-meta "species")) + )) diff --git a/test/runner.scm b/test/runner.scm index 0123d9a..45f2b0c 100644 --- a/test/runner.scm +++ b/test/runner.scm @@ -10,7 +10,13 @@ (test-begin "runner") -(test-assert "Make sure species-meta contains a link to tomato" +(test-assert "species-meta is expected contain a link to tomato" (assoc "tomato" (cdr (assoc "links" (get-species-meta))))) +(test-assert "tomato-meta should have a document link" + (assoc "doc" (get-expanded-taxon-meta "tomato"))) + +(test-equal "tomato-data should have a description" + (assoc-ref (get-expanded-taxon-data "tomato") "description") "type of plant species with edible, often red, berry fruit") + (test-end "runner") diff --git a/web/webserver.scm b/web/webserver.scm index 26b4a75..485d334 100755 --- a/web/webserver.scm +++ b/web/webserver.scm @@ -51,21 +51,6 @@ (,(mk-url "datasets")."Get a list of datasets"))))) - -; (define (wd-species-info wd) -; ) - - -(define (get-expanded-taxon-meta id) - "Get information on a specific species, e.g. mouse" - `(("info" . ,id) - ("doc" . ,(mk-doc id)) - ("meta" . ,(mk-meta id)) - ("data" . ,(mk-data id)) - ("up" . ,(mk-meta "species")) - )) - - ;; ---- REST API web server handler (define (not-found2 request) @@ -119,7 +104,7 @@ (let ([names (get-species-shortnames (get-expanded-species))]) (match (string->list id) [(name ... #\. #\m #\e #\t #\a #\. #\j #\s #\o #\n) (render-json (get-expanded-taxon-meta (list->string name)))] - [(name ... #\. #\j #\s #\o #\n) (render-json (get-expanded-species1 (list->string name)))] + [(name ... #\. #\j #\s #\o #\n) (render-json (get-expanded-taxon-data (list->string name)))] [rest (render-json "NOP")]))) (_ (not-found (request-uri request))) )) |