Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
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
433b8374
authored
Apr 19, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix _rename and its tests
🍻
parent
07e58f59
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
circle/vm/operations.py
+9
-7
circle/vm/tests/test_operations.py
+6
-5
No files found.
circle/vm/operations.py
View file @
433b8374
from
__future__
import
absolute_import
,
unicode_literals
from
__future__
import
absolute_import
,
unicode_literals
from
logging
import
getLogger
from
logging
import
getLogger
from
re
import
mat
ch
from
re
import
sear
ch
from
django.core.exceptions
import
PermissionDenied
from
django.core.exceptions
import
PermissionDenied
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -203,13 +203,15 @@ class SaveAsTemplateOperation(InstanceOperation):
...
@@ -203,13 +203,15 @@ class SaveAsTemplateOperation(InstanceOperation):
"""
)
"""
)
icon
=
'save'
icon
=
'save'
def
_rename
(
self
,
name
):
@staticmethod
m
=
match
(
"^(.*)( v(
\
d+))?$"
,
name
)
def
_rename
(
name
):
if
m
.
group
(
3
)
is
None
:
m
=
search
(
r" v(\d+)$"
,
name
)
v
=
2
if
m
:
v
=
int
(
m
.
group
(
1
))
+
1
name
=
search
(
r"^(.*) v(\d+)$"
,
name
)
.
group
(
1
)
else
:
else
:
v
=
int
(
v
)
+
1
v
=
1
return
"
%
s v
%
d"
%
(
m
.
group
(
1
)
,
v
)
return
"
%
s v
%
d"
%
(
name
,
v
)
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
300
,
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
300
,
with_shutdown
=
True
,
**
kwargs
):
with_shutdown
=
True
,
**
kwargs
):
...
...
circle/vm/tests/test_operations.py
View file @
433b8374
...
@@ -44,11 +44,12 @@ class SaveAsTemplateOperationTestCase(TestCase):
...
@@ -44,11 +44,12 @@ class SaveAsTemplateOperationTestCase(TestCase):
assert
SaveAsTemplateOperation
.
id
in
getattr
(
Instance
,
op_reg_name
)
assert
SaveAsTemplateOperation
.
id
in
getattr
(
Instance
,
op_reg_name
)
def
test_rename
(
self
):
def
test_rename
(
self
):
assert
SaveAsTemplateOperation
.
_rename
(
"foo"
)
==
"foo v2"
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo"
),
"foo v1"
)
assert
SaveAsTemplateOperation
.
_rename
(
"foo v2"
)
==
"foo v3"
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v2"
),
"foo v3"
)
assert
SaveAsTemplateOperation
.
_rename
(
"foo v"
)
==
"foo v v2"
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v"
),
"foo v v1"
)
assert
SaveAsTemplateOperation
.
_rename
(
"foo v9"
)
==
"foo v10"
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v9"
),
"foo v10"
)
assert
SaveAsTemplateOperation
.
_rename
(
"foo v111"
)
==
"foo v112"
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v111"
),
"foo v112"
)
class
ShutdownOperationTestCase
(
TestCase
):
class
ShutdownOperationTestCase
(
TestCase
):
...
...
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