コード例 #1
0
 def test_extra_file(self):
     """Test extra commit file handling."""
     subproject = self.create_subproject()
     subproject.pre_commit_script = get_test_file('hook-generate-mo')
     weblate.trans.models.subproject.PRE_COMMIT_SCRIPT_CHOICES.append(
         (subproject.pre_commit_script, 'hook-generate-mo'))
     subproject.pre_commit_script = get_test_file('hook-update-linguas')
     weblate.trans.models.subproject.PRE_COMMIT_SCRIPT_CHOICES.append(
         (subproject.pre_commit_script, 'hook-update-linguas'))
     subproject.extra_commit_file = 'po/%(language)s.mo\npo/LINGUAS'
     subproject.save()
     subproject.full_clean()
     translation = subproject.translation_set.get(language_code='cs')
     # change backend file
     with open(translation.get_filename(), 'a') as handle:
         handle.write(' ')
     # Test committing
     translation.git_commit(
         None,
         'TEST <*****@*****.**>',
         timezone.now(),
     )
     self.assertFalse(translation.repo_needs_commit())
     linguas = os.path.join(subproject.full_path, 'po', 'LINGUAS')
     with open(linguas, 'r') as handle:
         data = handle.read()
         self.assertIn('\ncs\n', data)
     self.assertFalse(translation.repo_needs_commit())
コード例 #2
0
ファイル: test_models.py プロジェクト: saily/weblate
 def test_extra_file(self):
     """Test extra commit file handling."""
     subproject = self.create_subproject()
     subproject.pre_commit_script = get_test_file('hook-generate-mo')
     weblate.trans.models.subproject.PRE_COMMIT_SCRIPT_CHOICES.append(
         (subproject.pre_commit_script, 'hook-generate-mo')
     )
     subproject.pre_commit_script = get_test_file('hook-update-linguas')
     weblate.trans.models.subproject.PRE_COMMIT_SCRIPT_CHOICES.append(
         (subproject.pre_commit_script, 'hook-update-linguas')
     )
     subproject.extra_commit_file = 'po/%(language)s.mo\npo/LINGUAS'
     subproject.save()
     subproject.full_clean()
     translation = subproject.translation_set.get(language_code='cs')
     # change backend file
     with open(translation.get_filename(), 'a') as handle:
         handle.write(' ')
     # Test committing
     translation.git_commit(
         None, 'TEST <*****@*****.**>', timezone.now(),
         force_commit=True
     )
     linguas = os.path.join(subproject.get_path(), 'po', 'LINGUAS')
     with open(linguas, 'r') as handle:
         data = handle.read()
         self.assertIn('\ncs\n', data)
     self.assertFalse(translation.repo_needs_commit())