Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
logging
import
getLogger
from
re
import
mat
ch
from
re
import
sear
ch
from
django.core.exceptions
import
PermissionDenied
from
django.utils
import
timezone
...
...
@@ -203,13 +203,15 @@ class SaveAsTemplateOperation(InstanceOperation):
"""
)
icon
=
'save'
def
_rename
(
self
,
name
):
m
=
match
(
"^(.*)( v(
\
d+))?$"
,
name
)
if
m
.
group
(
3
)
is
None
:
v
=
2
@staticmethod
def
_rename
(
name
):
m
=
search
(
r" v(\d+)$"
,
name
)
if
m
:
v
=
int
(
m
.
group
(
1
))
+
1
name
=
search
(
r"^(.*) v(\d+)$"
,
name
)
.
group
(
1
)
else
:
v
=
int
(
v
)
+
1
return
"
%
s v
%
d"
%
(
m
.
group
(
1
)
,
v
)
v
=
1
return
"
%
s v
%
d"
%
(
name
,
v
)
def
_operation
(
self
,
activity
,
user
,
system
,
timeout
=
300
,
with_shutdown
=
True
,
**
kwargs
):
...
...
circle/vm/tests/test_operations.py
View file @
433b8374
...
...
@@ -44,11 +44,12 @@ class SaveAsTemplateOperationTestCase(TestCase):
assert
SaveAsTemplateOperation
.
id
in
getattr
(
Instance
,
op_reg_name
)
def
test_rename
(
self
):
assert
SaveAsTemplateOperation
.
_rename
(
"foo"
)
==
"foo v2"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v2"
)
==
"foo v3"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v"
)
==
"foo v v2"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v9"
)
==
"foo v10"
assert
SaveAsTemplateOperation
.
_rename
(
"foo v111"
)
==
"foo v112"
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo"
),
"foo v1"
)
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v2"
),
"foo v3"
)
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v"
),
"foo v v1"
)
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v9"
),
"foo v10"
)
self
.
assertEqual
(
SaveAsTemplateOperation
.
_rename
(
"foo v111"
),
"foo v112"
)
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