Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
synnefo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
synnefo
Commits
54ffba9b
Commit
54ffba9b
authored
Aug 05, 2013
by
Christos Stavrakakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cyclades: Remove assumptions from tests
Remove some hard-coded IDs from tests.
parent
3bc2b7b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
snf-cyclades-app/synnefo/api/tests/flavors.py
snf-cyclades-app/synnefo/api/tests/flavors.py
+5
-7
snf-cyclades-app/synnefo/api/tests/floating_ips.py
snf-cyclades-app/synnefo/api/tests/floating_ips.py
+8
-3
No files found.
snf-cyclades-app/synnefo/api/tests/flavors.py
View file @
54ffba9b
# Copyright 201
2
GRNET S.A. All rights reserved.
# Copyright 201
3
GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
...
...
@@ -50,12 +50,10 @@ class FlavorAPITest(BaseAPITest):
self
.
compute_path
=
get_service_path
(
cyclades_services
,
'compute'
,
version
=
'v2.0'
)
def
myget
(
self
,
path
):
path
=
join_urls
(
self
.
compute_path
,
path
)
return
self
.
get
(
path
)
def
test_flavor_list
(
self
):
"""Test if the expected list of flavors is returned."""
response
=
self
.
myget
(
'flavors'
)
...
...
@@ -88,7 +86,7 @@ class FlavorAPITest(BaseAPITest):
self
.
assertEqual
(
api_flavor
[
'name'
],
db_flavor
.
name
)
self
.
assertEqual
(
api_flavor
[
'ram'
],
db_flavor
.
ram
)
self
.
assertEqual
(
api_flavor
[
'SNF:disk_template'
],
db_flavor
.
disk_template
)
db_flavor
.
disk_template
)
def
test_flavor_details
(
self
):
"""Test if the expected flavor is returned."""
...
...
@@ -133,14 +131,14 @@ class FlavorAPITest(BaseAPITest):
def
test_wrong_flavor
(
self
):
"""Test 404 result when requesting a flavor that does not exist."""
# XXX: flavors/22 below fails for no apparent reason
response
=
self
.
myget
(
'flavors/%d'
%
23
)
flavor_id
=
max
(
Flavor
.
objects
.
values_list
(
'id'
,
flat
=
True
))
+
1
response
=
self
.
myget
(
'flavors/%d'
%
flavor_id
)
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
)
json
.
loads
(
response
.
content
)
except
ValueError
:
self
.
assertTrue
(
False
)
snf-cyclades-app/synnefo/api/tests/floating_ips.py
View file @
54ffba9b
...
...
@@ -111,7 +111,8 @@ class FloatingIPAPITest(BaseAPITest):
self
.
assertEqual
(
ip
.
network
,
net
)
self
.
assertEqual
(
json
.
loads
(
response
.
content
)[
"floating_ip"
],
{
"instance_id"
:
None
,
"ip"
:
"192.168.2.1"
,
"fixed_ip"
:
None
,
"id"
:
"1"
,
"pool"
:
"1"
})
"fixed_ip"
:
None
,
"id"
:
str
(
ip
.
id
),
"pool"
:
str
(
net
.
id
)})
def
test_reserve_no_pool
(
self
):
# No networks
...
...
@@ -132,9 +133,11 @@ class FloatingIPAPITest(BaseAPITest):
with
mocked_quotaholder
():
response
=
self
.
post
(
URL
,
"test_user"
,
json
.
dumps
({}),
"json"
)
self
.
assertSuccess
(
response
)
ip
=
FloatingIP
.
objects
.
get
()
self
.
assertEqual
(
json
.
loads
(
response
.
content
)[
"floating_ip"
],
{
"instance_id"
:
None
,
"ip"
:
"192.168.2.1"
,
"fixed_ip"
:
None
,
"id"
:
"1"
,
"pool"
:
str
(
net2
.
id
)})
"fixed_ip"
:
None
,
"id"
:
str
(
ip
.
id
),
"pool"
:
str
(
net2
.
id
)})
def
test_reserve_full
(
self
):
net
=
FloatingIPPoolFactory
(
userid
=
"test_user"
,
...
...
@@ -151,9 +154,11 @@ class FloatingIPAPITest(BaseAPITest):
with
mocked_quotaholder
():
response
=
self
.
post
(
URL
,
"test_user"
,
json
.
dumps
(
request
),
"json"
)
self
.
assertSuccess
(
response
)
ip
=
FloatingIP
.
objects
.
get
()
self
.
assertEqual
(
json
.
loads
(
response
.
content
)[
"floating_ip"
],
{
"instance_id"
:
None
,
"ip"
:
"192.168.2.10"
,
"fixed_ip"
:
None
,
"id"
:
"1"
,
"pool"
:
"1"
})
"fixed_ip"
:
None
,
"id"
:
str
(
ip
.
id
),
"pool"
:
str
(
net
.
id
)})
# Already reserved
FloatingIPFactory
(
network
=
net
,
ipv4
=
"192.168.2.3"
)
...
...
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