-
Notifications
You must be signed in to change notification settings - Fork 2
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
34591b2
commit 4921a4f
Showing
3 changed files
with
21 additions
and
3 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 +1,21 @@ | ||
|
||
import unittest | ||
from unittest.mock import patch | ||
from scrapegraphaiapisdk.credits import credits | ||
|
||
class TestCredits(unittest.TestCase): | ||
|
||
@patch('scrapegraphaiapisdk.credits.requests.get') | ||
def test_credits_success(self, mock_get): | ||
mock_get.return_value.status_code = 200 | ||
mock_get.return_value.text = '{"credits": 100}' | ||
response = credits("test_api_key") | ||
self.assertEqual(response, '{"credits": 100}') | ||
|
||
@patch('scrapegraphaiapisdk.credits.requests.get') | ||
def test_credits_http_error(self, mock_get): | ||
mock_get.side_effect = requests.exceptions.HTTPError | ||
response = credits("test_api_key") | ||
self.assertIn("HTTP error occurred", response) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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