| Total Complexity | 4 | 
| Total Lines | 49 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 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 |