That's my first attempt to use mock in order to mock a db and cannot understand how it works.
My main file :
def _test( db ) :
res = {}
for x in db.getData() :
res[ x['id'] ] = x['name']
return res
and this is my test :
def test_small() :
mock_db = mock.Mock()
mock_db.getData.return_value = [{ u'name':u'Nick',u'id':1234}]
_test( mock_db )
assert mock_db.getData.assert_called_once()
Assert fails though. Error is :
assert None
E + where None = <bound method Mock.assert_called_once of <Mock name='mock.getData' id='140103447969552'>>()
E + where <bound method Mock.assert_called_once of <Mock name='mock.getData' id='140103447969552'>> = <Mock name='mock.getData' id='140103447969552'>.assert_called_once
E + where <Mock name='mock.getData' id='140103447969552'> = <Mock id='140103462485712'>.getData
Can someone explain me what am I missing? ideally I want to put some asserts later on - that result of _test is the return value of my mock.