Commit b1985b2a authored by Michal Čihař's avatar Michal Čihař

Test error paths in parsing storages

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 9a087355
...@@ -27,6 +27,7 @@ import shutil ...@@ -27,6 +27,7 @@ import shutil
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from weblate.trans.formats import ParseError
from weblate.trans.models import ( from weblate.trans.models import (
Project, SubProject, Unit, Suggestion, IndexUpdate, Project, SubProject, Unit, Suggestion, IndexUpdate,
) )
...@@ -543,7 +544,7 @@ class SubProjectErrorTest(RepoTestCase): ...@@ -543,7 +544,7 @@ class SubProjectErrorTest(RepoTestCase):
def setUp(self): def setUp(self):
super(SubProjectErrorTest, self).setUp() super(SubProjectErrorTest, self).setUp()
self.component = self.create_subproject() self.component = self.create_ts_mono()
# Change to invalid pull/push URL # Change to invalid pull/push URL
self.component.repository.configure_remote( self.component.repository.configure_remote(
'file:/dev/null', 'file:/dev/null',
...@@ -578,3 +579,26 @@ class SubProjectErrorTest(RepoTestCase): ...@@ -578,3 +579,26 @@ class SubProjectErrorTest(RepoTestCase):
self.assertFalse( self.assertFalse(
self.component.do_reset(None) self.component.do_reset(None)
) )
def test_invalid_storage(self):
testfile = os.path.join(self.component.get_path(), 'ts-mono', 'cs.ts')
with open(testfile, 'a') as handle:
handle.write('CHANGE')
translation = self.component.translation_set.get(language_code='cs')
self.assertRaises(
ParseError,
lambda: translation.store
)
def test_invalid_template_storage(self):
testfile = os.path.join(self.component.get_path(), 'ts-mono', 'en.ts')
with open(testfile, 'a') as handle:
handle.write('CHANGE')
# Clean class cache, pylint: disable=W0212
self.component._template_store = None
self.assertRaises(
ParseError,
lambda: self.component.template_store
)
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