Mercurial > libervia-backend
comparison tests/unit/test_ap-gateway.py @ 3735:04ecc8eeb81a
tests (ap-gateway): fix use of outbox URL to get items
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 21 Mar 2022 16:37:19 +0100 |
parents | 6cc39a3b8c14 |
children | f31113777881 |
comparison
equal
deleted
inserted
replaced
3734:643622ff1492 | 3735:04ecc8eeb81a |
---|---|
405 """AP requests are converted to pubsub""" | 405 """AP requests are converted to pubsub""" |
406 monkeypatch.setattr(plugin_comp_ap_gateway.treq, "get", mock_ap_get) | 406 monkeypatch.setattr(plugin_comp_ap_gateway.treq, "get", mock_ap_get) |
407 monkeypatch.setattr(plugin_comp_ap_gateway.treq, "json_content", mock_treq_json) | 407 monkeypatch.setattr(plugin_comp_ap_gateway.treq, "json_content", mock_treq_json) |
408 monkeypatch.setattr(ap_gateway, "apGet", mock_ap_get) | 408 monkeypatch.setattr(ap_gateway, "apGet", mock_ap_get) |
409 | 409 |
410 items, rsm_resp = await ap_gateway.getAPItems(TEST_AP_ACCOUNT, 2) | 410 actor_data = await ap_gateway.getAPActorDataFromId(TEST_AP_ACCOUNT) |
411 outbox = await ap_gateway.apGetObject(actor_data, "outbox") | |
412 items, rsm_resp = await ap_gateway.getAPItems(outbox, 2) | |
411 | 413 |
412 assert rsm_resp.count == 4 | 414 assert rsm_resp.count == 4 |
413 assert rsm_resp.index == 0 | 415 assert rsm_resp.index == 0 |
414 assert rsm_resp.first == "https://example.org/users/test_user/statuses/4" | 416 assert rsm_resp.first == "https://example.org/users/test_user/statuses/4" |
415 assert rsm_resp.last == "https://example.org/users/test_user/statuses/3" | 417 assert rsm_resp.last == "https://example.org/users/test_user/statuses/3" |
435 ) | 437 ) |
436 assert author_uri == "xmpp:test_user\\40example.org@ap.test.example" | 438 assert author_uri == "xmpp:test_user\\40example.org@ap.test.example" |
437 assert str(items[1].entry.published) == "2021-12-16T17:26:03Z" | 439 assert str(items[1].entry.published) == "2021-12-16T17:26:03Z" |
438 | 440 |
439 items, rsm_resp = await ap_gateway.getAPItems( | 441 items, rsm_resp = await ap_gateway.getAPItems( |
440 TEST_AP_ACCOUNT, | 442 outbox, |
441 max_items=2, | 443 max_items=2, |
442 after_id="https://example.org/users/test_user/statuses/3", | 444 after_id="https://example.org/users/test_user/statuses/3", |
443 ) | 445 ) |
444 | 446 |
445 assert rsm_resp.count == 4 | 447 assert rsm_resp.count == 4 |
468 ) | 470 ) |
469 assert author_uri == "xmpp:test_user\\40example.org@ap.test.example" | 471 assert author_uri == "xmpp:test_user\\40example.org@ap.test.example" |
470 assert str(items[1].entry.published) == "2021-12-16T17:28:03Z" | 472 assert str(items[1].entry.published) == "2021-12-16T17:28:03Z" |
471 | 473 |
472 items, rsm_resp = await ap_gateway.getAPItems( | 474 items, rsm_resp = await ap_gateway.getAPItems( |
473 TEST_AP_ACCOUNT, | 475 outbox, |
474 max_items=1, | 476 max_items=1, |
475 start_index=2 | 477 start_index=2 |
476 ) | 478 ) |
477 | 479 |
478 assert rsm_resp.count == 4 | 480 assert rsm_resp.count == 4 |
487 "</title>" | 489 "</title>" |
488 ) | 490 ) |
489 assert str(items[0].entry.published) == "2021-12-16T17:27:03Z" | 491 assert str(items[0].entry.published) == "2021-12-16T17:27:03Z" |
490 | 492 |
491 items, rsm_resp = await ap_gateway.getAPItems( | 493 items, rsm_resp = await ap_gateway.getAPItems( |
492 TEST_AP_ACCOUNT, | 494 outbox, |
493 max_items=3, | 495 max_items=3, |
494 chronological_pagination=False | 496 chronological_pagination=False |
495 ) | 497 ) |
496 assert rsm_resp.count == 4 | 498 assert rsm_resp.count == 4 |
497 assert rsm_resp.index == 1 | 499 assert rsm_resp.index == 1 |