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
1332fef6
Commit
1332fef6
authored
Feb 12, 2014
by
Dionysis Grigoropoulos
Browse files
cyclades: Add tests for servers/networks/subnets
Add new tests for changes introduced in commit 35ea7f6
parent
0c3c41fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/tests/networks.py
View file @
1332fef6
...
...
@@ -214,6 +214,13 @@ class NetworkTest(BaseAPITest):
response
=
self
.
put
(
url
,
test_net
.
userid
,
json
.
dumps
(
request
),
'json'
)
self
.
assertFault
(
response
,
403
,
'forbidden'
)
def
test_rename_network_invalid_name
(
self
):
test_net
=
dbmf
.
NetworkFactory
(
name
=
"foo"
)
url
=
join_urls
(
NETWORKS_URL
,
str
(
test_net
.
id
))
request
=
{
'network'
:
{
'name'
:
'a'
*
500
}}
response
=
self
.
put
(
url
,
test_net
.
userid
,
json
.
dumps
(
request
),
'json'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
def
test_method_not_allowed
(
self
,
*
args
):
# /networks/ allows only POST, GET
response
=
self
.
put
(
NETWORKS_URL
,
''
,
''
)
...
...
snf-cyclades-app/synnefo/api/tests/servers.py
View file @
1332fef6
...
...
@@ -282,6 +282,13 @@ class ServerAPITest(ComputeAPITest):
self
.
assertSuccess
(
response
)
self
.
assertEqual
(
VirtualMachine
.
objects
.
get
(
id
=
vm
.
id
).
name
,
"new_name"
)
def
test_rename_server_invalid_name
(
self
):
vm
=
self
.
vm2
request
=
{
'server'
:
{
'name'
:
'a'
*
500
}}
response
=
self
.
myput
(
'servers/%d'
%
vm
.
id
,
vm
.
userid
,
json
.
dumps
(
request
),
'json'
)
self
.
assertBadRequest
(
response
)
def
test_catch_wrong_api_paths
(
self
):
response
=
self
.
myget
(
'nonexistent'
)
self
.
assertEqual
(
response
.
status_code
,
400
)
...
...
@@ -737,6 +744,10 @@ class ServerActionAPITest(ComputeAPITest):
response
=
self
.
mypost
(
'servers/%d/action'
%
vm
.
id
,
vm
.
userid
,
json
.
dumps
(
request
),
'json'
)
self
.
assertItemNotFound
(
response
)
request
=
{
'firewallProfile'
:
{
'profile'
:
'PROTECTED'
,
"nic"
:
"error"
}}
response
=
self
.
mypost
(
'servers/%d/action'
%
vm
.
id
,
vm
.
userid
,
json
.
dumps
(
request
),
'json'
)
self
.
assertBadRequest
(
response
)
nic
=
mfactory
.
NetworkInterfaceFactory
(
machine
=
vm
)
request
=
{
'firewallProfile'
:
{
'profile'
:
'PROTECTED'
,
"nic"
:
nic
.
id
}}
response
=
self
.
mypost
(
'servers/%d/action'
%
vm
.
id
,
...
...
snf-cyclades-app/synnefo/api/tests/subnets.py
View file @
1332fef6
...
...
@@ -143,6 +143,19 @@ class SubnetTest(BaseAPITest):
json
.
dumps
(
request
),
"json"
)
self
.
assertBadRequest
(
response
)
def
test_create_subnet_with_malformed_network_id
(
self
):
"""Test create a subnet with an invalid network ID"""
test_net
=
mf
.
NetworkFactory
()
request
=
{
'subnet'
:
{
'network_id'
:
'error'
,
'cidr'
:
'192.168.42.0/24'
,
'ip_version'
:
4
}
}
response
=
self
.
post
(
SUBNETS_URL
,
test_net
.
userid
,
json
.
dumps
(
request
),
"json"
)
self
.
assertBadRequest
(
response
)
def
test_create_subnet_success_ipv6
(
self
):
"""Test create an IPv6 subnet successfully"""
test_net
=
mf
.
NetworkFactory
()
...
...
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