Commit 0eaf64d6 authored by Michal Čihař's avatar Michal Čihař

Factor out message editing

parent 46f33003
......@@ -143,24 +143,30 @@ class EditTest(ViewTestCase):
'''
Tests for manipulating translation.
'''
def test_edit(self):
def edit_unit(self, source, target):
translation = self.subproject.translation_set.get(language_code='cs')
unit = translation.unit_set.get(source='Hello, world!\n')
unit = translation.unit_set.get(source=source)
translate_url = reverse('translate', kwargs={
'project': self.subproject.project.slug,
'subproject': self.subproject.slug,
'lang': 'cs',
})
response = self.client.post(
return self.client.post(
translate_url,
{
'checksum': unit.checksum,
'target': 'Nazdar svete!\n',
'target': target,
'type': 'all',
'dir': 'forward',
'pos': '1',
}
)
def test_edit(self):
response = self.edit_unit(
'Hello, world!\n',
'Nazdar svete!\n'
)
# We should get to second message
self.assertRedirects(response, translate_url + '?type=all&pos=1')
unit = translation.unit_set.get(source='Hello, world!\n')
......@@ -168,22 +174,9 @@ class EditTest(ViewTestCase):
self.assertEqual(len(unit.checks()), 0)
def test_edit_check(self):
translation = self.subproject.translation_set.get(language_code='cs')
unit = translation.unit_set.get(source='Hello, world!\n')
translate_url = reverse('translate', kwargs={
'project': self.subproject.project.slug,
'subproject': self.subproject.slug,
'lang': 'cs',
})
response = self.client.post(
translate_url,
{
'checksum': unit.checksum,
'target': 'Nazdar svete!',
'type': 'all',
'dir': 'forward',
'pos': '1',
}
response = self.edit_unit(
'Hello, world!\n',
'Nazdar svete!'
)
# We should stay on current message
self.assertRedirects(response, translate_url + '?type=all&pos=1&dir=stay')
......
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