adds a test for Issue #135 and PR # 136

This commit is contained in:
Marco Bonetti 2015-08-04 16:12:00 +02:00
parent d23dd8859d
commit 85c2eca379
2 changed files with 25 additions and 2 deletions

View file

@ -8,6 +8,7 @@ Version 0.7.7 (unreleased)
* Fixes the Fuzzy toggle link by adding an actual toggle checkbox (Issue #132, thanks @EmilStenstrom)
* Better handling of Custom User Models while checking wether the current User is authorized to translate (Issue #131, thanks @EmilStenstrom)
* Include the testproject in the sdist tarball to allow Debian to run tests during installation (Issue #137, thanks @fladi)
* Display an explicit error message to the enduser when saving the POfile fails for some reason (Issue #135, thanks @pgcd)
Version 0.7.6
-------------

View file

@ -117,7 +117,7 @@ class RosettaTestCase(TestCase):
r = self.client.get(reverse('rosetta-home'))
# the translated string no longer is up for translation
self.assertTrue('String 1' in str(r.content))
self.assertTrue('String 1' in str(r.content))
self.assertTrue('String 2' not in str(r.content))
# display only translated strings
@ -125,7 +125,7 @@ class RosettaTestCase(TestCase):
r = self.client.get(reverse('rosetta-home'))
# The tranlsation was persisted
self.assertTrue('String 1' not in str(r.content))
self.assertTrue('String 1' not in str(r.content))
self.assertTrue('String 2' in str(r.content))
self.assertTrue('Hello, world' in str(r.content))
@ -687,6 +687,28 @@ class RosettaTestCase(TestCase):
r = self.client.get(reverse('rosetta-pick-file'))
self.assertTrue('rosetta/select/xx/1/">Test_App' in str(r.content))
def test_35_issue_135_display_exception_messages(self):
shutil.copy(os.path.normpath(os.path.join(self.curdir, './django.po.template')), self.dest_file)
# Load the template file
r = self.client.get(reverse('rosetta-pick-file') + '?filter=third-party')
r = self.client.get(reverse('rosetta-language-selection', args=('xx', 0), kwargs=dict()))
r = self.client.get(reverse('rosetta-home') + '?filter=untranslated')
r = self.client.get(reverse('rosetta-home'))
# make sure both strings are untranslated
self.assertTrue('m_e48f149a8b2e8baa81b816c0edf93890' in str(r.content))
# make the pofile read-only
os.chmod(self.dest_file, 292) # 0400
# post a translation
r = self.client.post(reverse('rosetta-home'), dict(m_e48f149a8b2e8baa81b816c0edf93890='Hello, world', _next='_next'))
r = self.client.get(reverse('rosetta-home'))
self.assertTrue(six.text_type('Permission denied') in six.text_type(r.content))
# cleanup
os.chmod(self.dest_file, 420) # 0644
# Stubbed access control function
def no_access(user):