Ejemplo n.º 1
0
 def test_valid_collections_json(self):
     with open(get_resource_file("test_collections.json"), 'r') as fp:
         mock_json = json.load(fp)
         responses.add(responses.GET,
                       'https://wallhaven.cc/api/v1/collections',
                       status=200,
                       json=mock_json)
         w = Wallhaven(api_key='testkeyisinvalid')
         collections = w.get_collections()
         self.assertIsInstance(collections, list)
         for c in collections:
             self.assertIsInstance(c, Collection)
Ejemplo n.º 2
0
 def test_valid_user_collections_json(self):
     with open(get_resource_file("test_user_collections.json"), 'r') as fp:
         mock_json = json.load(fp)
         username = '******'
         responses.add(
             responses.GET,
             'https://wallhaven.cc/api/v1/collections/{}'.format(username),
             status=200,
             json=mock_json)
         w = Wallhaven()
         collections = w.get_collections(username=username)
         self.assertIsInstance(collections, list)
         for c in collections:
             self.assertIsInstance(c, Collection)
Ejemplo n.º 3
0
 def test_without_api_key(self):
     w = Wallhaven()
     with self.assertRaises(AttributeError):
         w.get_collections()