Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
64b221ef
authored
Jul 15, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: more tests and a doc comment
parent
bac19e65
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletions
+44
-1
one/models.py
+3
-0
one/tests/test_models.py
+41
-1
No files found.
one/models.py
View file @
64b221ef
...
@@ -226,6 +226,9 @@ class Share(models.Model):
...
@@ -226,6 +226,9 @@ class Share(models.Model):
@classmethod
@classmethod
def
extend_type
(
cls
,
t
):
def
extend_type
(
cls
,
t
):
"""Extend the share's type descriptor with absolute deletion and
suspension time values based on the current time and intervals
already set."""
t
[
'deletex'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'delete'
]
t
[
'deletex'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'delete'
]
if
t
[
'delete'
]
else
None
)
if
t
[
'delete'
]
else
None
)
t
[
'suspendx'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'suspend'
]
t
[
'suspendx'
]
=
(
datetime
.
now
()
+
td
(
seconds
=
1
)
+
t
[
'suspend'
]
...
...
one/tests/test_models.py
View file @
64b221ef
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
mock
import
Mock
from
mock
import
Mock
,
patch
from
nose
import
with_setup
from
nose
import
with_setup
from
nose.tools
import
raises
from
nose.tools
import
raises
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
...
@@ -128,6 +128,19 @@ def test_set_quota():
...
@@ -128,6 +128,19 @@ def test_set_quota():
@with_setup
(
create_user
,
delete_user
)
@with_setup
(
create_user
,
delete_user
)
@patch
(
'one.models.StoreApi'
)
def
test_set_quota_without_store_user
(
MockStoreApi
):
MockStoreApi
.
userexist
=
Mock
(
return_value
=
False
)
MockStoreApi
.
createuser
=
Mock
()
user
=
User
.
objects
.
get
(
username
=
"testuser"
)
details
=
user
.
cloud_details
set_quota
(
None
,
details
,
None
)
MockStoreApi
.
userexist
.
assert_called_once_with
(
user
.
username
)
assert
MockStoreApi
.
createuser
.
called
assert
MockStoreApi
.
createuser
.
call_count
==
1
@with_setup
(
create_user
,
delete_user
)
def
test_reset_keys_when_created
():
def
test_reset_keys_when_created
():
mock_details
=
Mock
()
mock_details
=
Mock
()
mock_details
.
reset_smb
=
Mock
(
return_value
=
None
)
mock_details
.
reset_smb
=
Mock
(
return_value
=
None
)
...
@@ -183,3 +196,30 @@ def test_OpenSshKeyValidator_with_invalid_key_data():
...
@@ -183,3 +196,30 @@ def test_OpenSshKeyValidator_with_invalid_key_data():
key_parts
[
1
]
=
key_parts
[
1
][
1
:]
key_parts
[
1
]
=
key_parts
[
1
][
1
:]
public_key
=
' '
.
join
(
key_parts
)
public_key
=
' '
.
join
(
key_parts
)
validator
(
public_key
)
validator
(
public_key
)
def
test_Share_extend_type
():
t
=
{
'delete'
:
timedelta
(
weeks
=
2
),
'suspend'
:
timedelta
(
weeks
=
1
)}
Share
.
extend_type
(
t
)
assert
'deletex'
in
t
assert
'suspendx'
in
t
assert
t
[
'deletex'
]
is
not
None
assert
t
[
'suspendx'
]
is
not
None
def
test_Share_extend_type_with_no_deletion_interval
():
t
=
{
'delete'
:
None
,
'suspend'
:
timedelta
(
weeks
=
1
)}
Share
.
extend_type
(
t
)
assert
'deletex'
in
t
assert
'suspendx'
in
t
assert
t
[
'deletex'
]
is
None
assert
t
[
'suspendx'
]
is
not
None
def
test_Share_extend_type_with_no_suspension_interval
():
t
=
{
'delete'
:
timedelta
(
weeks
=
2
),
'suspend'
:
None
}
Share
.
extend_type
(
t
)
assert
'deletex'
in
t
assert
'suspendx'
in
t
assert
t
[
'deletex'
]
is
not
None
assert
t
[
'suspendx'
]
is
None
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