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)
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)
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 )
# 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 weblate.trans.tests.test_views import ViewTestCase import weblate.trans.admin_views from django.test import TestCase from django.core.urlresolvers import reverse from django.utils.unittest import SkipTest from weblate.trans.tests.test_util import get_test_file from weblate.trans.util import add_configuration_error import tempfile import shutil import os 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')
# 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/>. # """ File format specific behavior. """ import tempfile from unittest import TestCase from weblate.trans.formats import AutoFormat, PoFormat, AndroidFormat from weblate.trans.tests.test_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" MASK = "po/*.po" EXPECTED_PATH = "/path/po/cs_CZ.po"
# 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 weblate.trans.tests.test_views import ViewTestCase from django.core.urlresolvers import reverse from weblate.trans.tests.test_util import get_test_file TEST_PO = get_test_file('cs.po') TEST_MO = get_test_file('cs.mo') TEST_ANDROID = get_test_file('strings-cs.xml') 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()
# 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 weblate.trans.formats import ( AutoFormat, PoFormat, AndroidFormat, ) from weblate.trans.tests.test_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)
# 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 weblate.trans.formats import ( AutoFormat, PoFormat, AndroidFormat, ) from weblate.trans.tests.test_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)
def test_importdjangousers(self): # First import call_command('importusers', get_test_file('users-django.json')) self.assertEquals(User.objects.count(), 2)
# 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 weblate.trans.tests.test_views import ViewTestCase from weblate.trans.models import Dictionary from django.core.urlresolvers import reverse from weblate.trans.tests.test_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}) def import_file(self, filename, **kwargs): with open(filename) as handle:
# 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 weblate.trans.tests.test_views import ViewTestCase from weblate.trans.models import Dictionary from django.core.urlresolvers import reverse from weblate.trans.tests.test_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, })
# 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 weblate.trans.tests.test_views import ViewTestCase from django.core.urlresolvers import reverse from weblate.trans.tests.test_util import get_test_file TEST_PO = get_test_file('cs.po') TEST_MO = get_test_file('cs.mo') TEST_ANDROID = get_test_file('strings-cs.xml') 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()
# # 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 weblate.trans.tests.test_views import ViewTestCase import weblate.trans.admin_views from django.test import TestCase from django.core.urlresolvers import reverse from django.utils.unittest import SkipTest from weblate.trans.tests.test_util import get_test_file import tempfile import shutil import os 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')
# 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 weblate.trans.tests.test_views import ViewTestCase from django.core.urlresolvers import reverse from weblate.trans.tests.test_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
# 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 weblate.trans.tests.test_views import ViewTestCase from django.core.urlresolvers import reverse from weblate.trans.tests.test_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