def test_get_tkn_bad(capsys): with pytest.raises(SystemExit): secret = web_support.get_secret(invoker.configs() + invoker.bad_config()) out, err = capsys.readouterr() assert click.unstyle( err.strip()) == 'No webhook secret has been provided'
def test_listed_repos(betamax_parametrized_session): """Test the list_repos output and exit code""" runner = CliRunner() betamax_parametrized_session.headers.update( {'Accept-Encoding': 'identity'}) result = runner.invoke( cli, ['-c', invoker.configs() + invoker.real_config(), 'list_repos'], obj={'session': betamax_parametrized_session}) assert result.output.split('\n') == invoker.repos() assert result.exit_code == 0
def test_run(betamax_parametrized_session): """Test the run dry function""" runner = CliRunner() betamax_parametrized_session.headers.update( {'Accept-Encoding': 'identity'}) result = runner.invoke(cli, [ '-c', invoker.configs() + invoker.real_config(), 'run', '-v', '-d', 'update' ], obj={'session': betamax_parametrized_session}) assert result.output.split('\n') == invoker.run_dry() assert result.exit_code == 0
def test_listed_labels_not_found(betamax_parametrized_session, repo): """Test the list labels output and exit code for 404""" runner = CliRunner() betamax_parametrized_session.headers.update( {'Accept-Encoding': 'identity'}) result = runner.invoke( cli, ['-c', invoker.configs() + invoker.real_config(), 'list_labels', repo], obj={'session': betamax_parametrized_session}) assert result.output == 'GitHub: ERROR 404 - Not Found\n' assert result.exit_code == 5
def test_get_secret(): secret = web_support.get_secret(invoker.configs() + invoker.real_config()) assert secret == invoker.secret_true()
def test_get_tkn_bad(capsys): with pytest.raises(SystemExit): web_support.get_tkn(invoker.configs() + invoker.bad_config()) out, err = capsys.readouterr() assert click.unstyle( err.strip()) == 'No repositories specification has been found'
def test_get_tkn(): token = web_support.get_tkn(invoker.configs() + invoker.real_config()) assert token == invoker.token_true()
def test_get_config_repos(): repos = web_support.get_config_repos(invoker.configs() + invoker.real_config()) assert repos == invoker.target_repos()
from labelord import cli_support from labelord.cli_support import Label, is_named from tests_unit.conftest import invoker def create_label(): """Test the label creating""" label = Label('test', 'black') assert label.n == 'test' assert label.c == 'black' @pytest.mark.parametrize(['token', 'config'], [('JustSomeRandomTokenForTesting', ''), (None, invoker.configs() + 'config_basic.cfg')]) def test_get_token(token, config): """Test the function that return the token""" check = cli_support.get_token(token, config) assert check == invoker.token() def test_get_token_null(): """Test the function that return None token""" check = cli_support.get_token(None, '') assert check == None def test_check_token(): """Test the function that exit from the application if token is none""" with pytest.raises(SystemExit):