def test_calls_fetch_document(self, mock_get, mock_fetch): retrieve_and_parse_content(id="eggs", guid="eggs", handle="*****@*****.**", entity_type="spam") mock_fetch.assert_called_once_with( "https://example.com/fetch/spam/eggs")
def test_calls_get_fetch_content_endpoint(self, mock_get, mock_fetch): retrieve_and_parse_content("diaspora://[email protected]/spam/eggs") mock_get.assert_called_once_with("example.com", "spam", "eggs") mock_get.reset_mock() retrieve_and_parse_content( "diaspora://[email protected]/spam/eggs@spam") mock_get.assert_called_once_with("example.com", "spam", "eggs@spam")
def test_calls_get_fetch_content_endpoint(self, mock_get, mock_fetch): retrieve_and_parse_content(id="eggs", guid="eggs", handle="*****@*****.**", entity_type="spam") mock_get.assert_called_once_with("example.com", "spam", "eggs") mock_get.reset_mock() retrieve_and_parse_content(id="eggs", guid="eggs@spam", handle="*****@*****.**", entity_type="spam") mock_get.assert_called_once_with("example.com", "spam", "eggs@spam")
def test_calls_handle_receive(self, mock_handle, mock_get, mock_fetch): entity = retrieve_and_parse_content( id="eggs", guid="eggs", handle="*****@*****.**", entity_type="spam", sender_key_fetcher=sum, ) mock_handle.assert_called_once_with( RequestType(body=DIASPORA_PUBLIC_PAYLOAD), sender_key_fetcher=sum) assert entity == "entity"
def test_returns_on_404(self, mock_get, mock_fetch): result = retrieve_and_parse_content("diaspora://[email protected]/spam/eggs") assert not result
def test_raises_on_fetch_error(self, mock_get, mock_fetch): with pytest.raises(Exception): retrieve_and_parse_content("diaspora://[email protected]/spam/eggs")
def test_calls_handle_receive(self, mock_handle, mock_get, mock_fetch): entity = retrieve_and_parse_content("diaspora://[email protected]/spam/eggs", sender_key_fetcher=sum) mock_handle.assert_called_once_with(DIASPORA_PUBLIC_PAYLOAD, sender_key_fetcher=sum) assert entity == "entity"
def test_calls_fetch_document(self, mock_get, mock_fetch): retrieve_and_parse_content("diaspora://[email protected]/spam/eggs") mock_fetch.assert_called_once_with("https://example.com/fetch/spam/eggs")
def test_returns_on_404(self, mock_get, mock_fetch): result = retrieve_and_parse_content(id="eggs", guid="eggs", handle="*****@*****.**", entity_type="spam") assert not result
def test_raises_on_fetch_error(self, mock_get, mock_fetch): with pytest.raises(Exception): retrieve_and_parse_content(id="eggs", guid="eggs", handle="*****@*****.**", entity_type="spam")