Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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_ahead_remote(self):
with git_utils.Commit('gh-pages', 'add file') as commit:
commit.add_file(git_utils.FileInfo(
'file.txt', 'this is some text'
))
origin_rev = git_utils.get_latest_commit('gh-pages')
stage_dir('deploy_clone')
check_call_silent(['git', 'clone', self.stage, '.'])
check_call_silent(['git', 'fetch', 'origin', 'gh-pages:gh-pages'])
git_config()
with git_utils.Commit('gh-pages', 'add file') as commit:
commit.add_file(git_utils.FileInfo(
'file2.txt', 'this is some text'
))
old_rev = git_utils.get_latest_commit('gh-pages')
assertPopen(['mike', 'deploy', '1.0'])
def test_ahead_remote(self):
with git_utils.Commit('gh-pages', 'add file') as commit:
commit.add_file(git_utils.FileInfo(
'file.txt', 'this is some text'
))
origin_rev = git_utils.get_latest_commit('gh-pages')
stage_dir('deploy_clone')
check_call_silent(['git', 'clone', self.stage, '.'])
check_call_silent(['git', 'fetch', 'origin', 'gh-pages:gh-pages'])
git_config()
with git_utils.Commit('gh-pages', 'add file') as commit:
commit.add_file(git_utils.FileInfo(
'file2.txt', 'this is some text'
))
old_rev = git_utils.get_latest_commit('gh-pages')
assertPopen(['mike', 'deploy', '1.0'])
self.assertEqual(git_utils.get_latest_commit('gh-pages^'), old_rev)
self.assertEqual(git_utils.get_latest_commit('gh-pages^^'), origin_rev)
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_versions_exist(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": []}]',
))
self.assertEqual(list(commands.list_versions()), [
versions.VersionInfo('1.0'),
])
def test_subdir(self):
files = sorted(git_utils.walk_files('branch', 'dir'),
key=lambda x: x.path)
self.assertEqual(files, [
git_utils.FileInfo(os.path.join('dir', 'file 2.txt'),
b'more text'),
git_utils.FileInfo(os.path.join('dir', 'file.txt'), b'more text'),
git_utils.FileInfo(os.path.join('dir', 'subdir', 'file 3.txt'),
b'even more text'),
])
def test_copy_start(self):
f = git_utils.FileInfo(os.path.join('dir', 'file.txt'), '')
self.assertEqual(f.copy('destdir', 'dir'), git_utils.FileInfo(
os.path.join('destdir', 'file.txt'), ''
))
def test_root(self):
files = sorted(git_utils.walk_files('branch'),
key=lambda x: x.path)
self.assertEqual(files, [
git_utils.FileInfo(os.path.join('dir', 'file 2.txt'),
b'more text'),
git_utils.FileInfo(os.path.join('dir', 'file.txt'), b'more text'),
git_utils.FileInfo(os.path.join('dir', 'subdir', 'file 3.txt'),
b'even more text'),
git_utils.FileInfo('file.txt', b'text'),
])
def make_nojekyll():
return git_utils.FileInfo('.nojekyll', '')
def copy(self, destdir='', start=''):
return FileInfo(
os.path.join(destdir, os.path.relpath(self.path, start)),
self.data, self.mode
)