Skip to content

Commit f02c9e6

Browse files
Add unit tests for add_app_flow_user_scope
1 parent edd3189 commit f02c9e6

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/unit/globus_app/test_client_integration.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ def test_timers_client_add_app_data_access_scope(app):
6464
assert expected in str_list
6565

6666

67+
def test_timers_client_add_app_flow_user_scope(app):
68+
client = globus_sdk.TimersClient(app=app)
69+
70+
flow_id = str(uuid.UUID(int=0))
71+
client.add_app_flow_user_scope(flow_id)
72+
str_list = [
73+
str(s) for s in app.scope_requirements[globus_sdk.TimersClient.resource_server]
74+
]
75+
76+
flow_client = globus_sdk.SpecificFlowClient(flow_id, app=app)
77+
expected = f"{globus_sdk.TimersClient.scopes.timer}[{flow_client.scopes.user}]" # noqa: E501
78+
assert expected in str_list
79+
80+
6781
def test_specific_flow_client_add_app_data_access_scope(app):
6882
flow_id = str(uuid.UUID(int=1))
6983
client = globus_sdk.SpecificFlowClient(flow_id, app=app)
@@ -91,6 +105,27 @@ def test_transfer_client_add_app_data_access_scope_chaining(app):
91105
assert expected_2 in str_list
92106

93107

108+
def test_timers_client_add_app_flow_user_scope_chaining(app):
109+
flow_id_1 = str(uuid.UUID(int=1))
110+
flow_id_2 = str(uuid.UUID(int=2))
111+
(
112+
globus_sdk.TimersClient(app=app)
113+
.add_app_flow_user_scope(flow_id_1)
114+
.add_app_flow_user_scope(flow_id_2)
115+
)
116+
117+
str_list = [
118+
str(s) for s in app.scope_requirements[globus_sdk.TimersClient.resource_server]
119+
]
120+
flow_client_1 = globus_sdk.SpecificFlowClient(flow_id_1, app=app)
121+
expected_1 = f"{globus_sdk.TimersClient.scopes.timer}[{flow_client_1.scopes.user}]" # noqa: E501
122+
flow_client_2 = globus_sdk.SpecificFlowClient(flow_id_2, app=app)
123+
expected_2 = f"{globus_sdk.TimersClient.scopes.timer}[{flow_client_2.scopes.user}]" # noqa: E501
124+
125+
assert expected_1 in str_list
126+
assert expected_2 in str_list
127+
128+
94129
def test_transfer_client_add_app_data_access_scope_in_iterable(app):
95130
collection_id_1 = str(uuid.UUID(int=1))
96131
collection_id_2 = str(uuid.UUID(int=2))
@@ -136,6 +171,23 @@ def test_timers_client_add_app_data_access_scope_in_iterable(app):
136171
assert (expected_2, True) in transfer_dependencies
137172

138173

174+
def test_timers_client_add_app_flow_user_scope_in_iterable(app):
175+
flow_id_1 = str(uuid.UUID(int=1))
176+
flow_id_2 = str(uuid.UUID(int=2))
177+
globus_sdk.TimersClient(app=app).add_app_flow_user_scope((flow_id_1, flow_id_2))
178+
179+
timer_dependencies = [
180+
scope_dep.scope_string
181+
for scope in app.scope_requirements[globus_sdk.TimersClient.resource_server]
182+
for scope_dep in scope.dependencies
183+
]
184+
flow_client_1 = globus_sdk.SpecificFlowClient(flow_id_1, app=app)
185+
flow_client_2 = globus_sdk.SpecificFlowClient(flow_id_2, app=app)
186+
187+
assert flow_client_1.scopes.user.scope_string in timer_dependencies
188+
assert flow_client_2.scopes.user.scope_string in timer_dependencies
189+
190+
139191
def test_transfer_client_add_app_data_access_scope_catches_bad_uuid(app):
140192
with pytest.raises(ValueError, match="'collection_ids' must be a valid UUID"):
141193
globus_sdk.TransferClient(app=app).add_app_data_access_scope("foo")
@@ -154,6 +206,11 @@ def test_timers_client_add_app_data_access_scope_catches_bad_uuid(app):
154206
globus_sdk.TimersClient(app=app).add_app_transfer_data_access_scope("foo")
155207

156208

209+
def test_timers_client_add_app_flow_user_scope_catches_bad_uuid(app):
210+
with pytest.raises(ValueError, match="'flow_ids' must be a valid UUID"):
211+
globus_sdk.TimersClient(app=app).add_app_flow_user_scope("foo")
212+
213+
157214
def test_timers_client_add_app_data_access_scope_catches_bad_uuid_in_iterable(app):
158215
collection_id_1 = str(uuid.UUID(int=1))
159216
with pytest.raises(ValueError, match=r"'collection_ids\[1\]' must be a valid UUID"):
@@ -162,6 +219,12 @@ def test_timers_client_add_app_data_access_scope_catches_bad_uuid_in_iterable(ap
162219
)
163220

164221

222+
def test_timers_client_add_app_flow_user_scope_catches_bad_uuid_in_iterable(app):
223+
flow_id = str(uuid.UUID(int=1))
224+
with pytest.raises(ValueError, match=r"'flow_ids\[1\]' must be a valid UUID"):
225+
globus_sdk.TimersClient(app=app).add_app_flow_user_scope([flow_id, "foo"])
226+
227+
165228
def test_auth_client_default_scopes(app):
166229
globus_sdk.AuthClient(app=app)
167230

0 commit comments

Comments
 (0)