Method sending server connection

When you test, think about network failures, how do you account for those?
How do you make sure the function you wrote is sending the right request? Perhaps in the future someone modifies it, tests are a way to make sure you don't break the functionality.
How do you test that if the right response is received then you are able to parse it correctly?