-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates an update view and generation of a request action key
- Loading branch information
1 parent
68163af
commit 90d198f
Showing
9 changed files
with
116 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.core.urlresolvers import reverse | ||
from django.test import TestCase | ||
from django.utils import timezone | ||
|
||
from model_mommy import mommy | ||
|
||
from meupet.models import Pet | ||
|
||
|
||
class UpdateRegisterViewTest(TestCase): | ||
def setUp(self): | ||
stale_date = timezone.now() - timezone.timedelta(days=90) | ||
self.pet = mommy.make(Pet, request_sent=stale_date, active=False, request_key='abc') | ||
|
||
def test_redirect_to_pet(self): | ||
"""Redirect to the detail view after updating the registration""" | ||
resp = self.client.get(reverse('meupet:update_register', args=[self.pet.request_key])) | ||
|
||
self.assertRedirects(resp, reverse('meupet:detail', args=[self.pet.slug])) | ||
|
||
def test_not_found(self): | ||
"""Shows 404 if pet not found with given request_key""" | ||
resp = self.client.get(reverse('meupet:update_register', args=['cba']), follow=True) | ||
|
||
self.assertEqual(404, resp.status_code) | ||
|
||
def test_update_pet_registration(self): | ||
"""Should set the registration as active""" | ||
self.client.get(reverse('meupet:update_register', args=[self.pet.request_key])) | ||
|
||
self.pet.refresh_from_db() | ||
|
||
self.assertTrue(self.pet.active) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters