def test_invalid_parameters(self): w = Wallhaven() username = '******' collection_id = 1 with self.assertRaises(KeyError): w.get_collection(username, collection_id, test_parameter='1111') with self.assertRaises(ValueError): w.get_collection(username, collection_id, purity='1111') with self.assertRaises(ValueError): # noinspection PyTypeChecker w.get_collection(username, collection_id, page='-1')
def test_valid_user_collection_json(self): with open(get_resource_file("test_user_collection.json"), 'r') as fp: mock_json = json.load(fp) username = '******' collection_id = 1 responses.add( responses.GET, 'https://wallhaven.cc/api/v1/collections/{}/{}'.format( username, str(collection_id)), status=200, json=mock_json) w = Wallhaven() collection, meta = w.get_collection(username, collection_id) self.assertIsInstance(collection, list), for w in collection: self.assertIsInstance(w, Wallpaper) self.assertIsInstance(meta, Meta)