1
|
|
|
from django.test import Client, TestCase |
2
|
|
|
from django.urls import resolve, reverse |
3
|
|
|
|
4
|
|
|
from common.tests import GeneralMixinTestCase, OwnerMixinTestCase |
5
|
|
|
|
6
|
|
|
from ..views import SubmissionValidationSummaryView |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class SubmissionValidationSummaryViewTest(TestCase): |
10
|
|
|
"""Test Submission DetailView""" |
11
|
|
|
fixtures = [ |
12
|
|
|
"image_app/user", |
13
|
|
|
"image_app/dictcountry", |
14
|
|
|
"image_app/dictrole", |
15
|
|
|
"image_app/organization", |
16
|
|
|
"image_app/submission" |
17
|
|
|
] |
18
|
|
|
|
19
|
|
|
def setUp(self): |
20
|
|
|
# login a test user (defined in fixture) |
21
|
|
|
self.client = Client() |
22
|
|
|
self.client.login(username='test', password='test') |
23
|
|
|
|
24
|
|
|
self.url_animals = reverse('submissions:validation_summary', kwargs={ |
25
|
|
|
'pk': 1, 'type': 'animals'}) |
26
|
|
|
self.url_samples = reverse('submissions:validation_summary', kwargs={ |
27
|
|
|
'pk': 1, 'type': 'samples'}) |
28
|
|
|
|
29
|
|
|
def test_url_resolves_view_for_animals(self): |
30
|
|
|
view = resolve('/submissions/1/validation_summary/animals/') |
31
|
|
|
self.assertIsInstance(view.func.view_class(), |
32
|
|
|
SubmissionValidationSummaryView) |
33
|
|
|
|
34
|
|
|
def test_url_resolves_view_for_samples(self): |
35
|
|
|
view = resolve('/submissions/1/validation_summary/samples/') |
36
|
|
|
self.assertIsInstance(view.func.view_class(), |
37
|
|
|
SubmissionValidationSummaryView) |
38
|
|
|
|
39
|
|
|
def test_new_not_found_status_code_for_animals(self): |
40
|
|
|
url = reverse('submissions:validation_summary', kwargs={ |
41
|
|
|
'pk': 99, 'type': 'animals'}) |
42
|
|
|
response = self.client.get(url) |
43
|
|
|
self.assertEqual(response.status_code, 404) |
44
|
|
|
|
45
|
|
|
def test_new_not_found_status_code_for_samples(self): |
46
|
|
|
url = reverse('submissions:validation_summary', kwargs={ |
47
|
|
|
'pk': 99, 'type': 'samples'}) |
48
|
|
|
response = self.client.get(url) |
49
|
|
|
self.assertEqual(response.status_code, 404) |
50
|
|
|
|