Completed
Push — master ( 8a2447...e2760f )
by Paolo
06:42
created

AdminTestCase.test_submissiondataadmin()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
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
class AdminTestCase(PersonMixinTestCase, TestCase):
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/submission',
28
        'biosample/submissiondata',
29
        'uid/animal',
30
        'uid/dictbreed',
31
        'uid/dictcountry',
32
        'uid/dictrole',
33
        'uid/dictsex',
34
        'uid/dictspecie',
35
        'uid/dictstage',
36
        'uid/dictuberon',
37
        'uid/ontology',
38
        'uid/organization',
39
        'uid/publication',
40
        'uid/sample',
41
        'uid/speciesynonym',
42
        'uid/submission',
43
        'uid/user'
44
    ]
45
46
    @classmethod
47
    def setUpClass(cls):
48
        # calling my base class setup
49
        super().setUpClass()
50
51
        # create an admin user
52
        User = get_user_model()
53
        User.objects.create_superuser(
54
            username='admin',
55
            password='test',
56
            email='[email protected]')
57
58
    def setUp(self):
59
        self.client = Client()
60
        self.client.login(username='admin', password='test')
61
62
    def check_response(self, url):
63
        response = self.client.get(url)
64
        self.assertEqual(response.status_code, 200)
65
66
    def test_submissionadmin(self):
67
        url = reverse('admin:biosample_submission_changelist')
68
        self.check_response(url)
69
70
    def test_submissiondataadmin(self):
71
        url = reverse('admin:biosample_submissiondata_changelist')
72
        self.check_response(url)
73