def _deploy(self, branch='gh-pages', prefix=''): with commands.deploy(self.cfg, '1.0', aliases=['stable'], branch=branch, prefix=prefix): pass with commands.deploy(self.cfg, '2.0', branch=branch, prefix=prefix): pass
def test_overwrite_version(self): with git_utils.Commit('gh-pages', 'add versions.json') as commit: commit.add_file( git_utils.FileInfo( 'versions.json', '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]', )) commit.add_file(git_utils.FileInfo('1.0/old-file.txt', '')) commit.add_file(git_utils.FileInfo('latest/old-file.txt', '')) commands.deploy(self.stage, '1.0', '1.0.1', ['greatest']) check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', '1.0.1', ['latest', 'greatest']) ])
def test_overwrite_alias(self): with git_utils.Commit('gh-pages', 'add versions.json') as commit: commit.add_file( git_utils.FileInfo( 'versions.json', '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]', )) commit.add_file(git_utils.FileInfo('1.0/file.txt', '')) commit.add_file(git_utils.FileInfo('latest/file.txt', '')) with self.assertRaises(ValueError): commands.deploy(self.stage, '2.0', '2.0.0', ['latest']) check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy('add versions.json', [versions.VersionInfo('1.0', '1.0', ['latest'])])
def test_update_aliases(self): with git_utils.Commit('gh-pages', 'add versions.json') as commit: commit.add_file( git_utils.FileInfo( 'versions.json', '[{"version": "1.0", "title": "1.0", "aliases": ["latest"]}]', )) commit.add_file(git_utils.FileInfo('1.0/file.txt', '')) commit.add_file(git_utils.FileInfo('latest/file.txt', '')) commands.deploy(self.stage, '2.0', '2.0.0', ['latest'], True) check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy('.*', [ versions.VersionInfo('2.0', '2.0.0', ['latest']), versions.VersionInfo('1.0', '1.0', []), ])
def test_overwrite_include_same_alias(self): self._mock_commit() with commands.deploy(self.cfg, '1.0', '1.0.1', ['latest', 'greatest']): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', '1.0.1', ['latest', 'greatest']) ])
def test_overwrite_alias_error(self): self._mock_commit() with self.assertRaises(ValueError): with commands.deploy(self.cfg, '2.0', '2.0.0', ['latest']): raise AssertionError('should not get here') check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy('add versions.json', [versions.VersionInfo('1.0', '1.0', ['latest'])])
def test_alias_update(self): self._deploy() with commands.deploy(self.cfg, '2.0'): pass commands.alias(self.cfg, '2.0', ['latest'], update_aliases=True) check_call_silent(['git', 'checkout', 'gh-pages']) self._test_state(r'^Copied 2\.0 to latest', [ versions.VersionInfo('2.0', '2.0', ['latest']), versions.VersionInfo('1.0', '1.0'), ])
def test_aliases_copy(self): with commands.deploy(self.cfg, '1.0', aliases=['latest'], redirect=False): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', aliases=['latest']) ], redirect=False)
def test_prefix(self): with commands.deploy(self.cfg, '1.0', aliases=['latest'], prefix='prefix'): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', aliases=['latest']) ], directory='prefix')
def test_alias_overwrite_error(self): self._deploy() with commands.deploy(self.cfg, '2.0'): pass with self.assertRaises(ValueError): commands.alias(self.cfg, '2.0', ['latest']) check_call_silent(['git', 'checkout', 'gh-pages']) self._test_state(r'^Deployed \w+ to 2\.0', [ versions.VersionInfo('2.0', '2.0'), versions.VersionInfo('1.0', '1.0', ['latest']), ])
def test_aliases(self): with commands.deploy(self.cfg, '1.0', aliases=['latest']): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', aliases=['latest']) ]) with open('latest/page.html') as f: self.assertRegex(f.read(), match_redir('../1.0/page.html')) with open('latest/dir/index.html') as f: self.assertRegex(f.read(), match_redir('../../1.0/dir/'))
def test_update_aliases(self): self._mock_commit() with commands.deploy(self.cfg, '2.0', '2.0.0', ['latest'], update_aliases=True): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy('.*', [ versions.VersionInfo('2.0', '2.0.0', ['latest']), versions.VersionInfo('1.0', '1.0', []), ])
def test_aliases_custom_redirect(self): real_open = open with mock.patch('builtins.open', mock.mock_open(read_data=b'{{href}}')): with commands.deploy(self.cfg, '1.0', aliases=['latest'], template='template.html'): # Un-mock `open` so we can copy files for real. with mock.patch('builtins.open', real_open): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', aliases=['latest']) ]) with open('latest/page.html') as f: self.assertEqual(f.read(), '../1.0/page.html') with open('latest/dir/index.html') as f: self.assertEqual(f.read(), '../../1.0/dir/')
def _deploy(self, branch='gh-pages', prefix=''): with commands.deploy(self.cfg, '1.0', branch=branch, prefix=prefix): pass
def _deploy(self, branch='gh-pages'): commands.deploy(self.stage, '1.0', aliases=['stable'], branch=branch) commands.deploy(self.stage, '2.0', branch=branch)
def _deploy(self, branch='gh-pages'): commands.deploy(self.stage, '1.0', aliases=['latest'], branch=branch)
def _deploy(self, branch='gh-pages'): commands.deploy(self.stage, '1.0', branch=branch)
def test_default(self): commands.deploy(self.stage, '1.0') check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy()
def test_title(self): commands.deploy(self.stage, '1.0', '1.0.0') check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy( expected_versions=[versions.VersionInfo('1.0', '1.0.0')])
def test_aliases(self): commands.deploy(self.stage, '1.0', aliases=['latest']) check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy(expected_versions=[ versions.VersionInfo('1.0', aliases=['latest']) ])
def test_commit_message(self): with commands.deploy(self.cfg, '1.0', message='commit message'): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy('^commit message$')
def test_branch(self): with commands.deploy(self.cfg, '1.0', branch='branch'): self._mock_build() check_call_silent(['git', 'checkout', 'branch']) self._test_deploy()
def test_branch(self): commands.deploy(self.stage, '1.0', branch='branch') check_call_silent(['git', 'checkout', 'branch']) self._test_deploy()
def test_commit_message(self): commands.deploy(self.stage, '1.0', message='commit message') check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy('^commit message$')
def test_title(self): with commands.deploy(self.cfg, '1.0', '1.0.0'): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy( expected_versions=[versions.VersionInfo('1.0', '1.0.0')])
def test_default(self): with commands.deploy(self.cfg, '1.0'): self._mock_build() check_call_silent(['git', 'checkout', 'gh-pages']) self._test_deploy()