aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/api_annotations.py
blob: 79acaa4b6dcf257f769fd0cead5537861d98c8f6 (plain)
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

from fatcat_openapi_client import *
from fixtures import *


def test_annotations(api):

    eg = quick_eg(api)

    # ensure no annotations on this object
    a = api.get_editgroup_annotations(eg.editgroup_id)
    assert a == []

    # create an annotation!
    api.create_editgroup_annotation(
        eg.editgroup_id,
        EditgroupAnnotation(
            comment_markdown="some *annotation*",
            extra=dict(thing="thang")))

    # check that we can fetch it all sorts of ways
    a = api.get_editgroup_annotations(eg.editgroup_id)
    assert len(a) == 1
    assert a[0].extra['thing'] == "thang"

    # the editor persists, so this is a hack to find a "recent" one
    a2 = api.get_editor_annotations(eg.editor_id, limit=100)
    found = None
    for thing in a2:
        if thing.annotation_id == a[0].annotation_id:
            found = thing
            break
    assert found
    assert found.extra['thing'] == "thang"