11"""
2- Integration tests — require a valid KIDPLAN_COOKIE environment variable .
2+ Integration tests — require KIDPLAN_USERNAME and KIDPLAN_PASSWORD environment variables .
33
44These tests hit the real Kidplan API to verify that:
5+ - Authentication still works
56 - The album listing endpoint still returns data
67 - Album pages still contain parseable image links
78 - Image URLs are reachable and serve valid image content
89
910Run locally:
10- KIDPLAN_COOKIE=<value> pytest tests/test_integration.py -v
11+ KIDPLAN_USERNAME=your@email.com KIDPLAN_PASSWORD=secret pytest tests/test_integration.py -v
1112"""
1213
1314import imghdr
1718import pytest
1819import requests
1920
20- from kidplan_fetcher .cli import get_all_albums , get_fullsize_urls
21+ from kidplan_fetcher .cli import get_all_albums , get_fullsize_urls , login
22+
23+ USERNAME = os .getenv ("KIDPLAN_USERNAME" )
24+ PASSWORD = os .getenv ("KIDPLAN_PASSWORD" )
2125
22- COOKIE = os .getenv ("KIDPLAN_COOKIE" )
2326pytestmark = pytest .mark .skipif (
24- not COOKIE ,
25- reason = "KIDPLAN_COOKIE environment variable not set" ,
27+ not USERNAME or not PASSWORD ,
28+ reason = "KIDPLAN_USERNAME and KIDPLAN_PASSWORD environment variables not set" ,
2629)
2730
2831
2932@pytest .fixture (scope = "module" )
3033def session ():
3134 s = requests .Session ()
3235 s .headers ["User-Agent" ] = "Mozilla/5.0 (kidplan-fetcher-test)"
33- s . cookies . set ( ".ASPXAUTH" , COOKIE , domain = "app.kidplan.com" )
36+ assert login ( s , USERNAME , PASSWORD ), "Login failed — check credentials"
3437 return s
3538
3639
@@ -50,7 +53,6 @@ def test_album_list_has_required_fields(albums):
5053
5154
5255def test_album_list_modified_timestamp (albums ):
53- """Modified field must be parseable as /Date(ms)/."""
5456 import re
5557 for album in albums [:5 ]:
5658 assert re .search (r"\d+" , album .get ("Modified" , "" )), (
@@ -59,7 +61,6 @@ def test_album_list_modified_timestamp(albums):
5961
6062
6163def test_first_album_with_pictures_has_image_urls (session , albums ):
62- """Find the first non-empty album and verify image URLs are returned."""
6364 target = next ((a for a in albums if a .get ("PictureCount" , 0 ) > 0 ), None )
6465 assert target is not None , "No album with pictures found"
6566
@@ -75,10 +76,9 @@ def test_image_urls_have_no_size_param(session, albums):
7576
7677
7778def test_first_image_is_downloadable_jpeg (session , albums ):
78- """Download the first image from the first non-empty album and verify it's a valid image."""
7979 target = next ((a for a in albums if a .get ("PictureCount" , 0 ) > 0 ), None )
8080 pictures = get_fullsize_urls (session , target ["AlbumId" ])
81- assert pictures , "No pictures to test"
81+ assert pictures
8282
8383 _guid , url = pictures [0 ]
8484 resp = session .get (url , stream = True , timeout = 30 )
0 commit comments