def test_body(self): # Test the first method defined in __init__ to see if it calls # _COLLECTION_RESOURCE okay - if it does, they should all since # they're all built the same way # We need to mock _COLLECTION_RESOURCE before we create the Fitbit object, # since the __init__ is going to set up references to it with mock.patch('fitbit.api.Fitbit._COLLECTION_RESOURCE') as coll_resource: coll_resource.return_value = 999 fb = Fitbit('x', 'y') retval = fb.body(date=1, user_id=2, data=3) args, kwargs = coll_resource.call_args self.assertEqual(('body',), args) self.assertEqual({'date': 1, 'user_id': 2, 'data': 3}, kwargs) self.assertEqual(999, retval)