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
|
import unittest
|
||||||
from html import escape
|
from html import escape
|
||||||
from tmdb.tmdb_api import Movie, TvShow, MoviePopular
|
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 tmdb.database import Database
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
import time
|
import aiohttp
|
||||||
import requests
|
|
||||||
|
|
||||||
def apiRequests(command):
|
|
||||||
|
async def apiRequests(command):
|
||||||
api_key = '51d75c00dc1502dc894b7773ec3e7a15'
|
api_key = '51d75c00dc1502dc894b7773ec3e7a15'
|
||||||
base_url = "https://api.themoviedb.org/3/"
|
base_url = "https://api.themoviedb.org/3/"
|
||||||
url = base_url + command.lstrip('/')
|
url = base_url + command.lstrip('/')
|
||||||
params = {'api_key': api_key}
|
params = {'api_key': api_key}
|
||||||
params.update({'language': 'en'})
|
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):
|
class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
# TMDB API
|
# TMDB API
|
||||||
async def test_search_item(self):
|
async def test_search_item(self):
|
||||||
start = time.time()
|
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
await movie.load_parameters()
|
await movie.load_parameters()
|
||||||
id = await movie.search_title('Breakfast Club')
|
id = await movie.search_title('Breakfast Club')
|
||||||
|
@ -139,7 +140,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
await movie.close_session()
|
await movie.close_session()
|
||||||
|
|
||||||
async def test_movie_popular_length(self):
|
async def test_movie_popular_length(self):
|
||||||
results = apiRequests('/movie/popular')
|
results = await apiRequests('/movie/popular')
|
||||||
list = MoviePopular()
|
list = MoviePopular()
|
||||||
await list.load_parameters()
|
await list.load_parameters()
|
||||||
text = await list.query()
|
text = await list.query()
|
||||||
|
@ -147,7 +148,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
await list.close_session()
|
await list.close_session()
|
||||||
|
|
||||||
async def test_movie_popular_id(self):
|
async def test_movie_popular_id(self):
|
||||||
results = apiRequests('/movie/popular')
|
results = await apiRequests('/movie/popular')
|
||||||
list = MoviePopular()
|
list = MoviePopular()
|
||||||
await list.load_parameters()
|
await list.load_parameters()
|
||||||
await list.query()
|
await list.query()
|
||||||
|
@ -155,7 +156,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
await list.close_session()
|
await list.close_session()
|
||||||
|
|
||||||
async def test_movie_popular_html(self):
|
async def test_movie_popular_html(self):
|
||||||
results = apiRequests('/movie/popular')
|
results = await apiRequests('/movie/popular')
|
||||||
list = MoviePopular()
|
list = MoviePopular()
|
||||||
await list.load_parameters()
|
await list.load_parameters()
|
||||||
await list.query()
|
await list.query()
|
||||||
|
@ -166,7 +167,7 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
await list.close_session()
|
await list.close_session()
|
||||||
|
|
||||||
async def test_movie_popular_text(self):
|
async def test_movie_popular_text(self):
|
||||||
results = apiRequests('/movie/popular')
|
results = await apiRequests('/movie/popular')
|
||||||
list = MoviePopular()
|
list = MoviePopular()
|
||||||
await list.load_parameters()
|
await list.load_parameters()
|
||||||
await list.query()
|
await list.query()
|
||||||
|
@ -176,5 +177,6 @@ class TestTmdbMethods(unittest.IsolatedAsyncioTestCase):
|
||||||
self.assertEqual(tested, test_result)
|
self.assertEqual(tested, test_result)
|
||||||
await list.close_session()
|
await list.close_session()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in a new issue