Passed
Pull Request — master (#166)
by Antonio
06:26 queued 54s
created

build.tests.unit.test_db_models   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestDBModels.setUp() 0 23 1
A TestDBModels.test_evcbasedoc() 0 5 1
A TestDBModels.test_evcbasedoc_error() 0 7 2
1
"""Tests for DB models."""
2
from unittest import TestCase
3
from pydantic import ValidationError
4
5
from db.models import EVCBaseDoc
6
7
8
class TestDBModels(TestCase):
9
    """Test the DB models"""
10
11
    def setUp(self):
12
        self.evc_dict = {
13
            "uni_a": {
14
                "interface_id": "00:00:00:00:00:00:00:04:1",
15
                "tag": {
16
                    "tag_type": 1,
17
                    "value": 100,
18
                }
19
            },
20
            "uni_z": {
21
                "interface_id": "00:00:00:00:00:00:00:02:3",
22
                "tag": {
23
                    "tag_type": 1,
24
                    "value": 100,
25
                }
26
            },
27
            "name": "EVC 2",
28
            "dynamic_backup_path": True,
29
            "creation_time": "2022-04-06T21:34:10",
30
            "priority": 81,
31
            "active": False,
32
            "enabled": False,
33
            "circuit_scheduler": []
34
        }
35
36
    def test_evcbasedoc(self):
37
        """Test EVCBaseDoc model"""
38
39
        evc = EVCBaseDoc(**self.evc_dict)
40
        assert evc.name == "EVC 2"
41
42
    def test_evcbasedoc_error(self):
43
        """Test failure EVCBaseDoc model creation"""
44
45
        self.evc_dict["queue_id"] = "error"
46
47
        with self.assertRaises(ValidationError):
48
            EVCBaseDoc(**self.evc_dict)
49