Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
0d68a923
Commit
0d68a923
authored
Aug 20, 2015
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for proper functionality of post_update script
Issue #811 Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
010a08e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
weblate/trans/tests/test_scripts.py
weblate/trans/tests/test_scripts.py
+48
-0
No files found.
weblate/trans/tests/test_scripts.py
View file @
0d68a923
...
...
@@ -21,9 +21,35 @@
from
weblate.trans.tests.test_models
import
RepoTestCase
from
weblate.trans.scripts
import
run_hook
import
tempfile
import
os
import
stat
class
ScriptTest
(
RepoTestCase
):
output
=
None
script
=
None
def
setUp
(
self
):
super
(
ScriptTest
,
self
).
setUp
()
self
.
output
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
self
.
script
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
self
.
output
.
close
()
self
.
script
.
write
(
'#!/bin/sh
\
n
'
)
self
.
script
.
write
(
'echo "$WL_PATH" >> {0}
\
n
'
.
format
(
self
.
output
.
name
))
self
.
script
.
close
()
st
=
os
.
stat
(
self
.
script
.
name
)
os
.
chmod
(
self
.
script
.
name
,
st
.
st_mode
|
stat
.
S_IEXEC
)
def
tearDown
(
self
):
super
(
ScriptTest
,
self
).
tearDown
()
if
self
.
output
is
not
None
:
os
.
unlink
(
self
.
output
.
name
)
self
.
output
=
None
if
self
.
script
is
not
None
:
os
.
unlink
(
self
.
script
.
name
)
self
.
script
=
None
def
test_run_hook
(
self
):
subproject
=
self
.
create_subproject
()
self
.
assertFalse
(
...
...
@@ -32,3 +58,25 @@ class ScriptTest(RepoTestCase):
self
.
assertTrue
(
run_hook
(
subproject
,
'true'
)
)
def
assert_content
(
self
,
subproject
):
"""Checks file content and cleans it."""
with
open
(
self
.
output
.
name
,
'r'
)
as
handle
:
data
=
handle
.
read
()
self
.
assertIn
(
subproject
.
get_path
(),
data
)
with
open
(
self
.
output
.
name
,
'w'
)
as
handle
:
handle
.
write
(
''
)
def
test_post_update
(
self
):
subproject
=
self
.
_create_subproject
(
'po'
,
'po/*.po'
,
post_update_script
=
self
.
script
.
name
)
# Hook should fire on creation
self
.
assert_content
(
subproject
)
subproject
.
update_branch
()
# Hook should fire on update
self
.
assert_content
(
subproject
)
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