def post_driver(l):
def id_generator(size = 6, chars = string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
data = {"startLocation":{"address":{"fullAddress":"\n, ","fullAddressInLine":", , ","line1":"10407 Water Hyacinth Dr","city":"Orlando","state":"FL","zip":"32825"},"latitude":28.52144,"longitude":-81.23301},"endLocation":{"address":{"fullAddress":"\n, ","fullAddressInLine":", , ","line1":"1434 N Alafaya Trail","city":"Orlando","state":"FL","zip":"32819"},"latitude":28.52144,"longitude":-81.23301},"user":{"firstName":"Test" + id_generator(),"lastName":"doe","Username":"","Password":"","userId":"","role":"","email":"zbaker@productivityapex.com","username":"Test" + id_generator() + "","newPassword":"test"},"vehicle":{"vehicleNumber":"" + id_generator(),"licensePlate":"3216549877","maxCapacity":200000,"maxCapacityUnits":"units","costPerMile":3500,"fixedCost":35000,"costPerHour":35,"odometer":0,"tags":[{"text":"vehicle"}],"constraintTags":[],"id":"59fcca46520a6e2bb4a397ed"},"earliestStartTimeDate":"Mon Nov 13 2017 07:00:00 GMT-0500 (Eastern Standard Time)","restBreakDurationDate":"Mon Nov 13 2017 01:00:00 GMT-0500 (Eastern Standard Time)","maximumWorkingHours":9,"maximumDrivingHours":8,"fixedCost":0,"costPerMile":0,"costPerHour":0,"restBreakWindows":[{"startTime":"2017-11-03T19:30:35.275Z","endTime":"2017-11-04T05:00:35.275Z"}],"color":"#1c7c11","tags":[{"text":"test"}],"driverNumber":"" + id_generator(),"phoneNumber":"7894651231","earliestStartTime":"07:00:00","restBreakDuration":"01:00:00","customFields":{}}
# json_str = json.dumps(data)
r = l.client.post('/api/v1/drivers', data=str(data))
# content = r.json()
# return content["id"]
I am currently having issues with posting the data variable and having it succeed in my locust file. I've done this with other locust files with similar formats, but it's failing every time on this particular request... can someone please help me?