def test_cli_env_vars(argv, monkeypatch): """Should use credentials from the environment.""" monkeypatch.setattr('os.path.isfile', lambda x: False) monkeypatch.setattr(cli, 'notebook_to_page', mock_notebook_to_page) monkeypatch.setenv('CONFLUENCE_USERNAME', 'fake-username') monkeypatch.setenv('CONFLUENCE_PASSWORD', 'fake-password') cli.main(argv)
def test_cli_args(argv, monkeypatch): """Should respect command line arguments.""" monkeypatch.setattr('os.path.isfile', lambda x: False) monkeypatch.setattr(cli, 'notebook_to_page', mock_notebook_to_page) monkeypatch.setitem(__builtins__, 'input', lambda x: 'fake-username') monkeypatch.setattr('getpass.getpass', lambda x: 'fake-password') cli.main(argv)
def test_blank_username(argv, monkeypatch): """Should default to the current username.""" monkeypatch.setattr('os.path.isfile', lambda x: False) monkeypatch.setattr(cli, 'notebook_to_page', mock_notebook_to_page) monkeypatch.setitem(__builtins__, 'input', lambda x: '') monkeypatch.setattr('getpass.getpass', lambda x: 'fake-password') monkeypatch.setattr('getpass.getuser', lambda: 'fake-username') cli.main(argv)
def test_cli_creds_file(argv, tmpdir, monkeypatch): """Should use credentials from the user's home directory.""" monkeypatch.setattr(cli, 'notebook_to_page', mock_notebook_to_page) monkeypatch.setattr('os.path.isfile', lambda x: True) cfg = tmpdir.mkdir('nbconflux_test').join('.nbconflux') cfg.write('fake-username:fake-password') monkeypatch.setattr('os.path.expanduser', lambda x: str(cfg)) cli.main(argv)