def test_returns_none_on_xrd_parse_exception(self, mock_parse, mock_retrieve, mock_fetch): mock_retrieve.return_value = DiasporaHostMeta( webfinger_host="https://localhost" ).xrd document = retrieve_diaspora_webfinger("bob@localhost") mock_parse.assert_called_once_with("document") assert document == None
def test_returns_none_on_fetch_document_exception(self, mock_retrieve, mock_fetch): mock_retrieve.return_value = DiasporaHostMeta( webfinger_host="https://localhost" ).xrd mock_fetch.return_value = None, None, ValueError() document = retrieve_diaspora_webfinger("bob@localhost") mock_fetch.assert_called_with("https://localhost/webfinger?q=%s" % quote("bob@localhost")) assert document == None
def test_retrieve_fetch_document_is_called(self, mock_retrieve, mock_fetch, mock_xrd): mock_retrieve.return_value = DiasporaHostMeta( webfinger_host="https://localhost" ).xrd mock_fetch.return_value = "document", None, None mock_xrd.return_value = "document" document = retrieve_diaspora_webfinger("bob@localhost") mock_fetch.assert_called_with("https://localhost/webfinger?q=%s" % quote("bob@localhost")) assert document == "document"
def test_fetch_document_is_called__to_fetch_xml_webfinger( self, mock_retrieve, mock_parse, mock_fetch, mock_xrd): mock_retrieve.return_value = DiasporaHostMeta( webfinger_host="https://localhost").xrd mock_xrd.return_value = "document" result = retrieve_and_parse_diaspora_webfinger("bob@localhost") calls = [ call( host="localhost", path="/.well-known/webfinger?resource=acct:bob%40localhost", ), call("https://localhost/webfinger?q=%s" % quote("bob@localhost")), ] assert calls == mock_fetch.call_args_list assert result == {'hcard_url': None}
def test_fetch_document_is_called__to_fetch_xml_webfinger( self, mock_try, mock_retrieve, mock_parse, mock_fetch, mock_xrd, ): mock_retrieve.return_value = DiasporaHostMeta( webfinger_host="https://localhost").xrd mock_xrd.return_value = "document" result = retrieve_and_parse_diaspora_webfinger("bob@localhost") mock_try.assert_called_once_with("bob@localhost") calls = [ call("https://localhost/webfinger?q=%s" % quote("bob@localhost")), ] assert calls == mock_fetch.call_args_list assert result == {'hcard_url': None}