Fixed Flake
This commit is contained in:
parent
954a55e628
commit
339998ab93
22
test_tmdb.py
22
test_tmdb.py
|
@ -2,25 +2,26 @@
|
|||
import unittest
|
||||
from html import escape
|
||||
from tmdb.tmdb_api import Movie, TvShow, MoviePopular
|
||||
from tmdb.tmdb import TmdbBot, MessageConstructor
|
||||
from tmdb.tmdb import TmdbBot
|
||||
from tmdb.database import Database
|
||||
from sqlalchemy import create_engine
|
||||
import time
|
||||
import requests
|
||||
import aiohttp
|
||||
|
||||
def apiRequests(command):
|
||||
|
||||
async def apiRequests(command):
|
||||
api_key = '51d75c00dc1502dc894b7773ec3e7a15'
|
||||
base_url = "https://api.themoviedb.org/3/"
|
||||
url = base_url + command.lstrip('/')
|
||||
params = {'api_key': api_key}
|
||||
params.update({'language': 'en'})
|
||||
return requests.get(url, params=params).json()
|
||||
async with aiohttp.ClientSession() as client:
|
||||
async with client.get(url, params=params) as resp:
|
||||
return await resp.json()
|
||||
|
||||
|
||||
class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||
# TMDB API
|
||||
async def test_search_item(self):
|
||||
start = time.time()
|
||||
movie = Movie()
|
||||
await movie.load_parameters()
|
||||
id = await movie.search_title('Breakfast Club')
|
||||
|
@ -139,7 +140,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
|||
await movie.close_session()
|
||||
|
||||
async def test_movie_popular_length(self):
|
||||
results = apiRequests('/movie/popular')
|
||||
results = await apiRequests('/movie/popular')
|
||||
list = MoviePopular()
|
||||
await list.load_parameters()
|
||||
text = await list.query()
|
||||
|
@ -147,7 +148,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
|||
await list.close_session()
|
||||
|
||||
async def test_movie_popular_id(self):
|
||||
results = apiRequests('/movie/popular')
|
||||
results = await apiRequests('/movie/popular')
|
||||
list = MoviePopular()
|
||||
await list.load_parameters()
|
||||
await list.query()
|
||||
|
@ -155,7 +156,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
|||
await list.close_session()
|
||||
|
||||
async def test_movie_popular_html(self):
|
||||
results = apiRequests('/movie/popular')
|
||||
results = await apiRequests('/movie/popular')
|
||||
list = MoviePopular()
|
||||
await list.load_parameters()
|
||||
await list.query()
|
||||
|
@ -166,7 +167,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
|||
await list.close_session()
|
||||
|
||||
async def test_movie_popular_text(self):
|
||||
results = apiRequests('/movie/popular')
|
||||
results = await apiRequests('/movie/popular')
|
||||
list = MoviePopular()
|
||||
await list.load_parameters()
|
||||
await list.query()
|
||||
|
@ -176,5 +177,6 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
|||
self.assertEqual(tested, test_result)
|
||||
await list.close_session()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue