예제 #1
0
파일: tests.py 프로젝트: Marlinc/weblate
    def test_importusers(self):
        # First import
        call_command('importusers', get_test_file('users.json'))

        # Test that second import does not change anything
        user = User.objects.get(username='******')
        user.first_name = 'Weblate test user'
        user.save()
        call_command('importusers', get_test_file('users.json'))
        user2 = User.objects.get(username='******')
        self.assertEqual(user.first_name, user2.first_name)
예제 #2
0
파일: models.py 프로젝트: spc-12/weblate
 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'
     )
     appsettings.SCRIPT_CHOICES.append(
         (subproject.pre_commit_script, 'hook-generate-mo')
     )
     subproject.extra_commit_file = 'po/%(language)s.mo'
     subproject.save()
     subproject.full_clean()
     translation = subproject.translation_set.get(language_code='cs')
     # change backend file
     with open(translation.get_filename(), 'a') as handle:
         handle.write(' ')
     # Test committing
     translation.git_commit(
         None, 'TEST <*****@*****.**>', timezone.now(),
         force_commit=True
     )
예제 #3
0
# 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 dictionary manipulations.
"""

from trans.tests.views import ViewTestCase
from trans.models import Dictionary
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_TBX = get_test_file('terms.tbx')
TEST_CSV = get_test_file('terms.csv')
TEST_CSV_HEADER = get_test_file('terms-header.csv')
TEST_PO = get_test_file('terms.po')


class DictionaryTest(ViewTestCase):
    '''
    Testing of dictionary manipulations.
    '''

    def get_url(self, url):
        return reverse(url, kwargs={
            'lang': 'cs',
            'project': self.subproject.project.slug,
        })
예제 #4
0
파일: files.py 프로젝트: camilonova/weblate
# 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 import and export.
"""

from trans.tests.views import ViewTestCase
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_PO = get_test_file('cs.po')

TRANSLATION_OURS = u'Nazdar světe!\n'
TRANSLATION_PO = u'Ahoj světe!\n'


class ImportTest(ViewTestCase):
    '''
    Testing of file imports.
    '''

    def setUp(self):
        super(ImportTest, self).setUp()
        # We need extra privileges for overwriting
        self.user.is_superuser = True
        self.user.save()
예제 #5
0
파일: files.py 프로젝트: Marlinc/weblate
# 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 import and export.
"""

from trans.tests.views import ViewTestCase
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_PO = get_test_file('cs.po')
TEST_MO = get_test_file('cs.mo')

TRANSLATION_OURS = u'Nazdar světe!\n'
TRANSLATION_PO = u'Ahoj světe!\n'


class ImportTest(ViewTestCase):
    '''
    Testing of file imports.
    '''
    test_file = TEST_PO

    def setUp(self):
        super(ImportTest, self).setUp()
        # We need extra privileges for overwriting
예제 #6
0
# 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 dictionary manipulations.
"""

from trans.tests.views import ViewTestCase
from trans.models import Dictionary
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_TBX = get_test_file('terms.tbx')


class DictionaryTest(ViewTestCase):
    '''
    Testing of dictionary manipulations.
    '''

    def get_kwargs(self):
        return {
            'lang': 'cs',
            'project': self.subproject.project.slug,
        }

    def get_url(self, url):
        return reverse(url, kwargs=self.get_kwargs())
예제 #7
0
# 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 import and export.
"""

from trans.tests.views import ViewTestCase
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_PO = get_test_file('cs.po')

TRANSLATION_OURS = u'Nazdar světe!\n'
TRANSLATION_PO = u'Ahoj světe!\n'


class ImportTest(ViewTestCase):
    '''
    Testing of file imports.
    '''
    def setUp(self):
        super(ImportTest, self).setUp()
        # We need extra privileges for overwriting
        self.user.is_superuser = True
        self.user.save()
예제 #8
0
# 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 dictionary manipulations.
"""

from trans.tests.views import ViewTestCase
from trans.models import Dictionary
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_TBX = get_test_file('terms.tbx')


class DictionaryTest(ViewTestCase):
    '''
    Testing of dictionary manipulations.
    '''
    def get_kwargs(self):
        return {
            'lang': 'cs',
            'project': self.subproject.project.slug,
        }

    def get_url(self, url):
        return reverse(url, kwargs=self.get_kwargs())
예제 #9
0
파일: admin.py 프로젝트: Marlinc/weblate
# 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/>.
#

from trans.tests.views import ViewTestCase
import trans.admin_views
from django.test import TestCase
from django.core.urlresolvers import reverse
from trans.tests.util import get_test_file

TEST_HOSTS = get_test_file('known_hosts')


class AdminTest(ViewTestCase):
    '''
    Tests for customized admin interface.
    '''
    def setUp(self):
        super(AdminTest, self).setUp()
        self.user.is_staff = True
        self.user.is_superuser = True
        self.user.save()

    def test_index(self):
        response = self.client.get(reverse('admin:index'))
        self.assertContains(response, 'SSH')
예제 #10
0
파일: formats.py 프로젝트: spc-12/weblate
# 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/>.
#
'''
File format specific behavior.
'''
import tempfile
from unittest import TestCase
from trans.formats import (
    AutoFormat, PoFormat, AndroidFormat,
)
from trans.tests.util import get_test_file

TEST_PO = get_test_file('cs.po')
TEST_ANDROID = get_test_file('strings.xml')
TEST_POT = get_test_file('hello.pot')


class AutoFormatTest(TestCase):
    FORMAT = AutoFormat
    FILE = TEST_PO
    BASE = TEST_POT
    MIME = 'text/x-gettext-catalog'
    EXT = 'po'
    COUNT = 5
    MATCH = 'msgid_plural'

    def test_parse(self):
        storage = self.FORMAT(self.FILE)