(
mock_get,
mock_post,
bluesky_url,
good_media_response,
good_message_response,
)
| 596 | @patch("requests.post") |
| 597 | @patch("requests.get") |
| 598 | def test_plugin_bluesky_attachments_upload_fails( |
| 599 | mock_get, |
| 600 | mock_post, |
| 601 | bluesky_url, |
| 602 | good_media_response, |
| 603 | good_message_response, |
| 604 | ): |
| 605 | |
| 606 | # Test case where upload fails. |
| 607 | mock_get.return_value = good_message_response |
| 608 | mock_post.side_effect = [good_message_response, OSError] |
| 609 | |
| 610 | # Create application objects. |
| 611 | obj = Apprise.instantiate(bluesky_url) |
| 612 | attach = AppriseAttachment(os.path.join(TEST_VAR_DIR, "apprise-test.gif")) |
| 613 | |
| 614 | # Send our notification; it will fail because of the message response. |
| 615 | assert ( |
| 616 | obj.notify( |
| 617 | body="body", |
| 618 | title="title", |
| 619 | notify_type=NotifyType.INFO, |
| 620 | attach=attach, |
| 621 | ) |
| 622 | is False |
| 623 | ) |
| 624 | |
| 625 | # Verify API calls. |
| 626 | assert mock_get.call_count == 2 |
| 627 | assert ( |
| 628 | mock_get.call_args_list[0][0][0] |
| 629 | == "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle" |
| 630 | ) |
| 631 | assert ( |
| 632 | mock_get.call_args_list[1][0][0] |
| 633 | == "https://plc.directory/did:plc:1234" |
| 634 | ) |
| 635 | |
| 636 | assert mock_post.call_count == 2 |
| 637 | assert ( |
| 638 | mock_post.call_args_list[0][0][0] |
| 639 | == "https://example.pds.io/xrpc/com.atproto.server.createSession" |
| 640 | ) |
| 641 | assert ( |
| 642 | mock_post.call_args_list[1][0][0] |
| 643 | == "https://example.pds.io/xrpc/com.atproto.repo.uploadBlob" |
| 644 | ) |
| 645 | |
| 646 | |
| 647 | @patch("requests.post") |
nothing calls this directly
no test coverage detected
searching dependent graphs…