mercredi 1 mai 2019

Generate Strings [Name] and Number[ID] for Adding to a Collection

Requirements:
The total number of categories in the system does not exceed 100.
A category’s name is unique across all existing categories in the system.

In my test, I am thinking of executing a POST up to 101 record, and expect to fail on the 
101th attempt.

Seeking: Is there a built-in in Python that will allow for generation of unique names and ids? Any code snippet/implementation would be helpful.

So here's the psuedocode.

While length of collection is <= 101:
  randomly generate [unique name] and [id] # This is to be passed to 
  PAYLOAD before POST
  PAYLOAD = {'id': ID, 'name': Name}
  response = requests.post(url=API_ENDPOINT, data=json.dumps(PAYLOAD), 
  headers=HEADERS)




Aucun commentaire:

Enregistrer un commentaire