-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge main into sweep/pre-commit-github-action
- Loading branch information
Showing
6 changed files
with
82 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import unittest | ||
import unittest.mock | ||
|
||
from sweepai import api | ||
|
||
|
||
class TestAPI(unittest.TestCase): | ||
def setUp(self): | ||
self.mock_api = unittest.mock.create_autospec(api) | ||
|
||
def test_webhook(self): | ||
self.mock_api.webhook.return_value = {"success": True} | ||
result = self.mock_api.webhook() | ||
self.assertEqual(result, {"success": True}) | ||
self.mock_api.webhook.assert_called_once() | ||
|
||
def test_home(self): | ||
self.mock_api.home.return_value = "<h2>Sweep Webhook is up and running! To get started, copy the URL into the GitHub App settings' webhook field.</h2>" | ||
result = self.mock_api.home() | ||
self.assertEqual(result, "<h2>Sweep Webhook is up and running! To get started, copy the URL into the GitHub App settings' webhook field.</h2>") | ||
self.mock_api.home.assert_called_once() | ||
|
||
# Add more test methods as needed for each function in api.py | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
import unittest.mock | ||
|
||
from sweepai.handlers import stack_pr | ||
|
||
|
||
class TestStackPR(unittest.TestCase): | ||
def setUp(self): | ||
self.mock_stack_pr = unittest.mock.create_autospec(stack_pr) | ||
|
||
def test_stack_pr(self): | ||
self.mock_stack_pr.stack_pr.return_value = {"success": True} | ||
result = self.mock_stack_pr.stack_pr( | ||
request="Add type hints to create_payment_messages in on_ticket.py.", | ||
pr_number=2646, | ||
username="kevinlu1248", | ||
repo_full_name="sweepai/sweep", | ||
installation_id=36855882, | ||
tracking_id="test_stack_pr", | ||
) | ||
self.assertEqual(result, {"success": True}) | ||
self.mock_stack_pr.stack_pr.assert_called_once_with( | ||
request="Add type hints to create_payment_messages in on_ticket.py.", | ||
pr_number=2646, | ||
username="kevinlu1248", | ||
repo_full_name="sweepai/sweep", | ||
installation_id=36855882, | ||
tracking_id="test_stack_pr", | ||
) | ||
|
||
# Add more test methods as needed for each function in stack_pr.py | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |