File: test_zzz_revoke.py

package info (click to toggle)
python-mastodon 2.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,836 kB
  • sloc: python: 9,438; makefile: 206; sql: 98; sh: 27
file content (32 lines) | stat: -rw-r--r-- 1,201 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest
from mastodon.Mastodon import MastodonIllegalArgumentError
from mastodon import Mastodon
import vcr

@pytest.mark.vcr()
def test_zzz_revoke(api_anonymous):
    # No password login after 4.4.0, so this can't be tested anymore against newer servers
    with vcr.use_cassette('test_zzz_revoke.yaml', cassette_library_dir='tests/cassettes_pre_4_4_0', record_mode='none'):
        # Named zzz_revoke to ensure it runs last,
        # as it revokes the access token for the other tests
        token = api_anonymous.log_in(
            username='mastodonpy_test_2@localhost',
            password='5fc638e0e53eafd9c4145b6bb852667d',
            allow_http=True
        )
        api_anonymous.revoke_access_token(allow_http=True)

        try:
            api_anonymous.toot("illegal access detected")
            assert False
        except Exception as e:
            print(e)
            pass

        api_revoked_token = Mastodon(access_token = token, api_base_url='http://localhost:3000')
        try:
            api_revoked_token.toot("illegal access detected")
            assert False
        except Exception as e:
            print(e)
            pass