Unit tests focus on a single part of a whole application in total isolation, usually, a single class or function.
Integration testing is to test how parts of the application work together as a whole.
While a unit test may be used to ensure that the homepage produces an HTTP status code of 200, an integration test may be used to simulate a user’s whole registration process.
I generally use unit tests to check status codes:
w = self.create_whatever()
url = reverse("whatever.views.whatever")
resp = self.client.get(url)
I fetch the URL from the client, store the results in the variable resp and then test the assertions. First, test whether the response code is 200, and then test the actual response.
I can also use Selenium to make sure something fails which would be an example of integration testing.
pip install selenium
If a user needs to be logged in to create a new object, the test would succeed if it actually fails to create the object.
from selenium import webdriver
self.driver = webdriver.Firefox()
if __name__ == '__main__':