Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created January 14, 2022 20:44
Show Gist options
  • Save guilhermecarvalhocarneiro/d7638be0d575153ef63a98ac2eddb1f8 to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/d7638be0d575153ef63a98ac2eddb1f8 to your computer and use it in GitHub Desktop.
def test_orgao_list_queryset(self, init, client):
username = "user1"
password = "bar"
user = User.objects.create_user(username=username, password=password)
# Use this:
client.force_login(user)
# Or this:
client.login(username=username, password=password)
request = self.factory.get(reverse('orgao:orgao-list'))
request.user = user
response = OrgaoListView.as_view()(request)
assert response.status_code == 200
assert response.context_data['object_list'].count() == 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment