22from viu_media .libs .media_api .types import UserProfile
33
44
5- def test_load_auth_creates_file_when_missing (tmp_path , monkeypatch ):
5+ def test_load_auth_creates_file_when_missing (tmp_path ):
66 auth_file = tmp_path / "auth.json"
7- monkeypatch .setattr ("viu_media.cli.service.auth.service.AUTH_FILE" , auth_file )
87
9- service = AuthService (media_api = "anilist" )
8+ service = AuthService (media_api = "anilist" , auth_file = auth_file )
109 profile = service .get_auth ()
1110
1211 assert profile is None
1312 assert auth_file .exists ()
13+ assert (tmp_path / "auth.lock" ).exists () is False
1414
1515
16- def test_save_and_get_auth_roundtrip (tmp_path , monkeypatch ):
16+ def test_save_and_get_auth_roundtrip (tmp_path ):
1717 auth_file = tmp_path / "auth.json"
18- monkeypatch .setattr ("viu_media.cli.service.auth.service.AUTH_FILE" , auth_file )
1918
20- service = AuthService (media_api = "anilist" )
19+ service = AuthService (media_api = "anilist" , auth_file = auth_file )
2120 user = UserProfile (id = 1 , name = "test-user" , avatar_url = "https://img/avatar.png" )
2221
2322 service .save_user_profile (user , "token-abc" )
@@ -28,11 +27,10 @@ def test_save_and_get_auth_roundtrip(tmp_path, monkeypatch):
2827 assert auth .user_profile .name == "test-user"
2928
3029
31- def test_clear_user_profile_deletes_auth_file (tmp_path , monkeypatch ):
30+ def test_clear_user_profile_deletes_auth_file (tmp_path ):
3231 auth_file = tmp_path / "auth.json"
33- monkeypatch .setattr ("viu_media.cli.service.auth.service.AUTH_FILE" , auth_file )
3432
35- service = AuthService (media_api = "anilist" )
33+ service = AuthService (media_api = "anilist" , auth_file = auth_file )
3634 user = UserProfile (id = 2 , name = "clear-me" )
3735 service .save_user_profile (user , "token" )
3836 assert auth_file .exists ()
0 commit comments