def test_ask_what_to_release_test(self): """Check that in test mode no distributions are filtered""" repo = self.user_buildout_repo # add source, CHANGES.rst, commits and push the repo self._add_source(repo) self._add_changes(repo) first_commit_sha = self._commit(repo, msg='Random commit 1') self.user_buildout_repo.remote().push() # clone the repo path = '{0}/src'.format(self.user_buildout_repo.working_tree_dir) os.makedirs(path) repo_folder = '{0}/my.distribution'.format(path) self.buildout_repo.clone(repo_folder) # full release full_release = FullRelease(path=path, test=True) full_release.distributions = [repo_folder, ] full_release.last_tags['my.distribution'] = first_commit_sha utils.test_answer_book.set_answers(['n', ]) with wrap_folder(self.user_buildout_repo.working_tree_dir): with OutputCapture(): full_release.ask_what_to_release() self.assertEqual( full_release.distributions, [repo_folder, ] )
def test_ask_what_to_release_changes_rst_is_shown(self): """Check that the CHANGES.rst are shown to the user""" repo = self.user_buildout_repo # add source, CHANGES.rst, commits and push the repo self._add_source(repo) self._add_changes(repo) first_commit_sha = self._commit(repo, msg='Random commit 1') self.user_buildout_repo.remote().push() # clone the repo path = '{0}/src'.format(self.user_buildout_repo.working_tree_dir) os.makedirs(path) repo_folder = '{0}/my.distribution'.format(path) self.buildout_repo.clone(repo_folder) # full release full_release = FullRelease(path=path) full_release.distributions = [repo_folder, ] full_release.last_tags['my.distribution'] = first_commit_sha utils.test_answer_book.set_answers(['Y', ]) with wrap_folder(self.user_buildout_repo.working_tree_dir): with OutputCapture(): with LogCapture() as output: full_release.ask_what_to_release() self.assertIn( 'change log entry 1', self._get_logging_as_string(output) ) self.assertIn( 'change log entry 2', self._get_logging_as_string(output) )
def test_ask_what_to_release_clean_all_lines_of_git_history(self): """Check that if the commits on the distribution are only administrative ones, the distribution is discarded """ repo = self.user_buildout_repo # add source, CHANGES.rst, commits and push the repo self._add_source(repo) self._add_changes(repo) first_commit_sha = self._commit(repo, msg='Back to development') self._commit(repo, msg='New version:') self._commit(repo, msg='Preparing release la la') self.user_buildout_repo.remote().push() # clone the repo path = '{0}/src'.format(self.user_buildout_repo.working_tree_dir) os.makedirs(path) repo_folder = '{0}/my.distribution'.format(path) self.buildout_repo.clone(repo_folder) # full release full_release = FullRelease(path=path) full_release.distributions = [repo_folder, ] full_release.last_tags['my.distribution'] = first_commit_sha with wrap_folder(self.user_buildout_repo.working_tree_dir): with OutputCapture(): full_release.ask_what_to_release() # check that the distribution is not going to be released self.assertEqual( full_release.distributions, [] )
def test_ask_what_to_release_clean_some_lines_of_git_history(self): """Check that if the some commits are administrative they are not shown to the user, the other non-administrative are shown """ repo = self.user_buildout_repo # add some commits # save the sha to make the git history go as back as to this commit first_commit_sha = self._commit(repo, msg='Random commit 1') self._commit(repo, msg='Random commit 2') self._commit(repo, msg='Random commit 3') # this one will be filtered self._commit(repo, msg='Bump version this is not kept') # add source, CHANGES.rst and push the repo self._add_source(repo) self._add_changes(repo) self.user_buildout_repo.remote().push() # clone the repo path = '{0}/src'.format(self.user_buildout_repo.working_tree_dir) os.makedirs(path) repo_folder = '{0}/my.distribution'.format(path) self.buildout_repo.clone(repo_folder) # full release full_release = FullRelease(path=path) full_release.distributions = [repo_folder, ] full_release.last_tags['my.distribution'] = first_commit_sha utils.test_answer_book.set_answers(['Y', ]) with wrap_folder(self.user_buildout_repo.working_tree_dir): with OutputCapture(): with LogCapture() as output: full_release.ask_what_to_release() self.assertIn( 'Random commit 2', self._get_logging_as_string(output) ) self.assertNotIn( 'Bump version', self._get_logging_as_string(output) ) self.assertIn( 'Add source', self._get_logging_as_string(output) )
def test_ask_what_to_release_user_can_not_release_a_distribution(self): """Check that even if the distribution meets all the criteria, the user can still decide not to release it """ repo = self.user_buildout_repo # add source, CHANGES.rst, commits and push the repo self._add_source(repo) self._add_changes(repo) first_commit_sha = self._commit(repo, msg='Random commit 1') self.user_buildout_repo.remote().push() # clone the repo path = '{0}/src'.format(self.user_buildout_repo.working_tree_dir) os.makedirs(path) repo_folder = '{0}/my.distribution'.format(path) self.buildout_repo.clone(repo_folder) # full release full_release = FullRelease(path=path) full_release.distributions = [repo_folder, ] full_release.last_tags['my.distribution'] = first_commit_sha utils.test_answer_book.set_answers(['n', ]) with wrap_folder(self.user_buildout_repo.working_tree_dir): with OutputCapture() as output: full_release.ask_what_to_release() self.assertEqual( full_release.distributions, [] ) self.assertIn( 'Is the change log ready for release?', output.captured )
def test_ask_what_to_release_test_write_changes(self): """Check that in test mode you can write the git history on CHANGES """ repo = self.user_buildout_repo # add source, CHANGES.rst, commits and push the repo self._add_source(repo) self._add_changes(repo) first_commit_sha = self._commit(repo, msg='Random commit 1') self.user_buildout_repo.remote().push() # clone the repo path = '{0}/src'.format(self.user_buildout_repo.working_tree_dir) os.makedirs(path) repo_folder = '{0}/my.distribution'.format(path) self.buildout_repo.clone(repo_folder) # full release full_release = FullRelease(path=path, test=True) full_release.distributions = [repo_folder, ] full_release.last_tags['my.distribution'] = first_commit_sha utils.test_answer_book.set_answers(['y', ]) with wrap_folder(self.user_buildout_repo.working_tree_dir): with OutputCapture() as output: full_release.ask_what_to_release() self.assertIn( 'write the above git history on CHANGES.rst', output.captured ) self.assertIn( 'Random commit 1', open('{0}/CHANGES.rst'.format(repo_folder)).read() )