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
fe837dbc
Commit
fe837dbc
authored
Feb 16, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split validation tests to invidual cases
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
453afae1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
47 deletions
+57
-47
weblate/trans/tests/test_subproject.py
weblate/trans/tests/test_subproject.py
+57
-47
No files found.
weblate/trans/tests/test_subproject.py
View file @
fe837dbc
...
...
@@ -386,81 +386,93 @@ class SubProjectValidationTest(RepoTestCase):
"""
SubProject object validation testing.
"""
def
test_validation
(
self
):
project
=
self
.
create_subproject
()
# Correct project
project
.
full_clean
()
# Invalid commit message
project
.
commit_message
=
'%(foo)s'
def
setUp
(
self
):
super
(
SubProjectValidationTest
,
self
).
setUp
()
self
.
component
=
self
.
create_subproject
()
# Ensure we have correct component
self
.
component
.
full_clean
()
def
test_commit_message
(
self
):
"""Invalid commit message"""
self
.
component
.
commit_message
=
'%(foo)s'
self
.
assertRaisesMessage
(
ValidationError
,
'Bad format string'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
# Invalid mask
project
.
filemask
=
'foo/x.po'
def
test_filemask
(
self
):
"""Invalid mask"""
self
.
component
.
filemask
=
'foo/x.po'
self
.
assertRaisesMessage
(
ValidationError
,
'File mask does not contain * as a language placeholder!'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
# Not matching mask
project
.
filemask
=
'foo/*.po'
def
test_no_matches
(
self
):
"""Not matching mask"""
self
.
component
.
filemask
=
'foo/*.po'
self
.
assertRaisesMessage
(
ValidationError
,
'The mask did not match any files!'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
# Unknown file format
project
.
filemask
=
'invalid/*.invalid'
def
test_fileformat
(
self
):
"""Unknown file format"""
self
.
component
.
filemask
=
'invalid/*.invalid'
self
.
assertRaisesMessage
(
ValidationError
,
'Format of 2 matched files could not be recognized.'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
# Repoweb
project
.
repoweb
=
'http://%(foo)s/%(bar)s/%72'
def
test_repoweb
(
self
):
"""Invalid repoweb format"""
self
.
component
.
repoweb
=
'http://%(foo)s/%(bar)s/%72'
self
.
assertRaisesMessage
(
ValidationError
,
"Bad format string ('foo')"
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
projec
t
.
repoweb
=
''
self
.
componen
t
.
repoweb
=
''
# Bad link
project
.
repo
=
'weblate://foo'
project
.
push
=
''
def
test_link_incomplete
(
self
):
"""Incomplete link"""
self
.
component
.
repo
=
'weblate://foo'
self
.
component
.
push
=
''
self
.
assertRaisesMessage
(
ValidationError
,
'Invalid link to a Weblate project, '
'use weblate://project/component.'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
# Bad link
project
.
repo
=
'weblate://foo/bar'
project
.
push
=
''
def
test_link_nonexisting
(
self
):
"""Link to non existing project"""
self
.
component
.
repo
=
'weblate://foo/bar'
self
.
component
.
push
=
''
self
.
assertRaisesMessage
(
ValidationError
,
'Invalid link to a Weblate project, '
'use weblate://project/component.'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
# Bad link
project
.
repo
=
'weblate://test/test'
project
.
push
=
''
def
test_link_self
(
self
):
"""Link pointing to self"""
self
.
component
.
repo
=
'weblate://test/test'
self
.
component
.
push
=
''
self
.
assertRaisesMessage
(
ValidationError
,
'Invalid link to a Weblate project, '
'can not link to self!'
,
projec
t
.
full_clean
self
.
componen
t
.
full_clean
)
def
test_validation_mono
(
self
):
self
.
component
.
project
.
delete
()
project
=
self
.
create_po_mono
()
# Correct project
project
.
full_clean
()
...
...
@@ -473,45 +485,43 @@ class SubProjectValidationTest(RepoTestCase):
)
def
test_validation_languge_re
(
self
):
subproject
=
self
.
create_subproject
()
subproject
.
language_regex
=
'[-'
self
.
component
.
language_regex
=
'[-'
self
.
assertRaises
(
ValidationError
,
s
ubprojec
t
.
full_clean
s
elf
.
componen
t
.
full_clean
)
def
test_validation_newlang
(
self
):
subproject
=
self
.
create_subproject
()
subproject
.
new_base
=
'po/project.pot'
subproject
.
save
()
self
.
component
.
new_base
=
'po/project.pot'
self
.
component
.
save
()
# Check that it warns about unused pot
self
.
assertRaisesMessage
(
ValidationError
,
'Base file for new translations is not used '
'because of component settings.'
,
s
ubprojec
t
.
full_clean
s
elf
.
componen
t
.
full_clean
)
s
ubprojec
t
.
new_lang
=
'add'
s
ubprojec
t
.
save
()
s
elf
.
componen
t
.
new_lang
=
'add'
s
elf
.
componen
t
.
save
()
# Check that it warns about not supported format
self
.
assertRaisesMessage
(
ValidationError
,
'Chosen file format does not support adding new '
'translations as chosen in project settings.'
,
s
ubprojec
t
.
full_clean
s
elf
.
componen
t
.
full_clean
)
s
ubprojec
t
.
file_format
=
'po'
s
ubprojec
t
.
save
()
s
elf
.
componen
t
.
file_format
=
'po'
s
elf
.
componen
t
.
save
()
# Clean class cache, pylint: disable=W0212
s
ubprojec
t
.
_file_format
=
None
s
elf
.
componen
t
.
_file_format
=
None
# With correct format it should validate
s
ubprojec
t
.
full_clean
()
s
elf
.
componen
t
.
full_clean
()
def
test_lang_code
(
self
):
subproject
=
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