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_latest_tag_or_mod_commit(git_repo):
open('tag-mod.txt', "w").close()
git_repo.index.add("tag-mod.txt")
tag_commit = git_repo.index.commit("tag commit")
git_repo.create_tag("1.0.0", message="1.0.0")
open('post-tag-mod.txt', "w").close()
git_repo.index.add("post-tag-mod.txt")
post_tag_commit = git_repo.index.commit("post tag commit")
assert latest_tag_or_mod_commit("chartpress.yaml") == tag_commit.hexsha[:7]
assert latest_tag_or_mod_commit("tag-mod.txt") == tag_commit.hexsha[:7]
assert latest_tag_or_mod_commit("post-tag-mod.txt") == post_tag_commit.hexsha[:7]
def test_latest_tag_or_mod_commit(git_repo):
open('tag-mod.txt', "w").close()
git_repo.index.add("tag-mod.txt")
tag_commit = git_repo.index.commit("tag commit")
git_repo.create_tag("1.0.0", message="1.0.0")
open('post-tag-mod.txt', "w").close()
git_repo.index.add("post-tag-mod.txt")
post_tag_commit = git_repo.index.commit("post tag commit")
assert latest_tag_or_mod_commit("chartpress.yaml") == tag_commit.hexsha[:7]
assert latest_tag_or_mod_commit("tag-mod.txt") == tag_commit.hexsha[:7]
assert latest_tag_or_mod_commit("post-tag-mod.txt") == post_tag_commit.hexsha[:7]
def test_latest_tag_or_mod_commit(git_repo):
open('tag-mod.txt', "w").close()
git_repo.index.add("tag-mod.txt")
tag_commit = git_repo.index.commit("tag commit")
git_repo.create_tag("1.0.0", message="1.0.0")
open('post-tag-mod.txt', "w").close()
git_repo.index.add("post-tag-mod.txt")
post_tag_commit = git_repo.index.commit("post tag commit")
assert latest_tag_or_mod_commit("chartpress.yaml") == tag_commit.hexsha[:7]
assert latest_tag_or_mod_commit("tag-mod.txt") == tag_commit.hexsha[:7]
assert latest_tag_or_mod_commit("post-tag-mod.txt") == post_tag_commit.hexsha[:7]
def _capture_output(args, capfd):
"""
Calls chartpress given provided arguments and captures the output during the
call.
"""
# clear cache of in memory cached functions
# this allows us to better mimic the chartpress CLI behavior
chartpress.image_needs_building.cache_clear()
chartpress.image_needs_pushing.cache_clear()
chartpress.latest_tag_or_mod_commit.cache_clear()
# first flush past captured output, then run chartpress, and finally read
# and save all output that came of it
_, _ = capfd.readouterr()
chartpress.main(args)
out, err = capfd.readouterr()
# since the output was captured, print it back out again for debugging
# purposes if a test fails for example
header = f'--- chartpress {" ".join(args)} ---'
footer = "-" * len(header)
print()
print(header)
print(out)
print(footer)
return out
def _capture_output(args, capfd):
"""
Calls chartpress given provided arguments and captures the output during the
call.
"""
# clear cache of in memory cached functions
# this allows us to better mimic the chartpress CLI behavior
chartpress.image_needs_building.cache_clear()
chartpress.image_needs_pushing.cache_clear()
chartpress.latest_tag_or_mod_commit.cache_clear()
# first flush past captured output, then run chartpress, and finally read
# and save all output that came of it
_, _ = capfd.readouterr()
chartpress.main(args)
out, err = capfd.readouterr()
# since the output was captured, print it back out again for debugging
# purposes if a test fails for example
header = f'--- chartpress {" ".join(args)} ---'
footer = "-" * len(header)
print()
print(header)
print(out)
def test_image_needs_pushing():
assert image_needs_pushing("jupyterhub/image-not-to-be-found:latest")
assert not image_needs_pushing("jupyterhub/k8s-hub:0.8.2")
def _capture_output(args, capfd):
"""
Calls chartpress given provided arguments and captures the output during the
call.
"""
# clear cache of in memory cached functions
# this allows us to better mimic the chartpress CLI behavior
chartpress.image_needs_building.cache_clear()
chartpress.image_needs_pushing.cache_clear()
chartpress.latest_tag_or_mod_commit.cache_clear()
# first flush past captured output, then run chartpress, and finally read
# and save all output that came of it
_, _ = capfd.readouterr()
chartpress.main(args)
out, err = capfd.readouterr()
# since the output was captured, print it back out again for debugging
# purposes if a test fails for example
header = f'--- chartpress {" ".join(args)} ---'
footer = "-" * len(header)
print()
print(header)
print(out)
print(footer)
def test_image_needs_pushing():
assert image_needs_pushing("jupyterhub/image-not-to-be-found:latest")
assert not image_needs_pushing("jupyterhub/k8s-hub:0.8.2")
def _capture_output(args, capfd):
"""
Calls chartpress given provided arguments and captures the output during the
call.
"""
# clear cache of in memory cached functions
# this allows us to better mimic the chartpress CLI behavior
chartpress.image_needs_building.cache_clear()
chartpress.image_needs_pushing.cache_clear()
chartpress.latest_tag_or_mod_commit.cache_clear()
# first flush past captured output, then run chartpress, and finally read
# and save all output that came of it
_, _ = capfd.readouterr()
chartpress.main(args)
out, err = capfd.readouterr()
# since the output was captured, print it back out again for debugging
# purposes if a test fails for example
header = f'--- chartpress {" ".join(args)} ---'
footer = "-" * len(header)
print()
print(header)
print(out)
print(footer)
return out
def test_git_remote(monkeypatch):
monkeypatch.setenv(GITHUB_TOKEN_KEY, "test-github-token")
assert git_remote("jupyterhub/helm-chart") == "https://test-github-token@github.com/jupyterhub/helm-chart"
monkeypatch.delenv(GITHUB_TOKEN_KEY)
assert git_remote("jupyterhub/helm-chart") == "git@github.com:jupyterhub/helm-chart"