-
-
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.
- Loading branch information
1 parent
1a5521d
commit 18057d3
Showing
7 changed files
with
153 additions
and
20 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
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
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,15 @@ | ||
--- | ||
codecov: | ||
branch: master | ||
|
||
coverage: | ||
status: | ||
project: | ||
default: | ||
target: auto | ||
threshold: 10% | ||
|
||
comment: | ||
layout: "diff, flags, files" | ||
behavior: default | ||
require_changes: false # if true: only post the comment if coverage changes |
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,2 @@ | ||
pytest==8.3.3 | ||
pytest-cov==5.0.0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from unittest.mock import patch | ||
from action.main import facebook_post | ||
|
||
|
||
def test_facebook_post_success(): | ||
with patch('requests.post') as mock_post: | ||
mock_post.return_value.json.return_value = {} | ||
|
||
facebook_post( | ||
access_token='test_access_token', | ||
message='test_message', | ||
page_id='test_page_id', | ||
url='https://test.url', | ||
fail_on_error='true' | ||
) | ||
|
||
mock_post.assert_called_once_with( | ||
url='https://graph.facebook.com/test_page_id/feed', | ||
json={ | ||
'message': 'test_message', | ||
'access_token': 'test_access_token', | ||
'link': 'https://test.url' | ||
} | ||
) | ||
|
||
|
||
def test_facebook_post_error(): | ||
with patch('requests.post') as mock_post, patch('sys.exit') as mock_exit: | ||
mock_post.return_value.json.return_value = {'error': 'test_error'} | ||
|
||
facebook_post( | ||
access_token='test_access_token', | ||
message='test_message', | ||
page_id='test_page_id', | ||
url='https://test.url', | ||
fail_on_error='true' | ||
) | ||
|
||
mock_post.assert_called_once_with( | ||
url='https://graph.facebook.com/test_page_id/feed', | ||
json={ | ||
'message': 'test_message', | ||
'access_token': 'test_access_token', | ||
'link': 'https://test.url' | ||
} | ||
) | ||
mock_exit.assert_called_once_with(1) | ||
|
||
|
||
def test_facebook_post_error_no_fail(): | ||
with patch('requests.post') as mock_post, patch('sys.exit') as mock_exit: | ||
mock_post.return_value.json.return_value = {'error': 'test_error'} | ||
|
||
facebook_post( | ||
access_token='test_access_token', | ||
message='test_message', | ||
page_id='test_page_id', | ||
url='https://test.url', | ||
fail_on_error='false' | ||
) | ||
mock_post.assert_called_once_with( | ||
url='https://graph.facebook.com/test_page_id/feed', | ||
json={ | ||
'message': 'test_message', | ||
'access_token': 'test_access_token', | ||
'link': 'https://test.url' | ||
} | ||
) | ||
mock_exit.assert_not_called() |