def test_bad_pattern(self): with patch( '%s.subprocess.check_output' % pbm, autospec=True ) as mock_co: with pytest.raises(RuntimeError): mock_co.return_value = 'foobar' git_html_url()
def _policy_rst(self, region_policies): """ Build the policies rST source for the documentation. :param region_policies: dict of region names to per-region dict of policy name to policy content, for that region. :type region_policies: dict :return: built rST markup for policies docs :rtype: str """ buildinfo = 'by `%s %s <%s>`_' % (os.environ.get( 'JOB_NAME', ''), os.environ.get( 'BUILD_NUMBER', ''), os.environ.get('BUILD_URL', '')) commit = os.environ.get('GIT_COMMIT', 'unknown') gitlink = '%scommit/%s' % (git_html_url(), commit) if buildinfo == 'by ` <>`_': buildinfo = 'locally' s = "this page built %s from `%s <%s>`_ at %s\n\n" % ( buildinfo, commit, gitlink, timestr()) s += tabulate(sorted(self._policy_rst_data(region_policies)), headers=[ 'Policy Name', 'Account(s) / Region(s)', 'Description/Comment' ], tablefmt='grid') return s
def test_github_git(self): with patch('%s.subprocess.check_output' % pbm, autospec=True) as mock_co: mock_co.return_value = '[email protected]:Foo/bar.git' res = git_html_url() assert res == 'https://github.com/Foo/bar/' assert mock_co.mock_calls == [ call(['git', 'config', 'remote.origin.url'], text=True) ]