This post is 18 months old and a lot has changed since then. I would probably advocate now using infrastructure as code to build a test environment, and then test within that. But for testing a function prior to that, unit testing and mocking is still appropriate. However, things change, so mocking will never be a complete answer whatever happens.