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

Test hook execution backend

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 92e7fed6
...@@ -1464,12 +1464,14 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -1464,12 +1464,14 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
command, command,
env=get_clean_env(), env=get_clean_env(),
) )
return True
except (OSError, subprocess.CalledProcessError) as err: except (OSError, subprocess.CalledProcessError) as err:
self.log_error( self.log_error(
'failed to run hook script %s: %s', 'failed to run hook script %s: %s',
script, script,
err err
) )
return False
def get_editable_template(self): def get_editable_template(self):
if not self.edit_template or not self.has_template(): if not self.edit_template or not self.has_template():
......
...@@ -679,6 +679,15 @@ class SubProjectTest(RepoTestCase): ...@@ -679,6 +679,15 @@ class SubProjectTest(RepoTestCase):
component.save() component.save()
self.assertEqual(component.translation_set.count(), 4) self.assertEqual(component.translation_set.count(), 4)
def test_run_hook(self):
subproject = self.create_subproject()
self.assertFalse(
subproject.run_hook('false')
)
self.assertTrue(
subproject.run_hook('true')
)
class TranslationTest(RepoTestCase): class TranslationTest(RepoTestCase):
""" """
......
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