-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fa0b91
commit f6e33af
Showing
46 changed files
with
4,340 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
aiohttp==3.8.4 | ||
dacite==1.8.0 | ||
requests==2.28.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from themoviedb import tmdb, schemas | ||
|
||
|
||
def test_create_guest_session(get_data, assert_data): | ||
data = get_data("authentication/create_guest_session") | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
session = tmdb.TMDb().authentication().create_guest_session() | ||
mocked.assert_called_with( | ||
"GET", | ||
"https://api.themoviedb.org/3/authentication/guest_session/new", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
} | ||
) | ||
|
||
assert isinstance(session, schemas.GuestAuthentication) | ||
assert assert_data(session, data) | ||
|
||
|
||
def test_create_token(get_data, assert_data): | ||
data = get_data("authentication/create_token") | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
token = tmdb.TMDb().authentication().create_token() | ||
mocked.assert_called_with( | ||
"GET", | ||
"https://api.themoviedb.org/3/authentication/token/new", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
} | ||
) | ||
|
||
assert isinstance(token, schemas.TokenAuthentication) | ||
assert assert_data(token, data) | ||
|
||
|
||
def test_create_session(get_data, assert_data): | ||
data = get_data("authentication/create_session") | ||
request_token = "TOKEN" | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
session = tmdb.TMDb().authentication().create_session(request_token) | ||
mocked.assert_called_with( | ||
"POST", | ||
"https://api.themoviedb.org/3/authentication/session/new", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
json={"request_token": request_token}, | ||
) | ||
|
||
assert isinstance(session, schemas.Session) | ||
assert assert_data(session, data) | ||
|
||
|
||
def test_create_session_with_login(get_data, assert_data): | ||
data = get_data("authentication/create_session_with_login") | ||
username = "USERNAME" | ||
password = "PASSWORD" | ||
request_token = "TOKEN" | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
session = tmdb.TMDb().authentication().create_session_with_login( | ||
username, | ||
password, | ||
request_token, | ||
) | ||
mocked.assert_called_with( | ||
"POST", | ||
"https://api.themoviedb.org/3/authentication/token/validate_with_login", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
json={ | ||
"username": username, | ||
"password": password, | ||
"request_token": request_token, | ||
}, | ||
) | ||
|
||
assert isinstance(session, schemas.TokenAuthentication) | ||
assert assert_data(session, data) | ||
|
||
|
||
def test_delete_session(get_data, assert_data): | ||
data = get_data("authentication/delete_session") | ||
session_id = "SESSION_ID" | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
session = tmdb.TMDb().authentication().delete_session(session_id) | ||
mocked.assert_called_with( | ||
"DELETE", | ||
"https://api.themoviedb.org/3/authentication/session", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
json={"session_id": session_id}, | ||
) | ||
|
||
assert isinstance(session, schemas.Response) | ||
assert assert_data(session, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from themoviedb import tmdb, schemas | ||
|
||
|
||
def test_certifications_movie(get_data, assert_data): | ||
data = get_data("certifications/movie_list") | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
certifications = tmdb.TMDb().certifications().movie() | ||
mocked.assert_called_with( | ||
"GET", | ||
"https://api.themoviedb.org/3/certification/movie/list", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
} | ||
) | ||
|
||
assert isinstance(certifications, schemas.Certifications) | ||
assert assert_data(certifications, data) | ||
|
||
|
||
def test_certifications_tv(get_data, assert_data): | ||
data = get_data("certifications/tv_list") | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
certifications = tmdb.TMDb().certifications().tv() | ||
mocked.assert_called_with( | ||
"GET", | ||
"https://api.themoviedb.org/3/certification/tv/list", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
} | ||
) | ||
assert isinstance(certifications, schemas.Certifications) | ||
assert assert_data(certifications, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from themoviedb import tmdb, schemas | ||
|
||
|
||
def test_collection_details(get_data, assert_data): | ||
data = get_data("collections/details") | ||
collection_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
collection = tmdb.TMDb().collection(collection_id).details() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/collection/{collection_id}", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(collection, schemas.Collection) | ||
assert assert_data(collection, data) | ||
|
||
|
||
def test_collection_images(get_data, assert_data): | ||
data = get_data("collections/images") | ||
collection_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
images = tmdb.TMDb().collection(collection_id).images() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/collection/{collection_id}/images", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(images, schemas.Images) | ||
assert assert_data(images, data) | ||
|
||
|
||
def test_collection_translations(get_data, assert_data): | ||
data = get_data("collections/translations") | ||
collection_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
translations = tmdb.TMDb().collection(collection_id).translations() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/collection/{collection_id}/translations", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(translations, schemas.Translations) | ||
assert assert_data(translations, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from themoviedb import tmdb, schemas | ||
|
||
|
||
def test_company_details(get_data, assert_data): | ||
data = get_data("companies/details") | ||
company_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
company = tmdb.TMDb().company(company_id).details() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/company/{company_id}", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(company, schemas.Company) | ||
assert assert_data(company, data) | ||
|
||
|
||
def test_company_alternative_names(get_data, assert_data): | ||
data = get_data("companies/alternative_names") | ||
company_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
alternative_names = tmdb.TMDb().company(company_id).alternative_names() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/company/{company_id}/alternative_names", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(alternative_names, schemas.AlternativeNames) | ||
assert assert_data(alternative_names, data) | ||
|
||
|
||
def test_company_images(get_data, assert_data): | ||
data = get_data("companies/images") | ||
company_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
images = tmdb.TMDb().company(company_id).images() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/company/{company_id}/images", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(images, schemas.Images) | ||
assert assert_data(images, data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from themoviedb import tmdb, schemas | ||
|
||
|
||
def test_credit_details(get_data, assert_data): | ||
data = get_data("credits/details") | ||
credit_id = 123 | ||
|
||
with patch("themoviedb.routes_sync._base.Session.request") as mocked: | ||
mocked.return_value.__enter__.return_value.json.return_value = data | ||
credit = tmdb.TMDb().credit(credit_id).details() | ||
mocked.assert_called_with( | ||
"GET", | ||
f"https://api.themoviedb.org/3/credit/{credit_id}", | ||
params={ | ||
"api_key": "TEST_TMDB_KEY", | ||
"language": "en-US", | ||
"region": "US", | ||
"watch_region": "US", | ||
}, | ||
) | ||
|
||
assert isinstance(credit, schemas.Credit) | ||
assert assert_data(credit, data) |
Oops, something went wrong.