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
6b58c0c8
Commit
6b58c0c8
authored
Oct 21, 2013
by
Weblate
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
14961b90
0698d420
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
15 deletions
+103
-15
trans/tests/admin.py
trans/tests/admin.py
+34
-0
trans/tests/hooks.py
trans/tests/hooks.py
+56
-0
trans/views/api.py
trans/views/api.py
+13
-15
No files found.
trans/tests/admin.py
View file @
6b58c0c8
...
...
@@ -86,6 +86,40 @@ class AdminTest(ViewTestCase):
response
,
'Importing a new translation can take some time'
)
def
test_subproject
(
self
):
'''
Test for custom subproject actions.
'''
self
.
assertCustomAdmin
(
reverse
(
'admin:trans_subproject_changelist'
)
)
def
test_project
(
self
):
'''
Test for custom project actions.
'''
self
.
assertCustomAdmin
(
reverse
(
'admin:trans_project_changelist'
)
)
def
assertCustomAdmin
(
self
,
url
):
'''
Test for (sub)project custom admin.
'''
response
=
self
.
client
.
get
(
url
)
self
.
assertContains
(
response
,
'Update from git'
)
for
action
in
'force_commit'
,
'update_checks'
,
'update_from_git'
:
response
=
self
.
client
.
post
(
url
,
{
'_selected_action'
:
'1'
,
'action'
:
action
,
}
)
self
.
assertRedirects
(
response
,
url
)
class
SSHKeysTest
(
TestCase
):
def
test_parse
(
self
):
...
...
trans/tests/hooks.py
View file @
6b58c0c8
...
...
@@ -154,6 +154,7 @@ BITBUCKET_PAYLOAD_HG = '''
class
HooksViewTest
(
ViewTestCase
):
def
test_view_hook_project
(
self
):
appsettings
.
BACKGROUND_HOOKS
=
False
appsettings
.
ENABLE_HOOKS
=
True
response
=
self
.
client
.
get
(
reverse
(
'hook-project'
,
kwargs
=
{
'project'
:
self
.
subproject
.
project
.
slug
...
...
@@ -163,6 +164,7 @@ class HooksViewTest(ViewTestCase):
def
test_view_hook_subproject
(
self
):
appsettings
.
BACKGROUND_HOOKS
=
False
appsettings
.
ENABLE_HOOKS
=
True
response
=
self
.
client
.
get
(
reverse
(
'hook-subproject'
,
kwargs
=
{
'project'
:
self
.
subproject
.
project
.
slug
,
...
...
@@ -173,6 +175,7 @@ class HooksViewTest(ViewTestCase):
def
test_view_hook_github
(
self
):
appsettings
.
BACKGROUND_HOOKS
=
False
appsettings
.
ENABLE_HOOKS
=
True
response
=
self
.
client
.
post
(
reverse
(
'hook-github'
),
{
'payload'
:
GITHUB_PAYLOAD
}
...
...
@@ -181,6 +184,7 @@ class HooksViewTest(ViewTestCase):
def
test_view_hook_bitbucket_git
(
self
):
appsettings
.
BACKGROUND_HOOKS
=
False
appsettings
.
ENABLE_HOOKS
=
True
response
=
self
.
client
.
post
(
reverse
(
'hook-bitbucket'
),
{
'payload'
:
BITBUCKET_PAYLOAD_GIT
}
...
...
@@ -189,8 +193,60 @@ class HooksViewTest(ViewTestCase):
def
test_view_hook_bitbucket_hg
(
self
):
appsettings
.
BACKGROUND_HOOKS
=
False
appsettings
.
ENABLE_HOOKS
=
True
response
=
self
.
client
.
post
(
reverse
(
'hook-bitbucket'
),
{
'payload'
:
BITBUCKET_PAYLOAD_HG
}
)
self
.
assertContains
(
response
,
'update triggered'
)
def
test_disabled
(
self
):
'''
Test for hooks disabling.
'''
appsettings
.
ENABLE_HOOKS
=
False
response
=
self
.
client
.
get
(
reverse
(
'hook-project'
,
kwargs
=
{
'project'
:
self
.
subproject
.
project
.
slug
})
)
self
.
assertEquals
(
response
.
status_code
,
405
)
response
=
self
.
client
.
get
(
reverse
(
'hook-subproject'
,
kwargs
=
{
'project'
:
self
.
subproject
.
project
.
slug
,
'subproject'
:
self
.
subproject
.
slug
,
})
)
self
.
assertEquals
(
response
.
status_code
,
405
)
response
=
self
.
client
.
post
(
reverse
(
'hook-github'
),
{
'payload'
:
GITHUB_PAYLOAD
}
)
self
.
assertEquals
(
response
.
status_code
,
405
)
response
=
self
.
client
.
post
(
reverse
(
'hook-bitbucket'
),
{
'payload'
:
BITBUCKET_PAYLOAD_GIT
}
)
self
.
assertEquals
(
response
.
status_code
,
405
)
def
test_wrong_payload
(
self
):
'''
Tests for invalid payloads.
'''
# missing
response
=
self
.
client
.
post
(
reverse
(
'hook-github'
),
)
self
.
assertContains
(
response
,
'missing payload'
,
status_code
=
400
)
# wrong
response
=
self
.
client
.
post
(
reverse
(
'hook-github'
),
{
'payload'
:
'XX'
},
)
self
.
assertContains
(
response
,
'could not parse'
,
status_code
=
400
)
# missing data
response
=
self
.
client
.
post
(
reverse
(
'hook-github'
),
{
'payload'
:
'{}'
},
)
self
.
assertContains
(
response
,
'invalid data'
,
status_code
=
400
)
trans/views/api.py
View file @
6b58c0c8
...
...
@@ -51,6 +51,16 @@ GITHUB_REPOS = (
)
def
perform_update
(
obj
):
'''
Triggers update of given object.
'''
if
appsettings
.
BACKGROUND_HOOKS
:
thread
=
threading
.
Thread
(
target
=
obj
.
do_update
)
thread
.
start
()
else
:
obj
.
do_update
()
@
csrf_exempt
def
update_subproject
(
request
,
project
,
subproject
):
'''
...
...
@@ -59,11 +69,7 @@ def update_subproject(request, project, subproject):
if
not
appsettings
.
ENABLE_HOOKS
:
return
HttpResponseNotAllowed
([])
obj
=
get_subproject
(
request
,
project
,
subproject
,
True
)
if
appsettings
.
BACKGROUND_HOOKS
:
thread
=
threading
.
Thread
(
target
=
obj
.
do_update
)
thread
.
start
()
else
:
obj
.
do_update
()
perform_update
(
obj
)
return
HttpResponse
(
'update triggered'
)
...
...
@@ -75,11 +81,7 @@ def update_project(request, project):
if
not
appsettings
.
ENABLE_HOOKS
:
return
HttpResponseNotAllowed
([])
obj
=
get_project
(
request
,
project
,
True
)
if
appsettings
.
BACKGROUND_HOOKS
:
thread
=
threading
.
Thread
(
target
=
obj
.
do_update
)
thread
.
start
()
else
:
obj
.
do_update
()
perform_update
(
obj
)
return
HttpResponse
(
'update triggered'
)
...
...
@@ -144,11 +146,7 @@ def git_service_hook(request, service):
service_long_name
,
obj
)
if
appsettings
.
BACKGROUND_HOOKS
:
thread
=
threading
.
Thread
(
target
=
obj
.
do_update
)
thread
.
start
()
else
:
obj
.
do_update
()
perform_update
(
obj
)
return
HttpResponse
(
'update triggered'
)
...
...
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