def test_main():
    """Checks main returns without exception when invoked with minimal args
        assuming run() and add_args() are implemented
    """
    task = PulpTask()
    arg = ["", "--pulp-url", "http://some.url", "--verbose", "--debug"]
    with patch("sys.argv", arg):
        with patch("pubtools._pulp.task.PulpTask.run"):
            assert task.main() == 0
def test_pulp_client():
    """Checks that the client in the task is an instance of pubtools.pulplib.Client"""
    task = PulpTask()
    arg = ["", "--pulp-url", "http://some.url", "--pulp-user", "user"]
    with patch("sys.argv", arg):
        client = task.pulp_client

    assert isinstance(client, Client)
def test_init_args():
    """Checks whether the args from cli are available for the task"""
    task = PulpTask()
    arg = ["", "--pulp-url", "http://some.url", "--verbose", "--debug"]
    with patch("sys.argv", arg):
        task_args = task.args

    cli_args = ["pulp_url", "pulp_user", "pulp_password", "verbose", "debug"]
    for a in cli_args:
        assert hasattr(task_args, a)
Exemple #4
0
def test_task_run():
    """ raises if run() is not implemeted"""
    task = PulpTask()
    with pytest.raises(NotImplementedError):
        task.run()