File: test_search.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 (38 lines) | stat: -rw-r--r-- 1,423 bytes parent folder | download | duplicates (2)
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
33
34
35
36
37
38
import pytest
import vcr
import sys

@pytest.mark.vcr()
def test_search(api):    
    results = api.search_v2('mastodonpy_test')
    assert isinstance(results, dict)
    
    results = api.search('mastodonpy_test')
    assert isinstance(results, dict)

    results = api.search('mastodonpy_test', result_type="statuses")
    assert isinstance(results, dict)
    assert len(results["hashtags"]) == 0
    assert len(results["accounts"]) == 0

def test_search_pre_2_9_2(api):
    if sys.version_info > (3, 9): # 3.10 and up will not load the json data and regenerating it would require a 2.9.2 instance
        pytest.skip("Test skipped for 3.10 and up")
    else:
        api.mastodon_major = 2
        api.mastodon_minor = 9
        api.mastodon_patch = 1
        with vcr.use_cassette('test_search.yaml', cassette_library_dir='tests/cassettes_pre_2_9_2', record_mode='none'):    
            results = api.search_v1('mastodonpy_test')
            assert isinstance(results, dict)
            
            results = api.search_v2('mastodonpy_test')
            assert isinstance(results, dict)
            
            results = api.search('mastodonpy_test')
            assert isinstance(results, dict)

            results = api.search('mastodonpy_test', result_type="statuses")
            assert isinstance(results, dict)
            assert len(results["hashtags"]) == 0
            assert len(results["accounts"]) == 0