Пример #1
0
def test_authholder_cookiejar_filepath():
    """Builds the cookiejar filepath in user's config directory."""
    with patch("appdirs.user_config_dir") as mock:
        mock.return_value = "testpath"
        ah = _AuthHolder()

    assert ah._cookiejar_filepath == "testpath"
    mock.assert_called_once_with("charmcraft.credentials")
Пример #2
0
def auth_holder(tmp_path):
    """Produce an _AuthHolder instance with encapsulated resources.

    In detail:

    - writes into a temp dir

    - with a mocked webbrowser module
    """

    ah = _AuthHolder()
    ah._cookiejar_filepath = str(tmp_path / "test.credentials")

    with patch("webbrowser.open"):
        yield ah