1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
# -*- coding: utf-8 -*- |
3
|
|
|
""" |
4
|
|
|
Created on Wed Sep 18 12:07:40 2019 |
5
|
|
|
|
6
|
|
|
@author: Paolo Cozzi <[email protected]> |
7
|
|
|
""" |
8
|
|
|
|
9
|
|
|
from django.test import Client, TestCase |
10
|
|
|
from django.urls import resolve, reverse |
11
|
|
|
|
12
|
|
|
from common.tests import GeneralMixinTestCase, OwnerMixinTestCase |
13
|
|
|
from validation.models import ValidationSummary |
14
|
|
|
|
15
|
|
|
from ..views import SubmissionValidationSummaryFixErrorsView |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
class SubmissionValidationSummaryFixErrorsViewTest( |
19
|
|
|
GeneralMixinTestCase, OwnerMixinTestCase, TestCase): |
20
|
|
|
"""Test SubmissionValidationSummaryViewTest View""" |
21
|
|
|
|
22
|
|
|
fixtures = [ |
23
|
|
|
"image_app/user", |
24
|
|
|
"image_app/dictcountry", |
25
|
|
|
"image_app/dictrole", |
26
|
|
|
"image_app/organization", |
27
|
|
|
"image_app/submission", |
28
|
|
|
"validation/validationsummary" |
29
|
|
|
] |
30
|
|
|
|
31
|
|
|
def setUp(self): |
32
|
|
|
# login a test user (defined in fixture) |
33
|
|
|
self.client = Client() |
34
|
|
|
self.client.login(username='test', password='test') |
35
|
|
|
|
36
|
|
|
self.url = reverse( |
37
|
|
|
'submissions:validation_summary_fix_errors', |
38
|
|
|
kwargs={ |
39
|
|
|
'pk': 1, |
40
|
|
|
'type': 'animal', |
41
|
|
|
'message_counter': 0}) |
42
|
|
|
|
43
|
|
|
self.response = self.client.get(self.url) |
44
|
|
|
|
45
|
|
|
def test_url_resolves_view(self): |
46
|
|
|
view = resolve('/submissions/1/validation_summary/animal/0/') |
47
|
|
|
self.assertIsInstance( |
48
|
|
|
view.func.view_class(), |
49
|
|
|
SubmissionValidationSummaryFixErrorsView) |
50
|
|
|
|
51
|
|
|
def test_view_not_found_status_code(self): |
52
|
|
|
url = reverse( |
53
|
|
|
'submissions:validation_summary_fix_errors', |
54
|
|
|
kwargs={ |
55
|
|
|
'pk': 99, |
56
|
|
|
'type': 'animal', |
57
|
|
|
'message_counter': 0}) |
58
|
|
|
response = self.client.get(url) |
59
|
|
|
self.assertEqual(response.status_code, 404) |
60
|
|
|
|