-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finished tree tests and deleted trash
- Loading branch information
Showing
15 changed files
with
67 additions
and
121 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
Binary file not shown.
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
youtube_discussion_tree_api/.idea/inspectionProfiles/Project_Default.xml
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
youtube_discussion_tree_api/.idea/inspectionProfiles/profiles_settings.xml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
youtube_discussion_tree_api/.idea/youtube_discussion_tree_api.iml
This file was deleted.
Oops, something went wrong.
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
Empty file.
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
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,75 +1,74 @@ | ||
from youtube_discussion_tree_api._http import _get_list_search_videos, _get_video_comments, _get_video_transcription, _get_video_info | ||
from unittest import TestCase | ||
import os | ||
from youtube_discussion_tree_api.utils import QuotaController | ||
import pickle | ||
from youtube_discussion_tree_api.utils import QuotaInfo | ||
from youtube_discussion_tree_api._quota import QuotaManager | ||
|
||
class TestHttpMethods(TestCase): | ||
|
||
def setUp(self): | ||
self.API_KEY = os.getenv("API_KEY") | ||
self.quota_controller = QuotaController("apikey", 0, "12-12-2012") | ||
with open(".quota.pickle", "wb") as f: | ||
pickle.dump(self.quota_controller, f) | ||
self.quota_controller = QuotaInfo("apikey", 0, "12-12-2012") | ||
self.quota_manger = QuotaManager("./youtube_discussion_tree_api/tests/.quota.pickle") | ||
|
||
def test_get_video_comments(self): | ||
result = _get_video_comments("9GHmfg54gg8", self.API_KEY) | ||
result = _get_video_comments("9GHmfg54gg8", self.API_KEY, self.quota_manger) | ||
self.assertIn("kind", result) | ||
self.assertEqual("youtube#commentThreadListResponse", result["kind"]) | ||
|
||
def test_get_video_comments_bad_api_key(self): | ||
result = _get_video_comments("9GHmfg54gg8", "Google, Explode") | ||
result = _get_video_comments("9GHmfg54gg8", "Google, Explode", self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(400, result["error"]["code"]) | ||
|
||
def test_get_video_comments_no_api_key(self): | ||
result = _get_video_comments("9GHmfg54gg8", "") | ||
result = _get_video_comments("9GHmfg54gg8", "", self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(403, result["error"]["code"]) | ||
|
||
def test_get_video_comments_unexisting_video(self): | ||
result = _get_video_comments("Google, Explode", self.API_KEY) | ||
result = _get_video_comments("Google, Explode", self.API_KEY, self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(404, result["error"]["code"]) | ||
|
||
def test_get_video_info(self): | ||
result = _get_video_info("9GHmfg54gg8", self.API_KEY) | ||
result = _get_video_info("9GHmfg54gg8", self.API_KEY, self.quota_manger) | ||
self.assertIn("kind", result) | ||
self.assertEqual("youtube#videoListResponse", result["kind"]) | ||
|
||
def test_get_video_info_bad_api_key(self): | ||
result = _get_video_info("9GHmfg54gg8", "Google, Explode") | ||
result = _get_video_info("9GHmfg54gg8", "Google, Explode", self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(400, result["error"]["code"]) | ||
|
||
def test_get_video_info_no_api_key(self): | ||
result = _get_video_info("9GHmfg54gg8", "") | ||
result = _get_video_info("9GHmfg54gg8", "", self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(403, result["error"]["code"]) | ||
|
||
def test_get_video_info_unexisting_video(self): | ||
result = _get_video_info("Google, Explode", self.API_KEY) | ||
result = _get_video_info("Google, Explode", self.API_KEY, self.quota_manger) | ||
self.assertIn("kind", result) | ||
self.assertEqual("youtube#videoListResponse", result["kind"]) | ||
self.assertEqual(0, len(result["items"])) | ||
|
||
def test_get_list_search_videos(self): | ||
result = _get_list_search_videos("Functional Programming", 30, self.API_KEY) | ||
result = _get_list_search_videos("Functional Programming", 30, self.API_KEY, self.quota_manger) | ||
self.assertIn("kind", result) | ||
self.assertEqual("youtube#searchListResponse", result["kind"]) | ||
self.assertEqual(30, len(result["items"])) | ||
|
||
def test_get_list_search_videos_bad_pk(self): | ||
result = _get_list_search_videos("Functional Programming", 30, "Google, Explode") | ||
result = _get_list_search_videos("Functional Programming", 30, "Google, Explode", self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(400, result["error"]["code"]) | ||
|
||
def test_get_list_search_videos_bad_pk(self): | ||
result = _get_list_search_videos("Functional Programming", 30, "") | ||
result = _get_list_search_videos("Functional Programming", 30, "", self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(403, result["error"]["code"]) | ||
|
||
def test_get_list_search_videos_bad_maxresults(self): | ||
result = _get_list_search_videos("Functional Programming", -1, self.API_KEY) | ||
result = _get_list_search_videos("Functional Programming", -1, self.API_KEY, self.quota_manger) | ||
self.assertIn("error", result) | ||
self.assertEqual(400, result["error"]["code"]) |
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