I am building an application in python that uses a wrap to a library that performs hardware communication
I would like to create some test units and I am pretty new to unit tests, so I would like to mock the communications but I really don't know how to do it
quick example:
this is the application code using the comm lib
def changeValue(id, val):
current_value = comm.getval(id)
if (current_value != val):
comm.send(id, val)
I want to test this without performing communications, i.e. replacing the comm.getval return by some mocked value, and sending comm.send to a mocked comm class.
Can anyone give a hint on that?
The thing is that comm is a object inside a class
let's say the class is like this:
class myClass:
comm = Comm()
....
def __init__():
comm = comm.start()
def changeValue(id, val):
....
....