test restructuring via pytest

This commit is contained in:
sigma67 2024-01-02 21:58:33 +01:00 • committed by sigma67
commit 69dd4a9f2f
19 changed files with 858 additions and 619 deletions

View file

@ -0,0 +1,17 @@
from unittest import mock
import ytmusicapi.setup
from ytmusicapi.setup import main
class TestBrowser:
def test_setup_browser(self, config, browser_filepath: str):
headers = ytmusicapi.setup(browser_filepath, config["auth"]["headers_raw"])
assert len(headers) >= 2
headers_raw = config["auth"]["headers_raw"].split("\n")
with (
mock.patch("sys.argv", ["ytmusicapi", "browser", "--file", browser_filepath]),
mock.patch("builtins.input", side_effect=(headers_raw + [EOFError()])),
):
headers = main()
assert len(headers) >= 2