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
951ba07e
Commit
951ba07e
authored
Mar 25, 2014
by
Michal Čihař
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #461 from vrusinov/fix_tests
Add config for running tests using django-nose
parents
c495e10d
745433f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
133 additions
and
25 deletions
+133
-25
pylint.rc
pylint.rc
+1
-1
weblate/settings_test_nose.py
weblate/settings_test_nose.py
+108
-0
weblate/trans/tests/test_models.py
weblate/trans/tests/test_models.py
+24
-24
No files found.
pylint.rc
View file @
951ba07e
...
...
@@ -5,7 +5,7 @@ profile=no
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=migrations,settings.py,settings_test.py,settings_test_mysql.py,settings_test_postgresql.py,settings_test_sqlite.py,.git,test-repos,repos
ignore=migrations,settings.py,settings_test.py,settings_test_mysql.py,settings_test_postgresql.py,settings_test_sqlite.py,.git,test-repos,repos
,settings_test_nose.py
# Pickle collected data for later comparisons.
persistent=yes
...
...
weblate/settings_test_nose.py
0 → 100644
View file @
951ba07e
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2014 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <http://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/>.
#
"""
Django settings for running testsuite using django-nose.
Django-nose have some advantages over default django test suite, most notable
are:
- It will testing just your weblate by default, not all the standard things
that happen to be in INSTALLED_APPS. On my installation many django tests
fail for unrelated to weblate reasons.
- It will let more precise specification of what tests to run.
"""
from
weblate.settings_example
import
*
import
os
if
'TRAVIS_DATABASE'
in
os
.
environ
:
if
os
.
environ
[
'TRAVIS_DATABASE'
]
==
'mysql'
:
DATABASES
[
'default'
][
'ENGINE'
]
=
'django.db.backends.mysql'
DATABASES
[
'default'
][
'NAME'
]
=
'weblate'
DATABASES
[
'default'
][
'USER'
]
=
'root'
DATABASES
[
'default'
][
'PASSWORD'
]
=
''
elif
os
.
environ
[
'TRAVIS_DATABASE'
]
==
'postgresql'
:
DATABASES
[
'default'
][
'ENGINE'
]
=
\
'django.db.backends.postgresql_psycopg2'
DATABASES
[
'default'
][
'NAME'
]
=
'weblate'
DATABASES
[
'default'
][
'USER'
]
=
'postgres'
DATABASES
[
'default'
][
'PASSWORD'
]
=
''
# Configure admins
ADMINS
=
((
'Weblate test'
,
'noreply@weblate.org'
),
)
# Different root for test repos
GIT_ROOT
=
'%s/test-repos/'
%
WEB_ROOT
# Avoid migrating during testsuite
SOUTH_TESTS_MIGRATE
=
False
# Fake access to Microsoft Translator
MT_MICROSOFT_ID
=
'ID'
MT_MICROSOFT_SECRET
=
'SECRET'
# Fake Google translate API key
MT_GOOGLE_KEY
=
'KEY'
# To get higher limit for testing
MT_MYMEMORY_EMAIL
=
'test@weblate.org'
# Enable some machine translations
MACHINE_TRANSLATION_SERVICES
=
(
'weblate.trans.machine.microsoft.MicrosoftTranslation'
,
'weblate.trans.machine.dummy.DummyTranslation'
,
)
# Silent logging setup
LOGGING
=
{
'version'
:
1
,
'disable_existing_loggers'
:
False
,
'filters'
:
{
'require_debug_false'
:
{
'()'
:
'django.utils.log.RequireDebugFalse'
}
},
'handlers'
:
{
'mail_admins'
:
{
'level'
:
'ERROR'
,
'filters'
:
[
'require_debug_false'
],
'class'
:
'django.utils.log.AdminEmailHandler'
},
},
'loggers'
:
{
'django.request'
:
{
'handlers'
:
[
'mail_admins'
],
'level'
:
'ERROR'
,
'propagate'
:
True
,
},
'weblate'
:
{
'handlers'
:
[],
'level'
:
'ERROR'
,
}
}
}
INSTALLED_APPS
=
INSTALLED_APPS
+
(
'django_nose'
,
)
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
# Override default test match regexp (?:^|[\\b_\\.-])[Tt]est.
# It will match things like get_test_file which is not a test.
NOSE_ARGS
=
[
r'--match=(?:^|[\b_\
./-])^[T
t]est'
,
]
\ No newline at end of file
weblate/trans/tests/test_models.py
View file @
951ba07e
...
...
@@ -40,9 +40,9 @@ GIT_URL = 'git://github.com/nijel/weblate-test.git'
class
RepoTestCase
(
TestCase
):
'''
"""
Generic class for tests working with repositories.
'''
"""
def
setUp
(
self
):
if
'test-repos'
in
settings
.
GIT_ROOT
:
test_dir
=
os
.
path
.
join
(
settings
.
GIT_ROOT
,
'test'
)
...
...
@@ -84,9 +84,9 @@ class RepoTestCase(TestCase):
shutil
.
rmtree
(
test_repo_path
)
def
create_project
(
self
):
'''
"""
Creates test project.
'''
"""
return
Project
.
objects
.
create
(
name
=
'Test'
,
slug
=
'test'
,
...
...
@@ -94,9 +94,9 @@ class RepoTestCase(TestCase):
)
def
_create_subproject
(
self
,
file_format
,
mask
,
template
=
''
,
new_base
=
''
):
'''
"""
Creates real test subproject.
'''
"""
project
=
self
.
create_project
()
return
SubProject
.
objects
.
create
(
name
=
'Test'
,
...
...
@@ -113,9 +113,9 @@ class RepoTestCase(TestCase):
)
def
create_subproject
(
self
):
'''
"""
Wrapper method for providing test subproject.
'''
"""
return
self
.
_create_subproject
(
'auto'
,
'po/*.po'
,
...
...
@@ -192,9 +192,9 @@ class RepoTestCase(TestCase):
class
ProjectTest
(
RepoTestCase
):
'''
"""
Project object testing.
'''
"""
def
test_create
(
self
):
project
=
self
.
create_project
()
self
.
assertTrue
(
os
.
path
.
exists
(
project
.
get_path
()))
...
...
@@ -251,9 +251,9 @@ class ProjectTest(RepoTestCase):
)
def
test_acl
(
self
):
'''
"""
Test for ACL handling.
'''
"""
# Create user to verify ACL
user
=
User
.
objects
.
create_user
(
username
=
'testuser'
,
...
...
@@ -282,9 +282,9 @@ class ProjectTest(RepoTestCase):
class
SubProjectTest
(
RepoTestCase
):
'''
"""
SubProject object testing.
'''
"""
def
verify_subproject
(
self
,
project
,
translations
,
lang
,
units
,
unit
=
'Hello, world!
\
n
'
,
fail
=
False
):
# Validation
...
...
@@ -432,9 +432,9 @@ class SubProjectTest(RepoTestCase):
self
.
verify_subproject
(
project
,
3
,
'cs'
,
4
)
def
test_extra_file
(
self
):
'''
"""
Extra commit file validation.
'''
"""
project
=
self
.
create_subproject
()
project
.
full_clean
()
...
...
@@ -452,9 +452,9 @@ class SubProjectTest(RepoTestCase):
)
def
test_check_flags
(
self
):
'''
"""
Check flags validation.
'''
"""
project
=
self
.
create_subproject
()
project
.
full_clean
()
...
...
@@ -580,9 +580,9 @@ class SubProjectTest(RepoTestCase):
class
TranslationTest
(
RepoTestCase
):
'''
"""
Translation testing.
'''
"""
def
test_basic
(
self
):
project
=
self
.
create_subproject
()
translation
=
project
.
translation_set
.
get
(
language_code
=
'cs'
)
...
...
@@ -591,9 +591,9 @@ class TranslationTest(RepoTestCase):
self
.
assertEqual
(
translation
.
fuzzy
,
0
)
def
test_extra_file
(
self
):
'''
"""
Test extra commit file handling.
'''
"""
subproject
=
self
.
create_subproject
()
subproject
.
pre_commit_script
=
get_test_file
(
'../../../../examples/hook-generate-mo'
...
...
@@ -615,9 +615,9 @@ class TranslationTest(RepoTestCase):
)
def
test_validation
(
self
):
'''
"""
Translation validation
'''
"""
project
=
self
.
create_subproject
()
translation
=
project
.
translation_set
.
get
(
language_code
=
'cs'
)
translation
.
full_clean
()
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