Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KTruong008/2925c549bc6c137435aa9cf00bf06c1b to your computer and use it in GitHub Desktop.
Save KTruong008/2925c549bc6c137435aa9cf00bf06c1b to your computer and use it in GitHub Desktop.
def test_post_hand_with_deck(self):
deck1 = Deck(name=’deck1', user=self.user)
post_data = {
‘name’: ‘hand1’,
‘deck’: {
‘id’: deck1.pk
}
}
request = self.request_factory.post(reverse(‘goals:hand-list’), post_data, format=’json’)
force_authenticate(request, user=self.user)
view = HandList.as_view()
response = view(request)
response.render()
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertTrue(Hand.objects.all().count() == 1)
self.assertTrue(Hand.objects.get(name=’hand1').deck.name == ‘deck1’)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment