@@ -84,69 +84,118 @@ def test_aci_pod_tep_pool(self) -> None:
8484
8585 def test_invalid_aci_pod_name (self ) -> None :
8686 """Test validation of ACI Pod naming."""
87- pod = ACIPod (name = "ACI Test Pod 1" )
88- with self .assertRaises (ValidationError ):
87+ pod = ACIPod (
88+ name = "ACI Test Pod 1" ,
89+ aci_fabric = self .aci_fabric ,
90+ pod_id = 20 ,
91+ )
92+ with self .assertRaises (ValidationError ) as cm :
8993 pod .full_clean ()
9094
95+ # Check the specific field that failed
96+ self .assertIn ("name" , cm .exception .error_dict )
97+
9198 def test_invalid_aci_pod_name_length (self ) -> None :
9299 """Test validation of ACI Pod name length."""
93100 pod = ACIPod (
94101 name = "T" * 65 , # Exceeding the maximum length of 64
95102 aci_fabric = self .aci_fabric ,
103+ pod_id = 20 ,
96104 )
97- with self .assertRaises (ValidationError ):
105+ with self .assertRaises (ValidationError ) as cm :
98106 pod .full_clean ()
99107
108+ # Check the specific field that failed
109+ self .assertIn ("name" , cm .exception .error_dict )
110+
100111 def test_invalid_aci_pod_name_alias (self ) -> None :
101112 """Test validation of ACI pod aliasing."""
102113 pod = ACIPod (
103114 name = "ACIPodTest1" ,
104115 name_alias = "Invalid Alias" ,
105116 aci_fabric = self .aci_fabric ,
117+ pod_id = 20 ,
106118 )
107- with self .assertRaises (ValidationError ):
119+ with self .assertRaises (ValidationError ) as cm :
108120 pod .full_clean ()
109121
122+ # Check the specific field that failed
123+ self .assertIn ("name_alias" , cm .exception .error_dict )
124+
110125 def test_invalid_aci_pod_description (self ) -> None :
111126 """Test validation of ACI Pod description."""
112127 pod = ACIPod (
113128 name = "ACITestPod1" ,
114129 description = "Invalid Description: ö" ,
115130 aci_fabric = self .aci_fabric ,
131+ pod_id = 20 ,
116132 )
117- with self .assertRaises (ValidationError ):
133+ with self .assertRaises (ValidationError ) as cm :
118134 pod .full_clean ()
119135
136+ # Check the specific field that failed
137+ self .assertIn ("description" , cm .exception .error_dict )
138+
120139 def test_invalid_aci_pod_description_length (self ) -> None :
121140 """Test validation of ACI Pod description length."""
122141 pod = ACIPod (
123142 name = "ACITestPod1" ,
124143 description = "T" * 129 , # Exceeding the maximum length of 128
125144 aci_fabric = self .aci_fabric ,
145+ pod_id = 20 ,
126146 )
127- with self .assertRaises (ValidationError ):
147+ with self .assertRaises (ValidationError ) as cm :
128148 pod .full_clean ()
129149
150+ # Check the specific field that failed
151+ self .assertIn ("description" , cm .exception .error_dict )
152+
130153 def test_invalid_aci_pod_id (self ) -> None :
131154 """Test validation of ACI Pod ID value."""
132155 pod = ACIPod (
133156 name = "ACITestPod1" ,
134157 aci_fabric = self .aci_fabric ,
135158 pod_id = 5000 ,
136159 )
137- with self .assertRaises (ValidationError ):
160+ with self .assertRaises (ValidationError ) as cm :
138161 pod .full_clean ()
139162
163+ # Check the specific field that failed
164+ self .assertIn ("pod_id" , cm .exception .error_dict )
165+
166+ def test_invalid_aci_pod_tep_pool (self ) -> None :
167+ """Test validation of the ACI Pod TEP pool prefix."""
168+ invalid_tep_pool = Prefix (prefix = "10.0.0.0/27" )
169+ invalid_tep_pool .full_clean ()
170+ invalid_tep_pool .save ()
171+ pod = ACIPod (
172+ name = "ACITestPod1" ,
173+ aci_fabric = self .aci_fabric ,
174+ pod_id = 20 ,
175+ tep_pool = invalid_tep_pool ,
176+ )
177+ with self .assertRaises (ValidationError ) as cm :
178+ pod .full_clean ()
179+
180+ # Check the specific field that failed
181+ self .assertIn ("tep_pool" , cm .exception .error_dict )
182+
140183 def test_constraint_unique_aci_pod_name (self ) -> None :
141184 """Test unique constraint of ACI Pod name."""
142- duplicate_pod = ACIPod (name = self .aci_pod_name , aci_fabric = self .aci_fabric )
185+ duplicate_pod = ACIPod (
186+ name = self .aci_pod_name ,
187+ aci_fabric = self .aci_fabric ,
188+ pod_id = 100 ,
189+ )
143190 with self .assertRaises (IntegrityError ):
144191 duplicate_pod .save ()
145192
146193 def test_constraint_unique_aci_pod_id (self ) -> None :
147194 """Test unique constraint of ACI Pod ID."""
148195 duplicate_pod = ACIPod (
149- name = "ACITestPod1" , aci_fabric = self .aci_fabric , pod_id = self .aci_pod_id
196+ name = "ACITestPod1" ,
197+ aci_fabric = self .aci_fabric ,
198+ pod_id = self .aci_pod_id ,
150199 )
151200 with self .assertRaises (IntegrityError ):
152201 duplicate_pod .save ()
0 commit comments