I want to access an object attribute variable in Robot Framework tests and then validate the values of these attributes.
I have the following Python class:
class TestingClass(object):
def __init__(self, client_id=None, redirect_uri=None, state=None):
self.client_id = client_id
self.uri = uri
self.state = state
def url_authorize(self):
self.oauthsession = OAuth2Session(client_id=self.client_id, uri=self.uri, state=self.state)
self.authorize_endpoint_url = self.oauthsession.authorization_url(
url="http://localhost:8080/authorize")[0]
return self.authorize_endpoint_url
def authorize(self):
request = requests.get("http://localhost:8080")
self.status_code = request.status_code
self.content = request.content
self.json = request.json
I want to be able to grab any one of the attributes created in the Authorize (authorize method) and validate it. So I want to do something like this:
* Variables
${CLIENT_ID} to
${URI} http://127.0.0.1:8080/callback
${STATE} random
* Settings
Documentation Tests Suite
Library Utilities.TestingClass ${CLIENT_ID} ${URI}
... ${STATE}
*Keywords
*Test Cases
Authorize Test 1
[Documentation] Test that the user is redirected to the authorize
... endpoint
... when accessing the OAuth Client
Url Authorize
Authorize
Should Be Equal As Integers Utilities.TestingClass.status_code 200
However this gives: Utilities.TestingClass.status_code != 200 which is no surprise to me.
How do I grab this attribute to compare it? Would I need to maybe return all the attributes made from the authroize() method in a list/dictionary/some sort of array and then access by indexing? Or is there a more straight forward way to do this with Robot Framework?