示例#1
0
 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
示例#2
0
    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'])
        ])
示例#3
0
    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'])])
示例#4
0
    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', []),
        ])
示例#5
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'])
     ])
示例#6
0
 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'])])
示例#7
0
 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'),
     ])
示例#8
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)
示例#9
0
 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')
示例#10
0
 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']),
     ])
示例#11
0
    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/'))
示例#12
0
 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', []),
     ])
示例#13
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/')
示例#14
0
 def _deploy(self, branch='gh-pages', prefix=''):
     with commands.deploy(self.cfg, '1.0', branch=branch, prefix=prefix):
         pass
示例#15
0
 def _deploy(self, branch='gh-pages'):
     commands.deploy(self.stage, '1.0', aliases=['stable'], branch=branch)
     commands.deploy(self.stage, '2.0', branch=branch)
示例#16
0
 def _deploy(self, branch='gh-pages'):
     commands.deploy(self.stage, '1.0', aliases=['latest'], branch=branch)
示例#17
0
 def _deploy(self, branch='gh-pages'):
     commands.deploy(self.stage, '1.0', branch=branch)
示例#18
0
 def test_default(self):
     commands.deploy(self.stage, '1.0')
     check_call_silent(['git', 'checkout', 'gh-pages'])
     self._test_deploy()
示例#19
0
 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')])
示例#20
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'])
     ])
示例#21
0
 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$')
示例#22
0
 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()
示例#23
0
 def test_branch(self):
     commands.deploy(self.stage, '1.0', branch='branch')
     check_call_silent(['git', 'checkout', 'branch'])
     self._test_deploy()
示例#24
0
 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$')
示例#25
0
 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')])
示例#26
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()