def test_zdesk_is_inited_correctly(self, mock_zendesk): conn_mock = mock.Mock() conn_mock.host = "conn_host" conn_mock.login = "******" conn_mock.password = "******" zendesk_hook = ZendeskHook("conn_id") zendesk_hook.get_connection = mock.Mock(return_value=conn_mock) zendesk_hook.get_conn() mock_zendesk.assert_called_with('https://conn_host', 'conn_login', 'conn_pass', True)
def test_returns_multiple_pages_if_get_all_pages_true(self, _): zendesk_hook = ZendeskHook("conn_id") mock_connection = mock.Mock() mock_connection.host = "some_host" zendesk_hook.get_connection = mock.Mock(return_value=mock_connection) zendesk_hook.get_conn() mock_conn = mock.Mock() mock_call = mock.Mock( return_value={'next_page': 'https://some_host/something', 'path': []}) mock_conn.call = mock_call zendesk_hook.get_conn = mock.Mock(return_value=mock_conn) zendesk_hook.call("path", get_all_pages=True) assert mock_call.call_count == 2
def test_returns_single_page_if_get_all_pages_false(self, _): zendesk_hook = ZendeskHook("conn_id") mock_connection = mock.Mock() mock_connection.host = "some_host" zendesk_hook.get_connection = mock.Mock(return_value=mock_connection) zendesk_hook.get_conn() mock_conn = mock.Mock() mock_call = mock.Mock( return_value={'next_page': 'https://some_host/something', 'path': []}) mock_conn.call = mock_call zendesk_hook.get_conn = mock.Mock(return_value=mock_conn) zendesk_hook.call("path", get_all_pages=False) mock_call.assert_called_once_with("path", None)
def test_zdesk_sideloading_works_correctly(self, mock_zendesk): zendesk_hook = ZendeskHook("conn_id") mock_connection = mock.Mock() mock_connection.host = "some_host" zendesk_hook.get_connection = mock.Mock(return_value=mock_connection) zendesk_hook.get_conn() mock_conn = mock.Mock() mock_call = mock.Mock( return_value={'next_page': 'https://some_host/something', 'tickets': [], 'users': [], 'groups': []}) mock_conn.call = mock_call zendesk_hook.get_conn = mock.Mock(return_value=mock_conn) results = zendesk_hook.call(".../tickets.json", query={"include": "users,groups"}, get_all_pages=False, side_loading=True) assert results == {'groups': [], 'users': [], 'tickets': []}