예제 #1
0
    def test_update_buildout(self):
        """Check that repository is updated with commit message"""
        path = self.user_buildout_repo.working_tree_dir

        message = 'New versions: 345'

        with wrap_folder(path):
            with open('versions.cfg', 'w') as versions:
                versions.write('[versions]')

            full_release = FullRelease()
            full_release.commit_message = message
            full_release.update_buildout()

        commit = self.user_buildout_repo.commit()
        self.assertEqual(
            commit.message.strip(),
            message
        )
        self.assertTrue(is_branch_synced(self.user_buildout_repo))
예제 #2
0
    def test_update_batou(self):
        """Check that batou repository is updated with new version pins"""
        buildout_path = self.user_buildout_repo.working_tree_dir

        # create the fake batou repository
        remote_batou = Repo.init(mkdtemp(), bare=True)

        # clone the fake batou repository and add the versions.cfg
        tmp_batou_repo = remote_batou.clone(mkdtemp())
        folder_path = '{0}/components/plone/versions'
        folder_path = folder_path.format(tmp_batou_repo.working_tree_dir)
        os.makedirs(folder_path)
        file_path = '{0}/versions.cfg'.format(folder_path)
        with open(file_path, 'w') as versions:
            versions.write('[versions]')
        tmp_batou_repo.index.add([file_path, ])
        tmp_batou_repo.index.commit('lalala')
        tmp_batou_repo.remote().push('master:refs/heads/master')

        shutil.rmtree(tmp_batou_repo.working_dir)

        with wrap_folder(buildout_path):
            with open('sources.cfg', 'w') as versions:
                versions.write('[sources]\n')
                versions.write(
                    'deployment = git file://{0}'.format(
                        remote_batou.working_dir
                    )
                )

            full_release = FullRelease()
            full_release.commit_message = 'lalala'
            full_release.versions = {
                'der.freitag': '4.3',
                'freitag.article': '2.7',
            }
            full_release.update_batou()

        tmp_batou_repo = remote_batou.clone(mkdtemp())
        branch = tmp_batou_repo.branches['master']

        self.assertEqual(
            branch.commit.message,
            'lalala'
        )
        self.assertEqual(
            len(branch.commit.stats.files.keys()),
            1
        )
        self.assertEqual(
            branch.commit.stats.files.keys()[0],
            'components/plone/versions/versions.cfg'
        )

        with wrap_folder(tmp_batou_repo.working_tree_dir):
            with open('components/plone/versions/versions.cfg') as afile:
                data = afile.read()

        self.assertIn(
            'der.freitag = 4.3',
            data
        )
        self.assertIn(
            'freitag.article = 2.7',
            data
        )

        shutil.rmtree(remote_batou.working_dir)
        shutil.rmtree(tmp_batou_repo.working_tree_dir)