Completed
Push — master ( 5644bc...b87258 )
by Paolo
17s queued 13s
created

submissions.tests.test_commands   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 30
dl 0
loc 53
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A CommandsTestCase.test_reset_submission() 0 19 2
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
"""
4
Created on Mon Jul  1 11:17:12 2019
5
6
@author: Paolo Cozzi <[email protected]>
7
"""
8
9
from django.core.management import call_command
10
from django.test import TestCase
11
12
from common.constants import LOADED
13
from image_app.models import Submission, Name
14
15
16
class CommandsTestCase(TestCase):
17
    fixtures = [
18
        'image_app/animal',
19
        'image_app/dictbreed',
20
        'image_app/dictcountry',
21
        'image_app/dictrole',
22
        'image_app/dictsex',
23
        'image_app/dictspecie',
24
        'image_app/dictstage',
25
        'image_app/dictuberon',
26
        'image_app/name',
27
        'image_app/organization',
28
        'image_app/publication',
29
        'image_app/sample',
30
        'image_app/submission',
31
        'image_app/user'
32
    ]
33
34
    def test_reset_submission(self):
35
        "Test biosample_submission command command."
36
37
        # mocking objects
38
        args = ["--submission", 1]
39
        opts = {}
40
        call_command('reset_submission', *args, **opts)
41
42
        # get submission
43
        submission_obj = Submission.objects.get(pk=1)
44
45
        # check submission.state changed
46
        self.assertEqual(submission_obj.status, LOADED)
47
48
        # check name status changed
49
        qs = Name.objects.filter(submission=submission_obj)
50
51
        for name in qs:
52
            self.assertEqual(name.status, LOADED)
53