Exemplo n.º 1
0
    def test_no_auth_exit_with_message(self, monkeypatch, capsys):
        """Test that by default the configuration_wizard function exits with a
        relevant message."""
        with monkeypatch.context() as m:
            m.setattr(builtins, "input", lambda *args: False)
            with pytest.raises(SystemExit):
                cli.configuration_wizard()

            out, _ = capsys.readouterr()

        assert out == "No authentication token was provided, please configure again."
Exemplo n.º 2
0
    def test_auth_correct(self, monkeypatch):
        """Test that by default the configuration_wizard function works
        correctly, once the authentication token is passed."""
        with monkeypatch.context() as m:
            auth_prompt = "Please enter the authentication token"
            default_config = cli.create_config()["api"]
            default_auth = "SomeAuth"
            default_config['authentication_token'] = default_auth

            m.setattr(builtins, "input", lambda arg: default_auth if (auth_prompt in arg) else "")
            assert cli.configuration_wizard() == default_config
Exemplo n.º 3
0
    def test_correct_inputs(self, monkeypatch):
        """Test that the configuration_wizard function returns a dictionary
        based on the inputs, when each configuration detail was inputted."""
        with monkeypatch.context() as m:

            auth_prompt = "Please enter the authentication token"
            default_config = cli.create_config()["api"]
            default_auth = "SomeAuth"
            default_config['authentication_token'] = default_auth

            m.setattr(builtins, "input", mock_input)
            assert cli.configuration_wizard() == EXPECTED_KWARGS_FOR_PROMPTS