Commit 38236399 authored by Claude Paroz's avatar Claude Paroz

Add more test coverage for checkout process and fix discovered errors

Fixes #108.
parent ea5ef374
......@@ -49,9 +49,9 @@ class GitRepo(RepoBase):
def init_checkout(self):
# We are assuming here that master is the first branch created
if self.name == "master":
if self.branch.name == "master":
commands = [
['git', 'clone', self.branch.module.vcs_root, self.branch.co_path.parent],
['git', 'clone', self.branch.module.vcs_root, str(self.branch.co_path.parent)],
['git', 'remote', 'update'],
['git', 'checkout', self.branch.name],
]
......@@ -64,7 +64,7 @@ class GitRepo(RepoBase):
commands.append("if [ -e .gitmodules ]; then git submodule update --init; fi")
for cmd in commands:
working_dir = self.branch.co_path.parent if 'clone' in cmd else self.branch.co_path
run_shell_command(command, raise_on_error=True, cwd=working_dir)
run_shell_command(cmd, raise_on_error=True, cwd=working_dir)
def update(self):
# test "git checkout %(branch)s && git clean -dfq && git pull origin/%(branch)s"?
......
......@@ -55,7 +55,6 @@ class ModuleTestCase(TestCase):
def setUp(self):
Branch.checkout_on_creation = False
Branch.checkout = mocked_checkout
self.mod = Module.objects.get(name="gnome-hello")
self.branch = self.mod.branch_set.get(name="master")
......@@ -131,7 +130,8 @@ class ModuleTestCase(TestCase):
lang = Language.objects.create(name='xxx', locale='xxx')
ghost_stat = Statistics.objects.create(branch=self.branch, domain=self.mod.domain_set.get(name='po'), language=lang)
# Check stats
self.branch.update_stats(force=True)
with patch_shell_command(only=['git ']):
self.branch.update_stats(force=True)
fr_po_stat = Statistics.objects.get(branch=self.branch, domain__name='po', language__locale='fr')
self.assertEqual(fr_po_stat.translated(), 44)
self.assertEqual(fr_po_stat.translated(scope='part'), 44)
......@@ -191,7 +191,8 @@ class ModuleTestCase(TestCase):
def test_create_unexisting_branch(self):
""" Try to create a non-existing branch """
Branch.checkout_on_creation = True
branch = Branch(name="trunk2", module = self.mod)
Branch.checkout = mocked_checkout
branch = Branch(name="trunk2", module=self.mod)
self.assertRaises(ValidationError, branch.clean)
def test_edit_branches_form(self):
......@@ -248,7 +249,8 @@ class ModuleTestCase(TestCase):
def test_string_frozen_mail(self):
""" String change for a module of a string_frozen release should generate a message """
mail.outbox = []
self.branch.update_stats(force=False)
with patch_shell_command(only=['git ']):
self.branch.update_stats(force=False)
# Create a new file with translation
new_file_path = self.branch.co_path / "dummy_file.py"
......@@ -270,7 +272,8 @@ class ModuleTestCase(TestCase):
def test_dynamic_po(self):
""" Test the creation of a blank po file for a new language """
tamil = Language.objects.create(name="Tamil", locale="ta")
self.branch.update_stats(force=False) # At least POT stats needed
with patch_shell_command(only=['git ']):
self.branch.update_stats(force=False) # At least POT stats needed
pot_stats = Statistics.objects.get(
branch=self.branch, domain__name='po', language__isnull=True
)
......
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