Beispiel #1
0
 def test_parse_mastodon_document__rc_version(self, mock_fetch):
     mock_fetch.return_value = MASTODON_ACTIVITY_DOC, 200, None
     result = parse_mastodon_document(json.loads(MASTODON_RC_DOC),
                                      'example.com')
     assert result == {
         'organization': {
             'account': 'https://mastodon.local/@Admin',
             'contact': '*****@*****.**',
             'name': 'Admin dude',
         },
         'host': 'example.com',
         'name': 'Mastodon',
         'open_signups': True,
         'protocols': ["ostatus", "activitypub"],
         'relay': False,
         'server_meta': {},
         'services': [],
         'platform': 'mastodon',
         'version': '2.4.1rc1',
         'features': {},
         'activity': {
             'users': {
                 'total': 159726,
                 'half_year': 90774,
                 'monthly': 27829,
                 'weekly': 8779,
             },
             'local_posts': 6059606,
             'local_comments': None,
         },
     }
Beispiel #2
0
def fetch_mastodon_document(host):
    doc, status_code, error = fetch_document(host=host, path='/api/v1/instance')
    if not doc:
        return
    try:
        doc = json.loads(doc)
    except json.JSONDecodeError:
        return
    return parse_mastodon_document(doc, host)
Beispiel #3
0
 def test_calls_nodeinfo_fetcher_if_pleroma(self, mock_fetch):
     parse_mastodon_document(json.loads(PLEROMA_MASTODON_API_DOC),
                             'example.com')
     mock_fetch.assert_called_once_with('example.com')