Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
586d86e0
authored
Mar 20, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage/tests: added save_as exception tests
parent
d0690629
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
circle/storage/tests/test_models.py
+35
-0
No files found.
circle/storage/tests/test_models.py
View file @
586d86e0
...
@@ -2,9 +2,11 @@ from datetime import timedelta
...
@@ -2,9 +2,11 @@ from datetime import timedelta
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.utils
import
timezone
from
django.utils
import
timezone
from
mock
import
MagicMock
from
..models
import
Disk
,
DataStore
from
..models
import
Disk
,
DataStore
old
=
timezone
.
now
()
-
timedelta
(
days
=
2
)
old
=
timezone
.
now
()
-
timedelta
(
days
=
2
)
new
=
timezone
.
now
()
-
timedelta
(
hours
=
2
)
new
=
timezone
.
now
()
-
timedelta
(
hours
=
2
)
...
@@ -46,3 +48,36 @@ class DiskTestCase(TestCase):
...
@@ -46,3 +48,36 @@ class DiskTestCase(TestCase):
self
.
_disk
(
base
=
d
,
destroyed
=
new
)
self
.
_disk
(
base
=
d
,
destroyed
=
new
)
self
.
_disk
(
base
=
d
)
self
.
_disk
(
base
=
d
)
assert
not
d
.
is_deletable
assert
not
d
.
is_deletable
def
test_save_as_disk_in_use_error
(
self
):
class
MockException
(
Exception
):
pass
d
=
MagicMock
(
spec
=
Disk
)
d
.
DiskInUseError
=
MockException
d
.
type
=
"qcow2-norm"
d
.
is_in_use
=
True
with
self
.
assertRaises
(
MockException
):
Disk
.
save_as
(
d
)
def
test_save_as_wrong_type
(
self
):
class
MockException
(
Exception
):
pass
d
=
MagicMock
(
spec
=
Disk
)
d
.
WrongDiskTypeError
=
MockException
d
.
type
=
"wrong"
with
self
.
assertRaises
(
MockException
):
Disk
.
save_as
(
d
)
def
test_save_as_disk_not_ready
(
self
):
class
MockException
(
Exception
):
pass
d
=
MagicMock
(
spec
=
Disk
)
d
.
DiskIsNotReady
=
MockException
d
.
type
=
"qcow2-norm"
d
.
is_in_use
=
False
d
.
ready
=
False
with
self
.
assertRaises
(
MockException
):
Disk
.
save_as
(
d
)
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