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
6bda764a
Commit
6bda764a
authored
Jan 14, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate autotranslation tests
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
39d35f1d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
48 deletions
+76
-48
weblate/trans/tests/test_autotranslate.py
weblate/trans/tests/test_autotranslate.py
+75
-0
weblate/trans/tests/test_views.py
weblate/trans/tests/test_views.py
+1
-48
No files found.
weblate/trans/tests/test_autotranslate.py
0 → 100644
View file @
6bda764a
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2016 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Tests for automatic translation
"""
from
django.core.urlresolvers
import
reverse
from
weblate.trans.models
import
SubProject
from
weblate.trans.tests.test_views
import
ViewTestCase
class
AutoTranslationTest
(
ViewTestCase
):
def
setUp
(
self
):
super
(
AutoTranslationTest
,
self
).
setUp
()
# Need extra power
self
.
user
.
is_superuser
=
True
self
.
user
.
save
()
self
.
subproject2
=
SubProject
.
objects
.
create
(
name
=
'Test 2'
,
slug
=
'test-2'
,
project
=
self
.
project
,
repo
=
self
.
git_repo_path
,
push
=
self
.
git_repo_path
,
vcs
=
'git'
,
filemask
=
'po/*.po'
,
template
=
''
,
file_format
=
'po'
,
new_base
=
''
,
allow_translation_propagation
=
False
,
)
def
test_none
(
self
):
'''
Tests for automatic translation with no content.
'''
url
=
reverse
(
'auto_translation'
,
kwargs
=
self
.
kw_translation
)
response
=
self
.
client
.
post
(
url
)
self
.
assertRedirects
(
response
,
self
.
translation_url
)
def
test_different
(
self
):
'''
Tests for automatic translation with different content.
'''
self
.
edit_unit
(
'Hello, world!
\
n
'
,
'Nazdar svete!
\
n
'
)
params
=
{
'project'
:
'test'
,
'lang'
:
'cs'
,
'subproject'
:
'test-2'
}
url
=
reverse
(
'auto_translation'
,
kwargs
=
params
)
response
=
self
.
client
.
post
(
url
)
self
.
assertRedirects
(
response
,
reverse
(
'translation'
,
kwargs
=
params
))
# Check we've translated something
translation
=
self
.
subproject2
.
translation_set
.
get
(
language_code
=
'cs'
)
self
.
assertEqual
(
translation
.
translated
,
1
)
weblate/trans/tests/test_views.py
View file @
6bda764a
...
...
@@ -35,7 +35,7 @@ from django.core import mail
from
PIL
import
Image
from
weblate.trans.models
import
WhiteboardMessage
,
SubProject
from
weblate.trans.models
import
WhiteboardMessage
from
weblate.trans.tests.test_models
import
RepoTestCase
from
weblate.accounts.models
import
Profile
...
...
@@ -451,50 +451,3 @@ class SourceStringsTest(ViewTestCase):
reverse
(
'show_source'
,
kwargs
=
self
.
kw_subproject
)
)
self
.
assertContains
(
response
,
'Test/Test'
)
class
AutoTranslationTest
(
ViewTestCase
):
def
setUp
(
self
):
super
(
AutoTranslationTest
,
self
).
setUp
()
# Need extra power
self
.
user
.
is_superuser
=
True
self
.
user
.
save
()
self
.
subproject2
=
SubProject
.
objects
.
create
(
name
=
'Test 2'
,
slug
=
'test-2'
,
project
=
self
.
project
,
repo
=
self
.
git_repo_path
,
push
=
self
.
git_repo_path
,
vcs
=
'git'
,
filemask
=
'po/*.po'
,
template
=
''
,
file_format
=
'po'
,
new_base
=
''
,
allow_translation_propagation
=
False
,
)
def
test_none
(
self
):
'''
Tests for automatic translation with no content.
'''
url
=
reverse
(
'auto_translation'
,
kwargs
=
self
.
kw_translation
)
response
=
self
.
client
.
post
(
url
)
self
.
assertRedirects
(
response
,
self
.
translation_url
)
def
test_different
(
self
):
'''
Tests for automatic translation with different content.
'''
self
.
edit_unit
(
'Hello, world!
\
n
'
,
'Nazdar svete!
\
n
'
)
params
=
{
'project'
:
'test'
,
'lang'
:
'cs'
,
'subproject'
:
'test-2'
}
url
=
reverse
(
'auto_translation'
,
kwargs
=
params
)
response
=
self
.
client
.
post
(
url
)
self
.
assertRedirects
(
response
,
reverse
(
'translation'
,
kwargs
=
params
))
# Check we've translated something
translation
=
self
.
subproject2
.
translation_set
.
get
(
language_code
=
'cs'
)
self
.
assertEqual
(
translation
.
translated
,
1
)
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