Bluesky

 view release on metacpan or  search on metacpan

t/003_endpoints.t  view on Meta::CPAN

use v5.40;
use Test2::V0;
use blib;
use Bluesky;

# Mock At: canned responses for every endpoint exercised below.
my ( $last_get, $last_post );
my $mock_at = mock 'At' => (
    override => [
        did  => sub {'did:plc:mock-user'},
        host => sub {'https://bsky.social'},
        get  => sub ( $self, $method, $params = {} ) {
            $last_get = { method => $method, params => $params };
            if ( $method eq 'com.atproto.server.getServiceAuth' ) {
                return { token => 'mock-service-token' };
            }
            if ( $method eq 'app.bsky.feed.getListFeed' ) {
                return { feed => [ { post => { uri => 'at://did:plc:x/app.bsky.feed.post/1' } } ] };
            }
            if ( $method eq 'app.bsky.graph.getListBlocks' or $method eq 'app.bsky.graph.getListMutes' ) {
                return { lists => [ { uri => 'at://did:plc:x/app.bsky.graph.list/1' } ] };
            }
            if ( $method eq 'app.bsky.graph.getListsWithMembership' ) {
                return { listsWithMembership => [ { list => { uri => 'at://did:plc:x/app.bsky.graph.list/1' } } ] };
            }
            if ( $method eq 'app.bsky.graph.getStarterPacksWithMembership' ) {
                return { starterPacksWithMembership => [ { starterPack => { uri => 'at://did:plc:x/app.bsky.graph.starterpack/1' } } ] };
            }
            if ( $method eq 'app.bsky.graph.getSuggestedFollowsByActor' ) {
                return { suggestions => [ { handle => 'friend.bsky.social' } ] };
            }
            if ( $method eq 'app.bsky.graph.searchStarterPacks' ) {
                return { starterPacks => [ { uri => 'at://did:plc:x/app.bsky.graph.starterpack/1' } ] };
            }
            if ( $method eq 'app.bsky.notification.getPreferences' ) {
                return { preferences => { priority => 1 } };
            }
            if ( $method eq 'app.bsky.notification.putPreferencesV2' ) {
                return { preferences => { chat => { include => 'all' } } };
            }
            if ( $method eq 'app.bsky.notification.listActivitySubscriptions' ) {
                return { subscriptions => [ { handle => 'fan.bsky.social' } ] };
            }
            if ( $method eq 'app.bsky.draft.getDrafts' ) {
                return { drafts => [ { id => 'draft1' } ] };
            }
            if ( $method eq 'app.bsky.contact.getMatches' ) {
                return { matches => [ { handle => 'match.bsky.social' } ] };
            }
            if ( $method eq 'app.bsky.contact.getSyncStatus' ) {
                return { syncStatus => { matchesCount => 2 } };
            }
            if ( $method eq 'app.bsky.contact.importContacts' ) {
                return { matchesAndContactIndexes => [ { contactIndex => 0 } ] };
            }
            if ( $method eq 'app.bsky.contact.verifyPhone' ) {
                return { token => 'single-use-jwt' };
            }
            if ( $method eq 'app.bsky.ageassurance.getConfig' ) {
                return { regions => [] };
            }
            if ( $method eq 'app.bsky.ageassurance.getState' ) {
                return { state => { status => 'unknown', access => 'unknown' }, metadata => {} };
            }
            if ( $method eq 'com.atproto.label.queryLabels' ) {
                return { labels => [ { val => 'porn' } ] };



( run in 2.910 seconds using v1.01-cache-2.11-cpan-99fa8243a42 )