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
e90354cf
Commit
e90354cf
authored
Dec 14, 2012
by
Christos Stavrakakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include Pool tests to Django testsuite
parent
48f9d663
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
19 deletions
+44
-19
snf-cyclades-app/synnefo/db/pools/__init__.py
snf-cyclades-app/synnefo/db/pools/__init__.py
+1
-1
snf-cyclades-app/synnefo/db/pools/tests.py
snf-cyclades-app/synnefo/db/pools/tests.py
+40
-17
snf-cyclades-app/synnefo/db/tests.py
snf-cyclades-app/synnefo/db/tests.py
+3
-1
No files found.
snf-cyclades-app/synnefo/db/pools/__init__.py
View file @
e90354cf
...
...
@@ -43,7 +43,7 @@ class PoolManager(object):
def
add_padding
(
self
,
pool_size
):
bits
=
find_padding
(
pool_size
)
self
.
available
.
extend
([
AVAILABLE
]
*
bits
)
self
.
available
.
extend
([
UN
AVAILABLE
]
*
bits
)
self
.
reserved
.
extend
([
UNAVAILABLE
]
*
bits
)
def
cut_padding
(
self
,
pool_size
):
...
...
snf-cyclades-app/synnefo/db/pools/tests.py
View file @
e90354cf
import
sys
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
django.test
import
TestCase
from
synnefo.db.pools
import
(
PoolManager
,
EmptyPool
,
BridgePool
,
MacPrefixPool
,
IPPool
)
from
bitarray
import
bitarray
# Use backported unittest functionality if Python < 2.7
try
:
import
unittest2
as
unittest
except
ImportError
:
if
sys
.
version_info
<
(
2
,
7
):
raise
Exception
(
"The unittest2 package is required for Python < 2.7"
)
import
unittest
class
DummyObject
():
def
__init__
(
self
,
size
):
...
...
@@ -31,7 +57,7 @@ class DummyPool(PoolManager):
return
value
class
PoolManagerTestCase
(
unittest
.
TestCase
):
class
PoolManagerTestCase
(
TestCase
):
def
test_created_pool
(
self
):
obj
=
DummyObject
(
42
)
pool
=
DummyPool
(
obj
)
...
...
@@ -111,7 +137,7 @@ class PoolManagerTestCase(unittest.TestCase):
self
.
assertEqual
(
pool
.
reserved
,
bitarray
(
'1'
*
39
+
'0'
*
1
))
class
BridgePoolTestCase
(
unittest
.
TestCase
):
class
BridgePoolTestCase
(
TestCase
):
def
test_bridge_conversion
(
self
):
obj
=
DummyObject
(
13
)
obj
.
base
=
"bridge"
...
...
@@ -125,7 +151,7 @@ class BridgePoolTestCase(unittest.TestCase):
self
.
assertEqual
(
pool
.
empty
(),
True
)
class
MacPrefixPoolTestCase
(
unittest
.
TestCase
):
class
MacPrefixPoolTestCase
(
TestCase
):
def
test_invalid_mac_reservation
(
self
):
obj
=
DummyObject
(
65636
)
obj
.
base
=
'ab:ff:ff'
...
...
@@ -133,7 +159,8 @@ class MacPrefixPoolTestCase(unittest.TestCase):
for
i
in
range
(
0
,
65536
):
self
.
assertEqual
(
pool
.
is_available
(
i
,
index
=
True
),
False
)
class
IPPoolTestCase
(
unittest
.
TestCase
):
class
IPPoolTestCase
(
TestCase
):
def
test_auto_reservations
(
self
):
obj
=
DummyObject
(
0
)
network
=
DummyObject
(
0
)
...
...
@@ -158,7 +185,3 @@ class IPPoolTestCase(unittest.TestCase):
self
.
assertEqual
(
pool
.
is_available
(
'192.168.2.1'
),
False
)
self
.
assertEqual
(
pool
.
size
(),
8
)
self
.
assertEqual
(
pool
.
empty
(),
True
)
if
__name__
==
'__main__'
:
unittest
.
main
()
snf-cyclades-app/synnefo/db/tests.py
View file @
e90354cf
...
...
@@ -32,9 +32,11 @@
# Provides automated tests for db module
from
synnefo.db.models
import
*
from
django.test
import
TestCase
# Import pool tests
from
synnefo.db.pools.tests
import
*
class
FlavorTestCase
(
TestCase
):
fixtures
=
[
'db_test_data'
]
...
...
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