Commit 641ac27d authored by Michal Čihař's avatar Michal Čihař

Test for disappeared message

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 6a8ab796
......@@ -532,9 +532,7 @@ class FileFormat(object):
if ttkit_unit is None:
ttkit_unit = template_ttkit_unit
if template_ttkit_unit is None:
raise Exception(
'Could not find template unit for new unit!'
)
return (None, False)
add = True
else:
add = False
......
......@@ -33,6 +33,7 @@ from weblate.trans.models import (
)
from weblate.trans.tests import OverrideSettings
from weblate.trans.tests.test_models import RepoTestCase
from weblate.trans.tests.test_views import ViewTestCase
class SubProjectTest(RepoTestCase):
......@@ -602,3 +603,53 @@ class SubProjectErrorTest(RepoTestCase):
ParseError,
lambda: self.component.template_store
)
class SubProjectEditTest(ViewTestCase):
"""Tests for error handling"""
def remove_units(self, store):
if store is not None:
store.units = []
store.save()
def test_unit_disappear(self):
translation = self.subproject.translation_set.get(language_code='cs')
self.remove_units(self.subproject.template_store)
self.remove_units(translation.store.store)
# Clean class cache, pylint: disable=W0212
self.subproject._template_store = None
translation._store = None
unit = translation.unit_set.all()[0]
request = self.get_request('/')
self.assertFalse(
unit.translate(request, ['Empty'], False)
)
class SubProjectEditMonoTest(SubProjectEditTest):
"""Tests for error handling"""
def create_subproject(self):
return self.create_ts_mono()
def remove_units(self, store):
store.parse(store.XMLskeleton.replace("\n", "").encode('utf-8'))
store.save()
def test_unit_add(self):
translation = self.subproject.translation_set.get(language_code='cs')
self.remove_units(translation.store.store)
# Clean class cache, pylint: disable=W0212
translation._store = None
unit = translation.unit_set.all()[0]
request = self.get_request('/')
self.assertTrue(
unit.translate(request, ['Empty'], False)
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment