I want to test this class using python unittest framework and also mockito.
class ISightRequestEngine(object):
def __init__(self, pInputString=None):
self.__params = (pInputString)
def openHTTPConnection(self):
pass
def __closeHTTPConnection(self):
pass
def testFunc(self):
print 'test function called'
def startEngine(self):
self.__params.parseinputString()
self.openHTTPConnection()
self.testFunc()
def processRequest(self, header = None):
pass
I wanted to test that function startEngine() calls testFunc().
Similar to what we do in our mocked class,
obj = mock(ISightRequestEngine)
obj.startEngine()
try:
verify(obj).startEngine()
except VerificationError:
Unfortunately this only verifies whether the startEngine function is called or not, but it does not give the actual function call and I cannot verify that whether the call to testFunc() has been made or not.
Is there any way to test this scenario? I am new to testing world and framework.
Having similar such issue, where I am bit lost in writing the test case
I have to test this function. I have written test case something like this. I have tried to mock the UserAdapter class but I am not able to do so completely.
Here if you see I have mocked get_user_company_rate_limit() call from the testable function,
container = self.adapter.get_user_company_rate_limit()
but I am still not able to figure out the way in which I can mock this call,In your example you are testing your mock.
ISightRequestingEngine
startEngine()
method of that mockWhat you want to do is:
testFunc()
startEngine()
testFunc()
was calledI'm not familiar with mockito, but what from what I can make up from the documentation, I think you have to do something like the following: