Retry GET Request when field value is different than expected [Python][Requests]

Viewed 16

I'm creating test framework for my API project in python

Shortly i have a function where I

  1. Create user via API
  2. Trigger update session for him
  3. Im sending GET request and looking if status is completed
  4. If its still in progress thet repeat the get request if not go further

In response i have flat json object and i just want to look in one field 'status' from point 3)

How you reccomend to do it ?

    def test_object():
            createdUser = user.create() //here im sending post request to create user
            returnedObject = object.get(createObject.id, createdUser.id)
            assert returnedObject== createdObject
            # assert returnedUpdate.status == 'success'
            validate_field('success', returnedObject.status)

How to validate this field in external function and if this is not correct then run only get request without 1 line on POST Create user ?

0 Answers
Related