lundi 29 août 2016

Unit testing telnet in python

I'm making a small app that sends commands to a switch. Main class communicates with the desired host via subclasses of an abstract class (interface).

One of such class implements (wraps around) telnet communication with telnetlib.

How can I unittest such class? Interface consists of

connect(host, credentials)
closeConnection()
sendCommand(command)
readOutput()

I think that mocking it would require writing a telnet server mock, which is complicated. Is there an easier way?

Aucun commentaire:

Enregistrer un commentaire