File: test_batch_delete_by_subject.py

package info (click to toggle)
python-globus-sdk 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,172 kB
  • sloc: python: 35,227; sh: 44; makefile: 35
file content (67 lines) | stat: -rw-r--r-- 1,899 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import json

from globus_sdk.testing import get_last_request, load_response


def test_batch_delete_by_subject(client):
    meta = load_response(client.batch_delete_by_subject).metadata
    input_subjects = [
        "very-cool-document",
        "less-cool-document",
        "document-wearing-sunglasses",
    ]

    res = client.batch_delete_by_subject(meta["index_id"], subjects=input_subjects)
    assert res.http_status == 200

    assert res["task_id"] == meta["task_id"]

    req = get_last_request()
    sent_data = json.loads(req.body)
    assert sent_data == {"subjects": input_subjects}


def test_batch_delete_by_subject_accepts_string(client):
    """
    Test the handling for a single string.

    We want to ensure that
        subjects="mydoc"
    parses the same as
        subjects=["mydoc"]
    *not* as
        subjects=["m", "y", "d", "o", "c"]
    """
    meta = load_response(client.batch_delete_by_subject).metadata
    input_subject = "very-cool-document"

    res = client.batch_delete_by_subject(meta["index_id"], subjects=input_subject)
    assert res.http_status == 200

    assert res["task_id"] == meta["task_id"]

    req = get_last_request()
    sent_data = json.loads(req.body)
    assert sent_data == {"subjects": [input_subject]}


def test_batch_delete_by_subject_allows_additional_params(client):
    meta = load_response(client.batch_delete_by_subject).metadata
    input_subjects = [
        "very-cool-document",
        "less-cool-document",
        "document-wearing-sunglasses",
    ]

    res = client.batch_delete_by_subject(
        meta["index_id"],
        subjects=input_subjects,
        additional_params={"foo": "snork"},
    )
    assert res.http_status == 200

    assert res["task_id"] == meta["task_id"]

    req = get_last_request()
    sent_data = json.loads(req.body)
    assert sent_data == {"subjects": input_subjects, "foo": "snork"}