|
3 | 3 | import jsonpatch
|
4 | 4 | import sonic_yang
|
5 | 5 | import unittest
|
6 |
| -import mock |
| 6 | +from unittest.mock import MagicMock, Mock, patch |
7 | 7 |
|
8 |
| -from unittest.mock import MagicMock, Mock |
9 |
| -from mock import patch |
10 | 8 | from .gutest_helpers import create_side_effect_dict, Files
|
11 | 9 | import generic_config_updater.gu_common as gu_common
|
12 | 10 |
|
@@ -71,59 +69,15 @@ def setUp(self):
|
71 | 69 | self.config_wrapper_mock = gu_common.ConfigWrapper()
|
72 | 70 | self.config_wrapper_mock.get_config_db_as_json=MagicMock(return_value=Files.CONFIG_DB_AS_JSON)
|
73 | 71 |
|
74 |
| - @patch("sonic_py_common.device_info.get_sonic_version_info", mock.Mock(return_value={"asic_type": "mellanox", "build_version": "SONiC.20181131"})) |
75 |
| - def test_validate_field_operation_legal__pfcwd(self): |
| 72 | + def test_validate_field_operation_legal(self): |
76 | 73 | old_config = {"PFC_WD": {"GLOBAL": {"POLL_INTERVAL": "60"}}}
|
77 | 74 | target_config = {"PFC_WD": {"GLOBAL": {"POLL_INTERVAL": "40"}}}
|
78 | 75 | config_wrapper = gu_common.ConfigWrapper()
|
79 | 76 | config_wrapper.validate_field_operation(old_config, target_config)
|
80 |
| - |
81 |
| - def test_validate_field_operation_illegal__pfcwd(self): |
82 |
| - old_config = {"PFC_WD": {"GLOBAL": {"POLL_INTERVAL": "60"}}} |
83 |
| - target_config = {"PFC_WD": {"GLOBAL": {}}} |
84 |
| - config_wrapper = gu_common.ConfigWrapper() |
85 |
| - self.assertRaises(gu_common.IllegalPatchOperationError, config_wrapper.validate_field_operation, old_config, target_config) |
86 | 77 |
|
87 |
| - @patch("sonic_py_common.device_info.get_sonic_version_info", mock.Mock(return_value={"asic_type": "invalid-asic", "build_version": "SONiC.20181131"})) |
88 |
| - def test_validate_field_modification_illegal__pfcwd(self): |
89 |
| - old_config = {"PFC_WD": {"GLOBAL": {"POLL_INTERVAL": "60"}}} |
90 |
| - target_config = {"PFC_WD": {"GLOBAL": {"POLL_INTERVAL": "80"}}} |
91 |
| - config_wrapper = gu_common.ConfigWrapper() |
92 |
| - self.assertRaises(gu_common.IllegalPatchOperationError, config_wrapper.validate_field_operation, old_config, target_config) |
93 |
| - |
94 |
| - def test_validate_field_operation_legal__rm_loopback1(self): |
95 |
| - old_config = { |
96 |
| - "LOOPBACK_INTERFACE": { |
97 |
| - "Loopback0": {}, |
98 |
| - "Loopback0|10.1.0.32/32": {}, |
99 |
| - "Loopback1": {}, |
100 |
| - "Loopback1|10.1.0.33/32": {} |
101 |
| - } |
102 |
| - } |
103 |
| - target_config = { |
104 |
| - "LOOPBACK_INTERFACE": { |
105 |
| - "Loopback0": {}, |
106 |
| - "Loopback0|10.1.0.32/32": {} |
107 |
| - } |
108 |
| - } |
109 |
| - config_wrapper = gu_common.ConfigWrapper() |
110 |
| - config_wrapper.validate_field_operation(old_config, target_config) |
111 |
| - |
112 |
| - def test_validate_field_operation_illegal__rm_loopback0(self): |
113 |
| - old_config = { |
114 |
| - "LOOPBACK_INTERFACE": { |
115 |
| - "Loopback0": {}, |
116 |
| - "Loopback0|10.1.0.32/32": {}, |
117 |
| - "Loopback1": {}, |
118 |
| - "Loopback1|10.1.0.33/32": {} |
119 |
| - } |
120 |
| - } |
121 |
| - target_config = { |
122 |
| - "LOOPBACK_INTERFACE": { |
123 |
| - "Loopback1": {}, |
124 |
| - "Loopback1|10.1.0.33/32": {} |
125 |
| - } |
126 |
| - } |
| 78 | + def test_validate_field_operation_illegal(self): |
| 79 | + old_config = {"PFC_WD": {"GLOBAL": {"POLL_INTERVAL": 60}}} |
| 80 | + target_config = {"PFC_WD": {"GLOBAL": {}}} |
127 | 81 | config_wrapper = gu_common.ConfigWrapper()
|
128 | 82 | self.assertRaises(gu_common.IllegalPatchOperationError, config_wrapper.validate_field_operation, old_config, target_config)
|
129 | 83 |
|
|
0 commit comments