def test_getBranch_dir(self):
        # If passed a branch directory, the template generation script
        # works directly in that directory.
        branch_dir = '/home/me/branch'

        generator = GenerateTranslationTemplates(
            branch_dir, self.result_name, self.makeTemporaryDirectory(),
            log_file=StringIO())
        generator._checkout = FakeMethod()
        generator._getBranch()

        self.assertEqual(0, generator._checkout.call_count)
        self.assertEqual(branch_dir, generator.branch_dir)
    def test_getBranch_url(self):
        # If passed a branch URL, the template generation script will
        # check out that branch into a directory called "source-tree."
        branch_url = 'lp://~my/translation/branch'

        generator = GenerateTranslationTemplates(
            branch_url, self.result_name, self.makeTemporaryDirectory(),
            log_file=StringIO())
        generator._checkout = FakeMethod()
        generator._getBranch()

        self.assertEqual(1, generator._checkout.call_count)
        self.assertTrue(generator.branch_dir.endswith('source-tree'))
    def test_getBranch_bzr(self):
        # _getBranch can retrieve branch contents from a branch URL.
        self.useBzrBranches(direct_database=True)
        marker_text = "Ceci n'est pas cet branch."
        branch = self._createBranch({'marker.txt': marker_text})

        generator = GenerateTranslationTemplates(
            branch.getInternalBzrUrl(), self.result_name,
            self.makeTemporaryDirectory(), log_file=StringIO())
        generator.branch_dir = self.makeTemporaryDirectory()
        generator._getBranch()

        marker_file = file(os.path.join(generator.branch_dir, 'marker.txt'))
        self.assertEqual(marker_text, marker_file.read())
Example #4
0
    def test_getBranch_dir(self):
        # If passed a branch directory, the template generation script
        # works directly in that directory.
        branch_dir = '/home/me/branch'

        generator = GenerateTranslationTemplates(branch_dir,
                                                 self.result_name,
                                                 self.makeTemporaryDirectory(),
                                                 log_file=StringIO())
        generator._checkout = FakeMethod()
        generator._getBranch()

        self.assertEqual(0, generator._checkout.call_count)
        self.assertEqual(branch_dir, generator.branch_dir)
Example #5
0
    def test_getBranch_url(self):
        # If passed a branch URL, the template generation script will
        # check out that branch into a directory called "source-tree."
        branch_url = 'lp://~my/translation/branch'

        generator = GenerateTranslationTemplates(branch_url,
                                                 self.result_name,
                                                 self.makeTemporaryDirectory(),
                                                 log_file=StringIO())
        generator._checkout = FakeMethod()
        generator._getBranch()

        self.assertEqual(1, generator._checkout.call_count)
        self.assertTrue(generator.branch_dir.endswith('source-tree'))
Example #6
0
    def test_getBranch_bzr(self):
        # _getBranch can retrieve branch contents from a branch URL.
        self.useBzrBranches(direct_database=True)
        marker_text = "Ceci n'est pas cet branch."
        branch = self._createBranch({'marker.txt': marker_text})

        generator = GenerateTranslationTemplates(branch.getInternalBzrUrl(),
                                                 self.result_name,
                                                 self.makeTemporaryDirectory(),
                                                 log_file=StringIO())
        generator.branch_dir = self.makeTemporaryDirectory()
        generator._getBranch()

        marker_file = file(os.path.join(generator.branch_dir, 'marker.txt'))
        self.assertEqual(marker_text, marker_file.read())
    def test_templates_tarball(self):
        # Create a tarball from pot files.
        workdir = self.makeTemporaryDirectory()
        branchdir = os.path.join(workdir, 'branchdir')
        dummy_tar = os.path.join(
            os.path.dirname(__file__),'dummy_templates.tar.gz')
        tar = tarfile.open(dummy_tar, 'r|*')
        tar.extractall(branchdir)
        potnames = [member.name for member in tar.getmembers() if not member.isdir()]
        tar.close()

        generator = GenerateTranslationTemplates(
            branchdir, self.result_name, workdir, log_file=StringIO())
        generator._getBranch()
        generator._makeTarball(potnames)
        tar = tarfile.open(os.path.join(workdir, self.result_name), 'r|*')
        tarnames = tar.getnames()
        tar.close()
        self.assertContentEqual(potnames, tarnames)
Example #8
0
    def test_templates_tarball(self):
        # Create a tarball from pot files.
        workdir = self.makeTemporaryDirectory()
        branchdir = os.path.join(workdir, 'branchdir')
        dummy_tar = os.path.join(os.path.dirname(__file__),
                                 'dummy_templates.tar.gz')
        tar = tarfile.open(dummy_tar, 'r|*')
        tar.extractall(branchdir)
        potnames = [
            member.name for member in tar.getmembers() if not member.isdir()
        ]
        tar.close()

        generator = GenerateTranslationTemplates(branchdir,
                                                 self.result_name,
                                                 workdir,
                                                 log_file=StringIO())
        generator._getBranch()
        generator._makeTarball(potnames)
        tar = tarfile.open(os.path.join(workdir, self.result_name), 'r|*')
        tarnames = tar.getnames()
        tar.close()
        self.assertContentEqual(potnames, tarnames)