Skip to content

Commit c73bca1

Browse files
committed
sonic-yang-models: error strings are different in libyang3
1 parent e8ac86d commit c73bca1

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

src/sonic-yang-models/tests/yang_model_pytests/test_crm.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def test_crm_valid_data(self, yang_model, resource, threshold):
6161

6262
@pytest.mark.parametrize(
6363
"high, low, error_message", [
64-
(-1, 70, 'Invalid value "-1"'),
65-
(100, -70, 'Invalid value "-70"'),
64+
(-1, 70, 'Value "-1" is out of type uint16 min/max bounds'),
65+
(100, -70, 'Value "-70" is out of type uint16 min/max bounds'),
6666
(10, 70, 'high_threshold should be more than low_threshold')]
6767
)
6868
def test_crm_thresholds(self, yang_model, resource, threshold, high, low, error_message):
@@ -82,7 +82,7 @@ def test_crm_thresholds(self, yang_model, resource, threshold, high, low, error_
8282

8383
@pytest.mark.parametrize(
8484
"high, low, th_type, error_message", [
85-
(100, 70, 'wrong', 'Value "wrong" does not satisfy the constraint'),
85+
(100, 70, 'wrong', 'Unsatisfied pattern'),
8686
(110, 20, 'percentage', 'Must condition')]
8787
)
8888
def test_crm_threshold_type(self, yang_model, resource, high, low, th_type, error_message):

src/sonic-yang-models/tests/yang_model_pytests/test_dash_crm.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def test_dash_crm_valid_data(self, yang_model, data, resource, threshold):
6868

6969
@pytest.mark.parametrize(
7070
"high, low, error_message", [
71-
(-1, 70, 'Invalid value "-1"'),
72-
(100, -70, 'Invalid value "-70"'),
71+
(-1, 70, 'Value "-1" is out of type uint16 min/max bounds'),
72+
(100, -70, 'Value "-70" is out of type uint16 min/max bounds'),
7373
(10, 70, 'high_threshold should be more than low_threshold')]
7474
)
7575
def test_dash_crm_thresholds(self, yang_model, data, resource, threshold, high, low, error_message):
@@ -87,7 +87,7 @@ def test_dash_crm_thresholds(self, yang_model, data, resource, threshold, high,
8787

8888
@pytest.mark.parametrize(
8989
"high, low, th_type, error_message", [
90-
(100, 70, 'wrong', 'Value "wrong" does not satisfy the constraint'),
90+
(100, 70, 'wrong', 'Unsatisfied pattern'),
9191
(110, 20, 'percentage', 'Must condition')]
9292
)
9393
def test_dash_crm_threshold_type(self, yang_model, data, resource, high, low, th_type, error_message):

src/sonic-yang-models/tests/yang_model_pytests/test_smart_switch.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_valid_data(self, yang_model):
3232
@pytest.mark.parametrize(
3333
"bridge_name, error_message", [
3434
("bridge-midplane", None),
35-
("wrong_name", 'Value "wrong_name" does not satisfy the constraint "bridge-midplane"')]
35+
("wrong_name", 'Unsatisfied pattern')]
3636
)
3737
def test_bridge_name(self, yang_model, bridge_name, error_message):
3838
data = {
@@ -51,7 +51,7 @@ def test_bridge_name(self, yang_model, bridge_name, error_message):
5151
@pytest.mark.parametrize(
5252
"ip_prefix, error_message", [
5353
("169.254.200.254/24", None),
54-
("169.254.xyz.254/24", 'Value "169.254.xyz.254/24" does not satisfy the constraint')]
54+
("169.254.xyz.254/24", 'Unsatisfied pattern')]
5555
)
5656
def test_bridge_ip_prefix(self, yang_model, ip_prefix, error_message):
5757
data = {
@@ -70,7 +70,7 @@ def test_bridge_ip_prefix(self, yang_model, ip_prefix, error_message):
7070
@pytest.mark.parametrize(
7171
"dpu_name, error_message", [
7272
("dpu0", None),
73-
("xyz", 'Value "xyz" does not satisfy the constraint "dpu[0-9]+')]
73+
("xyz", 'Unsatisfied pattern')]
7474
)
7575
def test_dpu_name(self, yang_model, dpu_name, error_message):
7676
data = {
@@ -91,7 +91,7 @@ def test_dpu_name(self, yang_model, dpu_name, error_message):
9191
@pytest.mark.parametrize(
9292
"midplane_interface, error_message", [
9393
("dpu0", None),
94-
("xyz", 'Value "xyz" does not satisfy the constraint "dpu[0-9]+')]
94+
("xyz", 'Unsatisfied pattern')]
9595
)
9696
def test_dpu_midplane_interface(self, yang_model, midplane_interface, error_message):
9797
data = {
@@ -112,7 +112,7 @@ def test_dpu_midplane_interface(self, yang_model, midplane_interface, error_mess
112112
@pytest.mark.parametrize(
113113
"port_name, error_message", [
114114
("dpu0", None),
115-
("dp0rt0", 'Value "dp0rt0" does not satisfy the constraint "[a-zA-Z]+[0-9]+"')]
115+
("dp0rt0", 'Unsatisfied pattern')]
116116
)
117117
def test_dpu_port_name(self, yang_model, port_name, error_message):
118118
data = {
@@ -139,7 +139,7 @@ def test_dpu_port_name(self, yang_model, port_name, error_message):
139139
@pytest.mark.parametrize(
140140
"vip_ipv4, error_message", [
141141
("192.168.1.1", None),
142-
("192.168.1.xyz", 'Value "192.168.1.xyz" does not satisfy the constraint')]
142+
("192.168.1.xyz", 'Unsatisfied pattern')]
143143
)
144144
def test_dpu_port_vip_ipv4(self, yang_model, vip_ipv4, error_message):
145145
data = {
@@ -166,7 +166,7 @@ def test_dpu_port_vip_ipv4(self, yang_model, vip_ipv4, error_message):
166166
@pytest.mark.parametrize(
167167
"vip_ipv6, error_message", [
168168
("2001:db8::1", None),
169-
("2001:db8::xyz", 'Value "2001:db8::xyz" does not satisfy the constraint')]
169+
("2001:db8::xyz", 'Unsatisfied pattern')]
170170
)
171171
def test_dpu_port_vip_ipv6(self, yang_model, vip_ipv6, error_message):
172172
data = {
@@ -193,7 +193,7 @@ def test_dpu_port_vip_ipv6(self, yang_model, vip_ipv6, error_message):
193193
@pytest.mark.parametrize(
194194
"pa_ipv4, error_message", [
195195
("192.168.1.2", None),
196-
("192.168.1.xyz", 'Value "192.168.1.xyz" does not satisfy the constraint')]
196+
("192.168.1.xyz", 'Unsatisfied pattern')]
197197
)
198198
def test_dpu_port_pa_ipv4(self, yang_model, pa_ipv4, error_message):
199199
data = {
@@ -220,7 +220,7 @@ def test_dpu_port_pa_ipv4(self, yang_model, pa_ipv4, error_message):
220220
@pytest.mark.parametrize(
221221
"pa_ipv6, error_message", [
222222
("2001:db8::2", None),
223-
("2001:db8::xyz", 'Value "2001:db8::xyz" does not satisfy the constraint')]
223+
("2001:db8::xyz", 'Unsatisfied pattern')]
224224
)
225225
def test_dpu_port_pa_ipv6(self, yang_model, pa_ipv6, error_message):
226226
data = {
@@ -247,7 +247,7 @@ def test_dpu_port_pa_ipv6(self, yang_model, pa_ipv6, error_message):
247247
@pytest.mark.parametrize(
248248
"gnmi_port, error_message", [
249249
(8080, None),
250-
(99999, 'Invalid value "99999" in "gnmi_port" element.')]
250+
(99999, 'Value "99999" is out of type uint16 min/max bounds')]
251251
)
252252
def test_dpu_port_gnmi(self, yang_model, gnmi_port, error_message):
253253
data = {

src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py

+12-16
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,23 @@ class Test_yang_models:
4040
def initTest(self):
4141
self.defaultYANGFailure = {
4242
'Must': ['Must condition', 'not satisfied'],
43-
'InvalidValue': ['Invalid value'], # libyang3: ['Invalid', 'value', 'Data path']
44-
'LeafRef': ['Leafref', 'non-existing'], #libyang3: ['Invalid leafref', 'no target instance']
43+
'InvalidValue': ['Invalid', 'value', 'Data path'],
44+
'LeafRef': ['Invalid leafref', 'no target instance'],
4545
'When': ['When condition', 'not satisfied'],
46-
'Pattern': ['pattern', 'does not satisfy'], #libyang3: ['pattern', 'Unsatisfied pattern']
47-
'Mandatory': ['required element', 'Missing'], #libyang3: ['Mandatory node', 'does not exist']
46+
'Pattern': ['pattern', 'Unsatisfied pattern'],
47+
'Mandatory': ['Mandatory node', 'does not exist'],
4848
'Verify': ['verified'],
49-
'Range': ['does not satisfy', 'range'], #libyang3: ['Unsatisfied range']
49+
'Range': ['Unsatisfied range'],
5050
'MinElements': ['Too few'],
5151
'MaxElements': ['Too many'],
52-
'UnknownElement': ['Unknown element'],
52+
'UnknownElement': ['not found as a child'],
5353
'None': [],
54-
# New keys are needed for libyang3's messages which are different. Go
55-
# ahead and add them now with the libyang1 values (which are duplicates
56-
# of the above). This will make migrating to libyang3 easier with less
57-
# code review.
58-
'Length': ['does not satisfy', 'range'], # libyang3: ['Unsatisfied length']
59-
'DecimalFractionExceed': ['Invalid value'], # libyang3: ['Value', 'exceeds defined number', 'fraction digits']
60-
'Bounds': ['Invalid value'], #libyang3 ['Value', 'out of type', 'min/max bounds'],
61-
'ListKey': ['Missing required element'], #libyang3 ['List instance is missing its key']
62-
'DateTime': ['pattern', 'does not satisfy'], #libyang3: ['Invalid date-and-time']
63-
'IPv4': ['pattern', 'does not satisfy'], #libyang3 ['Failed to convert IPv4 address'],
54+
'Length': ['Unsatisfied length'],
55+
'DecimalFractionExceed': ['Value', 'exceeds defined number', 'fraction digits'],
56+
'Bounds': ['Value', 'out of type', 'min/max bounds'],
57+
'ListKey': ['List instance is missing its key'],
58+
'DateTime': ['Invalid date-and-time'],
59+
'IPv4': ['Failed to convert IPv4 address'],
6460
}
6561

6662
self.ExceptionTests = { }

0 commit comments

Comments
 (0)