@@ -14,18 +14,24 @@ class TestListMethods(unittest.TestCase):
1414
1515 def setUp (self ):
1616 """Set up test fixtures before each test method."""
17- self .scraper = GPlayScraper ()
17+ self .scraper = GPlayScraper () # Initialize scraper
1818 self .collection = "TOP_FREE" # Top free apps collection
1919 self .category = "GAME" # Game category
20+ self .count = 10 # Number of items to fetch
21+ self .lang = "en" # Language
22+ self .country = "us" # Country
2023
2124 def test_list_analyze (self ):
2225 """Test list_analyze returns list of top apps."""
2326 time .sleep (2 )
2427 try :
25- result = self .scraper .list_analyze (self .collection , self .category , count = 10 )
28+ result = self .scraper .list_analyze (self .collection , self .category , count = self . count , lang = self . lang , country = self . country )
2629 self .assertIsInstance (result , list )
2730 if result :
2831 self .assertGreater (len (result ), 0 )
32+ print (f"\n ✅ Top { self .collection } { self .category } apps ({ len (result )} apps):" )
33+ for i , app in enumerate (result [:3 ]): # Show first 3 apps
34+ print (f" { i + 1 } . { app .get ('title' , 'N/A' )} - { app .get ('developer' , 'N/A' )} " )
2935 except (NetworkError , RateLimitError , GPlayScraperError ) as e :
3036 warnings .warn (f"Network/Rate limit error in test_list_analyze: { e } " )
3137 self .skipTest (f"Skipping due to network/rate limit: { e } " )
@@ -34,8 +40,12 @@ def test_list_get_field(self):
3440 """Test list_get_field returns list of field values."""
3541 time .sleep (2 )
3642 try :
37- result = self .scraper .list_get_field (self .collection , self .category , "title" , count = 5 )
43+ result = self .scraper .list_get_field (self .collection , self .category , "title" , count = self . count , lang = self . lang , country = self . country )
3844 self .assertIsInstance (result , list )
45+ if result :
46+ print (f"\n ✅ Top chart app titles ({ len (result )} apps):" )
47+ for i , title in enumerate (result [:3 ]):
48+ print (f" { i + 1 } . { title } " )
3949 except (NetworkError , RateLimitError , GPlayScraperError ) as e :
4050 warnings .warn (f"Network/Rate limit error in test_list_get_field: { e } " )
4151 self .skipTest (f"Skipping due to network/rate limit: { e } " )
@@ -44,8 +54,12 @@ def test_list_get_fields(self):
4454 """Test list_get_fields returns list of dictionaries."""
4555 time .sleep (2 )
4656 try :
47- result = self .scraper .list_get_fields (self .collection , self .category , ["title" , "score" ], count = 5 )
57+ result = self .scraper .list_get_fields (self .collection , self .category , ["title" , "score" ], count = self . count , lang = self . lang , country = self . country )
4858 self .assertIsInstance (result , list )
59+ if result :
60+ print (f"\n ✅ Top chart app fields ({ len (result )} apps):" )
61+ for i , app in enumerate (result [:3 ]):
62+ print (f" { i + 1 } . { app .get ('title' , 'N/A' )} - { app .get ('score' , 'N/A' )} stars" )
4963 except (NetworkError , RateLimitError , GPlayScraperError ) as e :
5064 warnings .warn (f"Network/Rate limit error in test_list_get_fields: { e } " )
5165 self .skipTest (f"Skipping due to network/rate limit: { e } " )
@@ -54,7 +68,8 @@ def test_list_print_field(self):
5468 """Test list_print_field executes without error."""
5569 time .sleep (2 )
5670 try :
57- self .scraper .list_print_field (self .collection , self .category , "title" , count = 5 )
71+ print (f"\n ✅ list_print_field output:" )
72+ self .scraper .list_print_field (self .collection , self .category , "title" , count = self .count , lang = self .lang , country = self .country )
5873 except (NetworkError , RateLimitError , GPlayScraperError ) as e :
5974 warnings .warn (f"Network/Rate limit error in test_list_print_field: { e } " )
6075 self .skipTest (f"Skipping due to network/rate limit: { e } " )
@@ -65,7 +80,8 @@ def test_list_print_fields(self):
6580 """Test list_print_fields executes without error."""
6681 time .sleep (2 )
6782 try :
68- self .scraper .list_print_fields (self .collection , self .category , ["title" , "score" ], count = 5 )
83+ print (f"\n ✅ list_print_fields output:" )
84+ self .scraper .list_print_fields (self .collection , self .category , ["title" , "score" ], count = self .count , lang = self .lang , country = self .country )
6985 except (NetworkError , RateLimitError , GPlayScraperError ) as e :
7086 warnings .warn (f"Network/Rate limit error in test_list_print_fields: { e } " )
7187 self .skipTest (f"Skipping due to network/rate limit: { e } " )
@@ -76,7 +92,8 @@ def test_list_print_all(self):
7692 """Test list_print_all executes without error."""
7793 time .sleep (2 )
7894 try :
79- self .scraper .list_print_all (self .collection , self .category , count = 5 )
95+ print (f"\n ✅ list_print_all output:" )
96+ self .scraper .list_print_all (self .collection , self .category , count = self .count , lang = self .lang , country = self .country )
8097 except (NetworkError , RateLimitError , GPlayScraperError ) as e :
8198 warnings .warn (f"Network/Rate limit error in test_list_print_all: { e } " )
8299 self .skipTest (f"Skipping due to network/rate limit: { e } " )
0 commit comments