|
1
|
|
|
#!/usr/bin/env python3 |
|
2
|
|
|
# -*- coding: utf-8 -*- |
|
3
|
|
|
""" |
|
4
|
|
|
Created on Tue Sep 24 16:25:51 2019 |
|
5
|
|
|
|
|
6
|
|
|
@author: Paolo Cozzi <[email protected]> |
|
7
|
|
|
""" |
|
8
|
|
|
|
|
9
|
|
|
from unittest.mock import patch |
|
10
|
|
|
|
|
11
|
|
|
from django.core.management import call_command |
|
12
|
|
|
from django.test import TestCase |
|
13
|
|
|
|
|
14
|
|
|
from image_app.models import ( |
|
15
|
|
|
DictBreed, DictCountry, DictSpecie, DictUberon, DictDevelStage, |
|
16
|
|
|
DictPhysioStage) |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
class CommandsTestCase(TestCase): |
|
20
|
|
|
fixtures = [ |
|
21
|
|
|
'image_app/dictbreed', |
|
22
|
|
|
'image_app/dictcountry', |
|
23
|
|
|
'image_app/dictrole', |
|
24
|
|
|
'image_app/dictsex', |
|
25
|
|
|
'image_app/dictspecie', |
|
26
|
|
|
'image_app/dictstage', |
|
27
|
|
|
'image_app/dictuberon', |
|
28
|
|
|
] |
|
29
|
|
|
|
|
30
|
|
|
@classmethod |
|
31
|
|
|
def setUpClass(cls): |
|
32
|
|
|
"""Purging terms from database""" |
|
33
|
|
|
|
|
34
|
|
|
super().setUpClass() |
|
35
|
|
|
|
|
36
|
|
|
DictBreed.objects.update(mapped_breed_term=None) |
|
37
|
|
|
DictCountry.objects.update(term=None) |
|
38
|
|
|
DictSpecie.objects.update(term=None) |
|
39
|
|
|
DictUberon.objects.update(term=None) |
|
40
|
|
|
DictDevelStage.objects.update(term=None) |
|
41
|
|
|
DictPhysioStage.objects.update(term=None) |
|
42
|
|
|
|
|
43
|
|
|
@patch('zooma.helpers.annotate_breed') |
|
44
|
|
|
def test_annotate_breeds(self, my_func): |
|
45
|
|
|
"Test annotate_breeds command" |
|
46
|
|
|
|
|
47
|
|
|
# mocking objects |
|
48
|
|
|
args = [] |
|
49
|
|
|
opts = {} |
|
50
|
|
|
call_command('annotate_breeds', *args, **opts) |
|
51
|
|
|
|
|
52
|
|
|
self.assertTrue(my_func.called) |
|
53
|
|
|
|
|
54
|
|
|
@patch('zooma.helpers.annotate_country') |
|
55
|
|
|
def test_annotate_countries(self, my_func): |
|
56
|
|
|
"Test annotate_countries command" |
|
57
|
|
|
|
|
58
|
|
|
# mocking objects |
|
59
|
|
|
args = [] |
|
60
|
|
|
opts = {} |
|
61
|
|
|
call_command('annotate_countries', *args, **opts) |
|
62
|
|
|
|
|
63
|
|
|
self.assertTrue(my_func.called) |
|
64
|
|
|
|
|
65
|
|
|
@patch('zooma.helpers.annotate_specie') |
|
66
|
|
|
def test_annotate_species(self, my_func): |
|
67
|
|
|
"Test annotate_species command" |
|
68
|
|
|
|
|
69
|
|
|
# mocking objects |
|
70
|
|
|
args = [] |
|
71
|
|
|
opts = {} |
|
72
|
|
|
call_command('annotate_species', *args, **opts) |
|
73
|
|
|
|
|
74
|
|
|
self.assertTrue(my_func.called) |
|
75
|
|
|
|
|
76
|
|
|
@patch('zooma.helpers.annotate_uberon') |
|
77
|
|
|
def test_annotate_uberon(self, my_func): |
|
78
|
|
|
"Test annotate_uberon command" |
|
79
|
|
|
|
|
80
|
|
|
# mocking objects |
|
81
|
|
|
args = [] |
|
82
|
|
|
opts = {} |
|
83
|
|
|
call_command('annotate_uberon', *args, **opts) |
|
84
|
|
|
|
|
85
|
|
|
self.assertTrue(my_func.called) |
|
86
|
|
|
|
|
87
|
|
|
@patch('zooma.helpers.annotate_dictdevelstage') |
|
88
|
|
|
def test_annotate_dictdevelstage(self, my_func): |
|
89
|
|
|
"Test annotate_dictdevelstage command" |
|
90
|
|
|
|
|
91
|
|
|
# mocking objects |
|
92
|
|
|
args = [] |
|
93
|
|
|
opts = {} |
|
94
|
|
|
call_command('annotate_dictdevelstage', *args, **opts) |
|
95
|
|
|
|
|
96
|
|
|
self.assertTrue(my_func.called) |
|
97
|
|
|
|
|
98
|
|
|
@patch('zooma.helpers.annotate_dictphysiostage') |
|
99
|
|
|
def test_annotate_dictphysiostage(self, my_func): |
|
100
|
|
|
"Test annotate_dictphysiostage command" |
|
101
|
|
|
|
|
102
|
|
|
# mocking objects |
|
103
|
|
|
args = [] |
|
104
|
|
|
opts = {} |
|
105
|
|
|
call_command('annotate_dictphysiostage', *args, **opts) |
|
106
|
|
|
|
|
107
|
|
|
self.assertTrue(my_func.called) |
|
108
|
|
|
|