Пример #1
0
 def test_paged_collection_invalid_parameters(self):
     w = Wallhaven()
     username = '******'
     collection_id = 1
     with self.assertRaises(KeyError):
         next(
             w.get_collection_pages(username,
                                    collection_id,
                                    test_parameter='1111'))
     with self.assertRaises(ValueError):
         next(w.get_collection_pages(username, collection_id,
                                     purity='1111'))
     with self.assertRaises(AttributeError):
         next(w.get_collection_pages(username, collection_id, page='-1'))
Пример #2
0
 def test_paged_collection(self):
     username = '******'
     collection_id = 1
     for i in range(1, 4):
         with open(
                 get_resource_file(
                     os.path.join("test_paged_collection",
                                  f"page{i}.json")), 'r') as fp:
             responses.add(
                 responses.GET,
                 f"https://wallhaven.cc/api/v1/collections/{username}/{collection_id}?page={i}",
                 status=200,
                 json=json.load(fp))
     w = Wallhaven()
     wallpaper_list = []
     collection_pages = w.get_collection_pages(username, collection_id)
     for wallpapers, meta in collection_pages:
         self.assertIsInstance(meta, Meta)
         for w in wallpapers:
             self.assertIsInstance(w, Wallpaper)
         wallpaper_list.extend(wallpapers)
     self.assertEqual(len(wallpaper_list), 72)