Completed
Pull Request — master (#97)
by Paolo
08:19 queued 06:36
created

AdminTestCase.test_orphansubmissionadmin()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 3
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 3
dl 3
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
"""
4
Created on Sat Jan 25 17:51:52 2020
5
6
@author: Paolo Cozzi <[email protected]>
7
"""
8
9
from django.test import Client, TestCase
10
from django.contrib.auth import get_user_model
11
from django.urls import reverse
12
13
from uid.tests.mixins import PersonMixinTestCase
14
15
16 View Code Duplication
class AdminTestCase(PersonMixinTestCase, TestCase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
17
    """With this module, I want to test custom admin classes. See:
18
19
    https://docs.djangoproject.com/en/2.2/ref/contrib/admin/#admin-reverse-urls
20
21
    to have a list of admin views
22
    """
23
24
    fixtures = [
25
        'biosample/account',
26
        'biosample/managedteam',
27
        'biosample/orphansubmission',
28
        'biosample/submission',
29
        'biosample/submissiondata',
30
        'uid/animal',
31
        'uid/dictbreed',
32
        'uid/dictcountry',
33
        'uid/dictrole',
34
        'uid/dictsex',
35
        'uid/dictspecie',
36
        'uid/dictstage',
37
        'uid/dictuberon',
38
        'uid/ontology',
39
        'uid/organization',
40
        'uid/publication',
41
        'uid/sample',
42
        'uid/speciesynonym',
43
        'uid/submission',
44
        'uid/user'
45
    ]
46
47
    @classmethod
48
    def setUpClass(cls):
49
        # calling my base class setup
50
        super().setUpClass()
51
52
        # create an admin user
53
        User = get_user_model()
54
        User.objects.create_superuser(
55
            username='admin',
56
            password='test',
57
            email='[email protected]')
58
59
    def setUp(self):
60
        self.client = Client()
61
        self.client.login(username='admin', password='test')
62
63
    def check_response(self, url):
64
        response = self.client.get(url)
65
        self.assertEqual(response.status_code, 200)
66
67
    def test_submissionadmin(self):
68
        url = reverse('admin:biosample_submission_changelist')
69
        self.check_response(url)
70
71
    def test_submissiondataadmin(self):
72
        url = reverse('admin:biosample_submissiondata_changelist')
73
        self.check_response(url)
74
75
    def test_orphansubmissionadmin(self):
76
        url = reverse('admin:biosample_orphansubmission_changelist')
77
        self.check_response(url)
78