| 1 |
from responses import matchers |
| 2 |
|
| 3 |
from globus_sdk.testing.models import RegisteredResponse, ResponseSet |
| 4 |
|
| 5 |
VALIDATE_SIMPLE_FLOW_DEFINITION = { |
| 6 |
"Comment": "Simple flow", |
| 7 |
"StartAt": "Step1", |
| 8 |
"States": { |
| 9 |
"Step1": { |
| 10 |
"Type": "Action", |
| 11 |
"ActionUrl": "https://transfer.actions.globus.org/transfer", |
| 12 |
"Parameters": { |
| 13 |
"source_endpoint.$": "$.source_endpoint_id", |
| 14 |
"destination_endpoint.$": "$.destination_endpoint_id", |
| 15 |
"DATA": [ |
| 16 |
{ |
| 17 |
"source_path.$": "$.source_path", |
| 18 |
"destination_path.$": "$.destination_path", |
| 19 |
} |
| 20 |
], |
| 21 |
}, |
| 22 |
"ResultPath": "$.TransferResult", |
| 23 |
"End": True, |
| 24 |
} |
| 25 |
}, |
| 26 |
} |
| 27 |
|
| 28 |
VALIDATE_SIMPLE_SUCCESS_RESPONSE = { |
| 29 |
"scopes": {"User": ["urn:globus:auth:scope:transfer.api.globus.org:all"]} |
| 30 |
} |
| 31 |
|
| 32 |
VALIDATE_INVALID_FLOW_DEFINITION = { |
| 33 |
"Comment": "Simple flow", |
| 34 |
"StartAt": "Step1", |
| 35 |
"States": { |
| 36 |
"Step1": { |
| 37 |
"Type": "Action", |
| 38 |
"ActionUrl": "https://transfer.actions.globus.org/transfer", |
| 39 |
"Parameters": { |
| 40 |
"source_endpoint.$": "$.source_endpoint_id", |
| 41 |
"destination_endpoint.$": "$.destination_endpoint_id", |
| 42 |
"DATA": [ |
| 43 |
{ |
| 44 |
"source_path.$": "$.source_path", |
| 45 |
"destination_path.$": "$.destination_path", |
| 46 |
} |
| 47 |
], |
| 48 |
}, |
| 49 |
"ResultPath": "$.TransferResult", |
| 50 |
} |
| 51 |
}, |
| 52 |
} |
| 53 |
|
| 54 |
VALIDATE_INVALID_RESPONSE = { |
| 55 |
"error": { |
| 56 |
"code": "UNPROCESSABLE_ENTITY", |
| 57 |
"detail": [ |
| 58 |
{ |
| 59 |
"loc": ["definition", "States", "Step1"], |
| 60 |
"msg": ( |
| 61 |
"A state of type 'Action' must be defined as either terminal " |
| 62 |
'("End": true) or transitional ("Next": "NextStateId")' |
| 63 |
), |
| 64 |
"type": "value_error", |
| 65 |
} |
| 66 |
], |
| 67 |
"message": ( |
| 68 |
"1 validation error in body. $.definition.States.Step1: A state of " |
| 69 |
"type 'Action' must be defined as either terminal (\"End\": true) " |
| 70 |
'or transitional ("Next": "NextStateId")' |
| 71 |
), |
| 72 |
}, |
| 73 |
"debug_id": "41267e70-6788-4316-8b67-df7160166466", |
| 74 |
} |
| 75 |
|
| 76 |
_validate_simple_flow_request = { |
| 77 |
"definition": VALIDATE_SIMPLE_FLOW_DEFINITION, |
| 78 |
} |
| 79 |
|
| 80 |
_validate_invalid_flow_request = { |
| 81 |
"definition": VALIDATE_INVALID_FLOW_DEFINITION, |
| 82 |
} |
| 83 |
|
| 84 |
RESPONSES = ResponseSet( |
| 85 |
metadata={ |
| 86 |
"success": VALIDATE_SIMPLE_FLOW_DEFINITION, |
| 87 |
"invalid": VALIDATE_INVALID_FLOW_DEFINITION, |
| 88 |
}, |
| 89 |
default=RegisteredResponse( |
| 90 |
service="flows", |
| 91 |
path="/flows/validate", |
| 92 |
method="POST", |
| 93 |
status=200, |
| 94 |
json=VALIDATE_SIMPLE_SUCCESS_RESPONSE, |
| 95 |
match=[ |
| 96 |
matchers.json_params_matcher( |
| 97 |
params={"definition": VALIDATE_SIMPLE_FLOW_DEFINITION}, |
| 98 |
strict_match=False, |
| 99 |
) |
| 100 |
], |
| 101 |
), |
| 102 |
definition_error=RegisteredResponse( |
| 103 |
service="flows", |
| 104 |
path="/flows/validate", |
| 105 |
method="POST", |
| 106 |
status=422, |
| 107 |
json=VALIDATE_INVALID_RESPONSE, |
| 108 |
match=[ |
| 109 |
matchers.json_params_matcher( |
| 110 |
params={"definition": VALIDATE_INVALID_FLOW_DEFINITION}, |
| 111 |
strict_match=False, |
| 112 |
) |
| 113 |
], |
| 114 |
), |
| 115 |
) |