|
1 | 1 | import json
|
2 |
| -import uuid |
3 |
| - |
4 |
| -import pytest |
5 | 2 |
|
6 | 3 | from tests.constants import GO_EP1_ID
|
7 | 4 |
|
8 | 5 |
|
9 |
| -@pytest.fixture |
10 |
| -def gen_bookmark_name(created_bookmark_names): |
11 |
| - def f(name=""): |
12 |
| - if name: |
13 |
| - name = name + "-" |
14 |
| - bmname = "{}{}".format(name, str(uuid.uuid1())) |
15 |
| - created_bookmark_names.append(bmname) |
16 |
| - return bmname |
17 |
| - |
18 |
| - return f |
19 |
| - |
20 |
| - |
21 |
| -@pytest.fixture |
22 |
| -def bookmark1(gen_bookmark_name, tc): |
23 |
| - bm1name = gen_bookmark_name(name="bm1") |
24 |
| - res = tc.create_bookmark( |
25 |
| - {"endpoint_id": GO_EP1_ID, "path": "/home/", "name": bm1name} |
26 |
| - ) |
27 |
| - bm1id = res["id"] |
28 |
| - return (bm1name, bm1id) |
29 |
| - |
30 |
| - |
31 |
| -@pytest.fixture |
32 |
| -def bm1name(bookmark1): |
33 |
| - return bookmark1[0] |
34 |
| - |
35 |
| - |
36 |
| -@pytest.fixture |
37 |
| -def bm1id(bookmark1): |
38 |
| - return bookmark1[1] |
39 |
| - |
40 |
| - |
41 |
| -def test_bookmark_create(gen_bookmark_name, run_line): |
| 6 | +def test_bookmark_create(run_line, load_api_fixtures): |
42 | 7 | """
|
43 | 8 | Runs bookmark create, confirms simple things about text and json output
|
44 | 9 | """
|
45 |
| - result = run_line( |
46 |
| - ("globus bookmark create " "{}:{} {}").format( |
47 |
| - GO_EP1_ID, "/share/", gen_bookmark_name(name="sharebm") |
48 |
| - ) |
49 |
| - ) |
50 |
| - assert "Bookmark ID: " in result.output |
| 10 | + data = load_api_fixtures("bookmark_operations.yaml") |
| 11 | + bookmark_id = data["metadata"]["bookmark_id"] |
| 12 | + result = run_line("globus bookmark create {}:/share/ sharebm".format(GO_EP1_ID)) |
| 13 | + assert "Bookmark ID: {}".format(bookmark_id) in result.output |
51 | 14 |
|
52 |
| - bm2name = gen_bookmark_name(name="share bookmark 2") |
| 15 | + # repeat, but with JSON output |
53 | 16 | json_output = json.loads(
|
54 | 17 | run_line(
|
55 |
| - ('globus bookmark create -F json {}:{} "{}"').format( |
56 |
| - GO_EP1_ID, "/share/dne/", bm2name |
57 |
| - ) |
| 18 | + "globus bookmark create -Fjson {}:/share/ sharebm".format(GO_EP1_ID) |
58 | 19 | ).output
|
59 | 20 | )
|
60 |
| - assert json_output["name"] == bm2name |
61 |
| - assert json_output["path"] == "/share/dne/" |
| 21 | + assert json_output["id"] == bookmark_id |
| 22 | + assert json_output["name"] == "sharebm" |
| 23 | + assert json_output["path"] == "/share/" |
62 | 24 | assert json_output["endpoint_id"] == GO_EP1_ID
|
63 | 25 |
|
64 | 26 |
|
65 |
| -def test_bookmark_show(gen_bookmark_name, bm1name, bm1id, run_line): |
| 27 | +def test_bookmark_show(run_line, load_api_fixtures): |
66 | 28 | """
|
67 | 29 | Runs bookmark show on bm1's name and id.
|
68 | 30 | Confirms both inputs work, and verbose output is as expected.
|
69 | 31 | """
|
| 32 | + data = load_api_fixtures("bookmark_operations.yaml") |
| 33 | + bookmark_id = data["metadata"]["bookmark_id"] |
| 34 | + bookmark_name = data["metadata"]["bookmark_name"] |
| 35 | + |
70 | 36 | # id
|
71 |
| - result = run_line('globus bookmark show "{}"'.format(bm1id)) |
72 |
| - assert "{}:/home/\n".format(GO_EP1_ID) == result.output |
| 37 | + result = run_line('globus bookmark show "{}"'.format(bookmark_id)) |
| 38 | + assert "{}:/share/\n".format(GO_EP1_ID) == result.output |
73 | 39 |
|
74 | 40 | # name
|
75 |
| - result = run_line('globus bookmark show "{}"'.format(bm1name)) |
76 |
| - assert "{}:/home/\n".format(GO_EP1_ID) == result.output |
| 41 | + result = run_line('globus bookmark show "{}"'.format(bookmark_name)) |
| 42 | + assert "{}:/share/\n".format(GO_EP1_ID) == result.output |
77 | 43 |
|
78 | 44 | # verbose
|
79 |
| - result = run_line("globus bookmark show -v {}".format(bm1id)) |
| 45 | + result = run_line("globus bookmark show -v {}".format(bookmark_id)) |
80 | 46 | assert "Endpoint ID: {}".format(GO_EP1_ID) in result.output
|
81 | 47 |
|
82 | 48 |
|
83 |
| -def test_bookmark_rename_by_id(gen_bookmark_name, run_line, bm1id): |
| 49 | +def test_bookmark_rename_by_id(run_line, load_api_fixtures): |
84 | 50 | """
|
85 |
| - Runs bookmark rename on bm1's id. Confirms can be shown by new name. |
| 51 | + Runs bookmark rename on bm1's id. |
86 | 52 | """
|
87 |
| - new_name = gen_bookmark_name(name="new_bm1") |
88 |
| - result = run_line('globus bookmark rename "{}" "{}"'.format(bm1id, new_name)) |
89 |
| - assert "Success" in result.output |
| 53 | + data = load_api_fixtures("bookmark_operations.yaml") |
| 54 | + bookmark_id = data["metadata"]["bookmark_id"] |
| 55 | + updated_bookmark_name = data["metadata"]["bookmark_name_after_update"] |
90 | 56 |
|
91 |
| - result = run_line('globus bookmark show -v "{}"'.format(new_name)) |
92 |
| - assert "ID: {}".format(bm1id) in result.output |
| 57 | + result = run_line( |
| 58 | + 'globus bookmark rename "{}" "{}"'.format(bookmark_id, updated_bookmark_name) |
| 59 | + ) |
| 60 | + assert "Success" in result.output |
93 | 61 |
|
94 | 62 |
|
95 |
| -def test_bookmark_rename_by_name(gen_bookmark_name, run_line, bm1name, bm1id): |
| 63 | +def test_bookmark_rename_by_name(run_line, load_api_fixtures): |
96 | 64 | """
|
97 | 65 | Runs bookmark rename on bm1's name. Confirms can be shown by new name.
|
98 | 66 | """
|
99 |
| - new_name = gen_bookmark_name(name="new_bm1") |
100 |
| - result = run_line('globus bookmark rename "{}" "{}"'.format(bm1name, new_name)) |
101 |
| - assert "Success" in result.output |
| 67 | + data = load_api_fixtures("bookmark_operations.yaml") |
| 68 | + bookmark_name = data["metadata"]["bookmark_name"] |
| 69 | + updated_bookmark_name = data["metadata"]["bookmark_name_after_update"] |
102 | 70 |
|
103 |
| - result = run_line('globus bookmark show -v "{}"'.format(new_name)) |
104 |
| - assert "ID: {}".format(bm1id) in result.output |
| 71 | + result = run_line( |
| 72 | + 'globus bookmark rename "{}" "{}"'.format(bookmark_name, updated_bookmark_name) |
| 73 | + ) |
| 74 | + assert "Success" in result.output |
105 | 75 |
|
106 | 76 |
|
107 |
| -def test_bookmark_delete_by_id(gen_bookmark_name, run_line, bm1id): |
| 77 | +def test_bookmark_delete_by_id(run_line, load_api_fixtures): |
108 | 78 | """
|
109 | 79 | Runs bookmark delete on bm1's id. Confirms success message.
|
110 | 80 | """
|
111 |
| - result = run_line('globus bookmark delete "{}"'.format(bm1id)) |
| 81 | + data = load_api_fixtures("bookmark_operations.yaml") |
| 82 | + bookmark_id = data["metadata"]["bookmark_id"] |
| 83 | + result = run_line('globus bookmark delete "{}"'.format(bookmark_id)) |
112 | 84 | assert "deleted successfully" in result.output
|
113 | 85 |
|
114 | 86 |
|
115 |
| -def test_bookmark_delete_by_name(gen_bookmark_name, run_line, bm1name): |
| 87 | +def test_bookmark_delete_by_name(run_line, load_api_fixtures): |
116 | 88 | """
|
117 | 89 | Runs bookmark delete on bm1's name. Confirms success message.
|
118 | 90 | """
|
119 |
| - result = run_line('globus bookmark delete "{}"'.format(bm1name)) |
| 91 | + data = load_api_fixtures("bookmark_operations.yaml") |
| 92 | + bookmark_name = data["metadata"]["bookmark_name"] |
| 93 | + result = run_line('globus bookmark delete "{}"'.format(bookmark_name)) |
120 | 94 | assert "deleted successfully" in result.output
|
0 commit comments