Passed
Pull Request — master (#40)
by Paolo
01:37
created

image_app.tests.mixins   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A DataSourceMixinTestCase.check_errors() 0 9 1
A DataSourceMixinTestCase.upload_datasource() 0 9 1
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
"""
4
Created on Fri Jul  5 15:57:10 2019
5
6
@author: Paolo Cozzi <[email protected]>
7
"""
8
9
from common.tests import DataSourceMixinTestCase as CommonDataSourceMixinTest
10
11
from ..models import db_has_data, Animal, Sample, Submission
12
13
14
class DataSourceMixinTestCase(CommonDataSourceMixinTest):
15
    # defining attribute classes
16
    submission_model = Submission
17
18
    def upload_datasource(self, message):
19
        """test upload data from DatsSource"""
20
21
        super(DataSourceMixinTestCase, self).upload_datasource(message)
22
23
        # assert data into database
24
        self.assertTrue(db_has_data())
25
        self.assertTrue(Animal.objects.exists())
26
        self.assertTrue(Sample.objects.exists())
27
28
    def check_errors(self, my_check, message):
29
        """Common stuff for cehcking error in file loading"""
30
31
        super(DataSourceMixinTestCase, self).check_errors(my_check, message)
32
33
        # assert data into database
34
        self.assertFalse(db_has_data())
35
        self.assertFalse(Animal.objects.exists())
36
        self.assertFalse(Sample.objects.exists())
37