()
| 68 | |
| 69 | |
| 70 | def create_pat(): |
| 71 | session_token, user_id = login() |
| 72 | os.environ["CLARIFAI_USER_ID"] = user_id |
| 73 | |
| 74 | url = "/users/%s/keys" % user_id |
| 75 | payload = { |
| 76 | "keys": [ |
| 77 | { |
| 78 | "description": "Auto-created in a CI test run", |
| 79 | "scopes": ["All"], |
| 80 | "type": "personal_access_token", |
| 81 | "apps": [], |
| 82 | } |
| 83 | ] |
| 84 | } |
| 85 | data = _request(method="POST", url=url, payload=payload, headers=_auth_headers(session_token)) |
| 86 | _assert_response_success(data) |
| 87 | |
| 88 | assert "keys" in data, f"Invalid response {data}" |
| 89 | assert len(data["keys"]) == 1, f"Invalid response {data}" |
| 90 | assert "id" in data["keys"][0], f"Invalid response {data}" |
| 91 | pat_id = data["keys"][0]["id"] |
| 92 | assert pat_id, f"Invalid response {data}" |
| 93 | |
| 94 | # This print needs to be present so we can read the value in CI. |
| 95 | print(pat_id) |
| 96 | |
| 97 | |
| 98 | def run(arguments): |
no test coverage detected