Skip to content

Commit

Permalink
Adds a list flavor details unit test and the corresponding handler
Browse files Browse the repository at this point in the history
  • Loading branch information
zodmaner committed May 4, 2016
1 parent 27d27a7 commit 1e5d0b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 21 additions & 0 deletions t/t.mock-compute-server/mock-compute-server.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,24 @@ acceptor and shutdown the server."
(alexandria:plist-hash-table
(list "name" "m1.micro"
"id" "84"))))))))))

(hunchentoot:define-easy-handler
(nova-endpoint-flavor-details
:uri #'(lambda (request)
(uri-template:uri-template-bind
(#U/v2.1/{tenant-id}/flavors/{id})
(hunchentoot:request-uri request)
(and (string= tenant-id *tenant-id*)
(string= id "1"))))) ()
(case (hunchentoot:request-method*)
(:get
(when (string= *token* (hunchentoot:header-in* "X-Auth-Token"))
(st-json:write-json-to-string
(alexandria:plist-hash-table
(list "flavor"
(alexandria:plist-hash-table
(list "name" "m1.tiny"
"vcpus" 1
"ram" 512
"swap" ""
"disk" 1)))))))))
13 changes: 8 additions & 5 deletions t/trivial-openstack-test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,21 @@
(is (string= (token *openstack-token*)
*token*))))

(test images
"Test images REST API."
(test images-api
"Test the images REST API."
(with-fixture mock-image-server ()
(is (equalp (list-images)
'(("cirros-0.3.4-x86_64-uec" . "c4947a88-3b38-44d5-b605-edad3cf1191b")
("cirros-0.3.4-x86_64-uec-ramdisk" . "619726e7-b3b1-4d39-8669-cf05fb04981d")
("cirros-0.3.4-x86_64-uec-kernel" . "b5afe28f-3ed5-4d4e-8094-fac19d2d7ac3"))))))

(test computes
"Test compute REST API."
(test flavors-api
"Test the flavors REST API."
(with-fixture mock-compute-server ()
(is (equalp (list-flavors)
'(("m1.tiny" . "1") ("m1.small" . "2") ("m1.medium" . "3")
("m1.large" . "4") ("m1.nano" . "42") ("m1.xlarge" . "5")
("m1.micro" . "84"))))))
("m1.micro" . "84"))))
(is (equalp (list-flavor-details "1")
'(("disk" . 1) ("swap" . "")
("ram" . 512) ("vcpus" . 1) ("name" . "m1.tiny"))))))

0 comments on commit 1e5d0b5

Please sign in to comment.