Here are the examples of the python api pytest.mark.cli taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
16 Examples
3
Example 1
@pytest.mark.cli
@pytest.mark.last
def test_signup(user, email, password, parser, api_stg, package_home, capsys):
cmd = "login -u %s -p %s -e %s --signup" % (user, password, email)
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
response = ' >>> Registration complete\n'
out, err = capsys.readouterr()
assert out == response
3
Example 2
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_push_1(package_home, parser, monkeypatch, pkgname, api_stg, capsys):
os.chdir(package_home)
cmd = "push"
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == "package: %s (1.0.1) pushed\n" % pkgname
3
Example 3
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_push_1_existing(package_home, parser, monkeypatch, pkgname, api_stg, capsys):
os.chdir(package_home)
cmd = "push"
args = parser.parse_args(cmd.split(" ") + api_stg)
with pytest.raises(requests.HTTPError):
args.func(args)
3
Example 4
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_push_1_force(package_home, parser, monkeypatch, pkgname, api_stg, capsys):
os.chdir(package_home)
cmd = "push --force"
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == "package: %s (1.0.1) pushed\n" % pkgname
3
Example 5
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_list_packages_ok(package_home, user, parser, pkgname, api_stg, capsys):
cmd = "list -u %s" % user
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
response = """app version downloads
------------------------- --------- -----------
{pkgname} 1.0.1 0\n""".format(pkgname=pkgname)
assert out == response
3
Example 6
@pytest.mark.cli
@pytest.mark.last
def test_show(package_home, parser, pkgname, api_stg, capsys):
os.chdir(package_home)
cmd = "show %s" % pkgname
manifestpath = package_home + "/manifest.yaml"
# Read in the file
filedata = None
with open(manifestpath, 'r') as f:
filedata = f.read()
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == filedata + "\n"
3
Example 7
@pytest.mark.cli
@pytest.mark.last
def test_show_tree(package_home, parser, pkgname, api_stg, capsys):
os.chdir(package_home)
cmd = "show --tree %s" % pkgname
manifestpath = package_home + "/manifest.yaml"
# Read in the file
filedata = None
with open(manifestpath, 'r') as f:
filedata = f.read()
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == """README.md
3
Example 8
@pytest.mark.cli
@pytest.mark.last
def test_show_file(package_home, parser, pkgname, api_stg, capsys):
os.chdir(package_home)
cmd = "show -f templates/kube-ui-rc.yaml %s" % pkgname
path = package_home + "/templates/kube-ui-rc.yaml"
# Read in the file
filedata = None
with open(path, 'r') as f:
filedata = f.read()
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == filedata + "\n"
3
Example 9
@pytest.mark.cli
@pytest.mark.last
def test_logout(cli_home, parser, api_stg, capsys):
os.chdir(str(cli_home))
assert os.path.exists(".kpm/auth_token")
cmd = "logout"
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == ' >>> Logout complete\n'
assert not os.path.exists(".kpm/auth_token")
3
Example 10
@pytest.mark.cli
@pytest.mark.last
def test_login(cli_home, user, password, parser, api_stg, capsys):
os.chdir(str(cli_home))
cmd = "login -u %s -p %s" % (user, password)
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == ' >>> Login succeeded\n'
assert os.path.exists(".kpm/auth_token")
3
Example 11
@pytest.mark.cli
@pytest.mark.last
def test_pull(package_home, parser, pkgname, api_stg):
cmd = "pull %s" % pkgname
os.chdir(str(package_home))
manifestpath = package_home + "/manifest.yaml"
# Read in the file
filedata = None
with open(manifestpath, 'r') as f:
filedata = f.read()
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
pulldata = None
with open(package_home + ("/%s_1.0.1/manifest.yaml" % pkgname.replace("/", "_")), 'r') as f:
pulldata = f.read()
assert pulldata == filedata
3
Example 12
@pytest.mark.cli
@pytest.mark.last
def test_new(cli_home, parser, pkgname, api_stg):
os.chdir(str(cli_home))
cmd = "new t2/test"
args = parser.parse_args(cmd.split(" "))
args.func(args)
assert os.path.exists("t2/test/manifest.yaml")
3
Example 13
@pytest.mark.cli
@pytest.mark.last
def test_delete_package(package_home, user, parser, pkgname, api_stg, capsys):
cmd = "delete-package %s" % pkgname
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
assert out == "Package %s deleted\n" % pkgname
3
Example 14
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_list_packages_missing(package_home, user, parser, pkgname, api_stg, capsys):
cmd = "list -u %s" % user
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
response = """app version downloads
----- --------- -----------\n"""
assert out == response
0
Example 15
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_deploy(project_dir, subcall_all, user, parser, pkgname, api_stg, capsys):
os.chdir(project_dir)
cmd = "deploy %s --namespace=testns" % pkgname
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
response = """create {pkgname} \n
01 - {pkgname}:
--> testns (namespace): {ok}
--> kube-ui (replicationcontroller): {updated}
--> kube-ui (service): {updated}
package version type name namespace status
------------------------- --------- --------------------- ------- ----------- --------
{pkgname} 1.0.1 namespace testns testns {ok}
{pkgname} 1.0.1 replicationcontroller kube-ui testns {updated}
{pkgname} 1.0.1 service kube-ui testns {updated}\n""".format(pkgname=pkgname,
ok=colorize('ok'),
updated=colorize('updated'))
with open("/tmp/r", "w") as f:
f.write(out)
with open("/tmp/r2", "w") as f:
f.write(response)
assert out == response
0
Example 16
Project: kpm Source File: test_kpmcli.py
@pytest.mark.cli
@pytest.mark.last
def test_remove(project_dir, subcall_all, user, parser, pkgname, api_stg, capsys):
os.chdir(project_dir)
cmd = "remove %s --namespace=testns" % pkgname
args = parser.parse_args(cmd.split(" ") + api_stg)
args.func(args)
out, err = capsys.readouterr()
response = """delete {pkgname} \n
01 - {pkgname}:
--> testns (namespace): {protected}
--> kube-ui (replicationcontroller): {deleted}
--> kube-ui (service): {deleted}
package version type name namespace status
------------------------- --------- --------------------- ------- ----------- ---------
{pkgname} 1.0.1 namespace testns testns {protected}
{pkgname} 1.0.1 replicationcontroller kube-ui testns {deleted}
{pkgname} 1.0.1 service kube-ui testns {deleted}\n""".format(pkgname=pkgname,
protected=colorize('protected'),
deleted=colorize('deleted'))
assert out == response