Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
74be46f4
Commit
74be46f4
authored
Jun 12, 2013
by
Georgios D. Tsoukalas
Browse files
cyclades: add tests for 400 on wrong Compute paths
parent
1f4da53c
Changes
5
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/test/flavors.py
View file @
74be46f4
...
...
@@ -136,3 +136,11 @@ class FlavorAPITest(BaseAPITest):
# XXX: flavors/22 below fails for no apparent reason
response
=
self
.
myget
(
'flavors/%d'
%
23
)
self
.
assertItemNotFound
(
response
)
def
test_catch_wrong_api_paths
(
self
,
*
args
):
response
=
self
.
myget
(
'nonexistent'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
try
:
error
=
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
snf-cyclades-app/synnefo/api/test/images.py
View file @
74be46f4
...
...
@@ -213,6 +213,15 @@ class ImageAPITest(ComputeAPITest):
mimage
.
return_value
.
unregister
.
assert_called_once_with
(
'42'
)
mimage
.
return_value
.
_delete
.
assert_not_called
(
'42'
)
@
assert_backend_closed
def
test_catch_wrong_api_paths
(
self
,
*
args
):
response
=
self
.
myget
(
'nonexistent'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
try
:
error
=
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
@
patch
(
'synnefo.plankton.backend.ImageBackend'
)
class
ImageMetadataAPITest
(
ComputeAPITest
):
...
...
snf-cyclades-app/synnefo/api/test/networks.py
View file @
74be46f4
...
...
@@ -433,3 +433,11 @@ class NetworkAPITest(ComputeAPITest):
response
=
self
.
mypost
(
'networks/%d/action'
%
net
.
id
,
net
.
userid
,
json
.
dumps
(
request
),
'json'
)
self
.
assertBadRequest
(
response
)
def
test_catch_wrong_api_paths
(
self
,
*
args
):
response
=
self
.
myget
(
'nonexistent'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
try
:
error
=
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
snf-cyclades-app/synnefo/api/test/servers.py
View file @
74be46f4
...
...
@@ -189,6 +189,14 @@ class ServerAPITest(ComputeAPITest):
self
.
assertSuccess
(
response
)
self
.
assertEqual
(
VirtualMachine
.
objects
.
get
(
id
=
vm
.
id
).
name
,
"new_name"
)
def
test_catch_wrong_api_paths
(
self
):
response
=
self
.
myget
(
'nonexistent'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
try
:
error
=
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
@
patch
(
'synnefo.api.util.get_image'
)
@
patch
(
'synnefo.logic.rapi_pool.GanetiRapiClient'
)
...
...
snf-cyclades-app/synnefo/api/test/versions.py
View file @
74be46f4
...
...
@@ -36,6 +36,8 @@ from django.test import TestCase
from
snf_django.utils.testing
import
astakos_user
from
synnefo.cyclades_settings
import
cyclades_services
from
synnefo.lib.services
import
get_service_path
from
synnefo.lib
import
join_urls
class
APITest
(
TestCase
):
def
test_api_version
(
self
):
...
...
@@ -48,3 +50,13 @@ class APITest(TestCase):
api_version
=
json
.
loads
(
response
.
content
)[
'version'
]
self
.
assertEqual
(
api_version
[
'id'
],
'v2.0'
)
self
.
assertEqual
(
api_version
[
'status'
],
'CURRENT'
)
def
test_catch_wrong_api_paths
(
self
,
*
args
):
path
=
get_service_path
(
cyclades_services
,
'compute'
,
version
=
'v2.0'
)
response
=
self
.
client
.
get
(
join_urls
(
path
,
'nonexistent'
))
self
.
assertEqual
(
response
.
status_code
,
400
)
try
:
error
=
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment