Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ca1da568
authored
Aug 04, 2022
by
Fábián János
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
during migration, Operation::asnyc was replaced by _async
parent
a7cae3ff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
22 deletions
+22
-22
circle/dashboard/tests/test_mockedviews.py
+22
-22
No files found.
circle/dashboard/tests/test_mockedviews.py
View file @
ca1da568
...
@@ -44,8 +44,6 @@ class QuerySet(list):
...
@@ -44,8 +44,6 @@ class QuerySet(list):
def
all
(
self
):
def
all
(
self
):
return
self
return
self
class
ViewUserTestCase
(
unittest
.
TestCase
):
class
ViewUserTestCase
(
unittest
.
TestCase
):
def
test_404
(
self
):
def
test_404
(
self
):
...
@@ -170,14 +168,14 @@ class VmOperationViewTestCase(unittest.TestCase):
...
@@ -170,14 +168,14 @@ class VmOperationViewTestCase(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
)
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
.
async
=
MagicMock
()
inst
.
migrate
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
form_kwargs
.
return_value
=
{
form_kwargs
.
return_value
=
{
'default'
:
100
,
'choices'
:
QuerySet
([
node
])}
'default'
:
100
,
'choices'
:
QuerySet
([
node
])}
go
.
return_value
=
inst
go
.
return_value
=
inst
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
not
msg
.
error
.
called
assert
not
msg
.
error
.
called
inst
.
migrate
.
async
.
assert_called_once_with
(
inst
.
migrate
.
_
async
.
assert_called_once_with
(
to_node
=
node
,
live_migration
=
True
,
user
=
request
.
user
)
to_node
=
node
,
live_migration
=
True
,
user
=
request
.
user
)
def
test_migrate_failed
(
self
):
def
test_migrate_failed
(
self
):
...
@@ -191,14 +189,14 @@ class VmOperationViewTestCase(unittest.TestCase):
...
@@ -191,14 +189,14 @@ class VmOperationViewTestCase(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
)
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
.
async
=
MagicMock
()
inst
.
migrate
.
_
async
=
MagicMock
()
inst
.
migrate
.
async
.
side_effect
=
Exception
inst
.
migrate
.
_
async
.
side_effect
=
Exception
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
form_kwargs
.
return_value
=
{
form_kwargs
.
return_value
=
{
'default'
:
100
,
'choices'
:
QuerySet
([
node
])}
'default'
:
100
,
'choices'
:
QuerySet
([
node
])}
go
.
return_value
=
inst
go
.
return_value
=
inst
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
inst
.
migrate
.
async
.
called
assert
inst
.
migrate
.
_
async
.
called
assert
msg
.
error
.
called
assert
msg
.
error
.
called
def
test_migrate_wo_permission
(
self
):
def
test_migrate_wo_permission
(
self
):
...
@@ -211,14 +209,14 @@ class VmOperationViewTestCase(unittest.TestCase):
...
@@ -211,14 +209,14 @@ class VmOperationViewTestCase(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
)
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
.
async
=
MagicMock
()
inst
.
migrate
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
form_kwargs
.
return_value
=
{
form_kwargs
.
return_value
=
{
'default'
:
100
,
'choices'
:
QuerySet
([
node
])}
'default'
:
100
,
'choices'
:
QuerySet
([
node
])}
go
.
return_value
=
inst
go
.
return_value
=
inst
with
self
.
assertRaises
(
PermissionDenied
):
with
self
.
assertRaises
(
PermissionDenied
):
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
not
inst
.
migrate
.
async
.
called
assert
not
inst
.
migrate
.
_
async
.
called
def
test_migrate_template
(
self
):
def
test_migrate_template
(
self
):
"""check if GET dialog's template can be rendered"""
"""check if GET dialog's template can be rendered"""
...
@@ -244,7 +242,7 @@ class VmOperationViewTestCase(unittest.TestCase):
...
@@ -244,7 +242,7 @@ class VmOperationViewTestCase(unittest.TestCase):
inst
.
name
=
"asd"
inst
.
name
=
"asd"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
save_as_template
=
Instance
.
_ops
[
'save_as_template'
](
inst
)
inst
.
save_as_template
=
Instance
.
_ops
[
'save_as_template'
](
inst
)
inst
.
save_as_template
.
async
=
MagicMock
()
inst
.
save_as_template
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
go
.
return_value
=
inst
go
.
return_value
=
inst
assert
view
.
as_view
()(
request
,
pk
=
1234
)
assert
view
.
as_view
()(
request
,
pk
=
1234
)
...
@@ -261,7 +259,7 @@ class VmOperationViewTestCase(unittest.TestCase):
...
@@ -261,7 +259,7 @@ class VmOperationViewTestCase(unittest.TestCase):
inst
.
name
=
"asd"
inst
.
name
=
"asd"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
save_as_template
=
Instance
.
_ops
[
'save_as_template'
](
inst
)
inst
.
save_as_template
=
Instance
.
_ops
[
'save_as_template'
](
inst
)
inst
.
save_as_template
.
async
=
MagicMock
()
inst
.
save_as_template
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
go
.
return_value
=
inst
go
.
return_value
=
inst
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
...
@@ -334,7 +332,7 @@ class VmMassOperationViewTestCase(unittest.TestCase):
...
@@ -334,7 +332,7 @@ class VmMassOperationViewTestCase(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
)
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
=
Instance
.
_ops
[
'migrate'
](
inst
)
inst
.
migrate
.
async
=
MagicMock
()
inst
.
migrate
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
go
.
return_value
=
[
inst
]
go
.
return_value
=
[
inst
]
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
assert
view
.
as_view
()(
request
,
pk
=
1234
)[
'location'
]
...
@@ -413,13 +411,13 @@ class RenewViewTest(unittest.TestCase):
...
@@ -413,13 +411,13 @@ class RenewViewTest(unittest.TestCase):
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
go
.
return_value
=
inst
go
.
return_value
=
inst
assert
view
.
as_view
()(
request
,
pk
=
1234
)
assert
view
.
as_view
()(
request
,
pk
=
1234
)
assert
not
msg
.
error
.
called
assert
not
msg
.
error
.
called
assert
inst
.
renew
.
async
.
called_with
(
user
=
request
.
user
,
lease
=
None
)
assert
inst
.
renew
.
_
async
.
called_with
(
user
=
request
.
user
,
lease
=
None
)
assert
inst
.
renew
.
async
.
return_value
.
get
.
called
assert
inst
.
renew
.
_
async
.
return_value
.
get
.
called
# success would redirect
# success would redirect
def
test_renew_by_owner_w_param
(
self
):
def
test_renew_by_owner_w_param
(
self
):
...
@@ -432,7 +430,7 @@ class RenewViewTest(unittest.TestCase):
...
@@ -432,7 +430,7 @@ class RenewViewTest(unittest.TestCase):
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
True
inst
.
has_level
.
return_value
=
True
go
.
return_value
=
inst
go
.
return_value
=
inst
assert
view
.
as_view
()(
request
,
pk
=
1234
)
assert
view
.
as_view
()(
request
,
pk
=
1234
)
...
@@ -446,7 +444,7 @@ class RenewViewTest(unittest.TestCase):
...
@@ -446,7 +444,7 @@ class RenewViewTest(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
)
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
False
inst
.
has_level
.
return_value
=
False
go
.
return_value
=
inst
go
.
return_value
=
inst
self
.
assertIn
(
'login'
,
self
.
assertIn
(
'login'
,
...
@@ -460,7 +458,7 @@ class RenewViewTest(unittest.TestCase):
...
@@ -460,7 +458,7 @@ class RenewViewTest(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
)
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
False
inst
.
has_level
.
return_value
=
False
go
.
return_value
=
inst
go
.
return_value
=
inst
with
self
.
assertRaises
(
PermissionDenied
):
with
self
.
assertRaises
(
PermissionDenied
):
...
@@ -475,7 +473,7 @@ class RenewViewTest(unittest.TestCase):
...
@@ -475,7 +473,7 @@ class RenewViewTest(unittest.TestCase):
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
False
inst
.
has_level
.
return_value
=
False
go
.
return_value
=
inst
go
.
return_value
=
inst
with
self
.
assertRaises
(
PermissionDenied
):
with
self
.
assertRaises
(
PermissionDenied
):
...
@@ -486,8 +484,9 @@ class RenewViewTest(unittest.TestCase):
...
@@ -486,8 +484,9 @@ class RenewViewTest(unittest.TestCase):
view
=
vm_ops
[
'renew'
]
view
=
vm_ops
[
'renew'
]
inst
=
MagicMock
(
spec
=
Instance
,
pk
=
11
)
inst
=
MagicMock
(
spec
=
Instance
,
pk
=
11
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
key
=
view
.
get_token_url
(
inst
,
user
)
.
split
(
'?'
)[
1
]
.
split
(
'='
)[
1
]
key
=
view
.
get_token_url
(
inst
,
user
)
.
split
(
'?'
)[
1
]
.
split
(
'='
)[
1
]
request
=
FakeRequestFactory
(
GET
=
{
'k'
:
key
})
# other user!
request
=
FakeRequestFactory
(
GET
=
{
'k'
:
key
})
# other user!
...
@@ -504,8 +503,9 @@ class RenewViewTest(unittest.TestCase):
...
@@ -504,8 +503,9 @@ class RenewViewTest(unittest.TestCase):
view
=
vm_ops
[
'renew'
]
view
=
vm_ops
[
'renew'
]
inst
=
MagicMock
(
spec
=
Instance
,
pk
=
11
)
inst
=
MagicMock
(
spec
=
Instance
,
pk
=
11
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
lease
=
MagicMock
(
pk
=
99
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
=
lambda
user
,
level
:
user
.
is_authenticated
inst
.
has_level
=
lambda
user
,
level
:
user
.
is_authenticated
key
=
view
.
get_token_url
(
inst
,
user
)
.
split
(
'?'
)[
1
]
.
split
(
'='
)[
1
]
key
=
view
.
get_token_url
(
inst
,
user
)
.
split
(
'?'
)[
1
]
.
split
(
'='
)[
1
]
request
=
FakeRequestFactory
(
GET
=
{
'k'
:
key
},
authenticated
=
False
)
request
=
FakeRequestFactory
(
GET
=
{
'k'
:
key
},
authenticated
=
False
)
...
@@ -541,7 +541,7 @@ class RenewViewTest(unittest.TestCase):
...
@@ -541,7 +541,7 @@ class RenewViewTest(unittest.TestCase):
inst
=
MagicMock
(
spec
=
Instance
,
pk
=
11
)
inst
=
MagicMock
(
spec
=
Instance
,
pk
=
11
)
inst
.
_meta
.
object_name
=
"Instance"
inst
.
_meta
.
object_name
=
"Instance"
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
=
Instance
.
_ops
[
'renew'
](
inst
)
inst
.
renew
.
async
=
MagicMock
()
inst
.
renew
.
_
async
=
MagicMock
()
inst
.
has_level
.
return_value
=
False
inst
.
has_level
.
return_value
=
False
key
=
view
.
get_token_url
(
inst
,
user
)
.
split
(
'?'
)[
1
]
.
split
(
'='
)[
1
]
key
=
view
.
get_token_url
(
inst
,
user
)
.
split
(
'?'
)[
1
]
.
split
(
'='
)[
1
]
with
patch
(
'dashboard.views.signing.loads'
)
as
loader
,
\
with
patch
(
'dashboard.views.signing.loads'
)
as
loader
,
\
...
...
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