jeudi 25 janvier 2018

Testing in python a part of a class method

here's my problem. I'm new to python testing (testing in general) and i'm working with Python 3.x and Django 2.0. I have a class which has the goal of starting a synchronization between two DBs. It has a method for the synch, and this method is composed in different parts:

  1. Send an HTTP Request to the other server (it tries to send the request for a certain amount of attempts, then it stops);
  2. Check the result (response received or number attempts exceeded);
  3. Check the Response (Status code, format, response content (It's a JSON), ...)

After that, it starts again doing this, while there's nothing to synchronize.

Now, i need to test this different parts separately, but i don't know how because, as i said, this ops are all in the same method.

I thought a solution would be separate this operation in different "sub" methods (only for testing purpose) or execute those parts of code in different tests. Is there a better solution?

Aucun commentaire:

Enregistrer un commentaire