|
| 1 | +import jsonpointer |
1 | 2 | import unittest
|
2 | 3 | from importlib import reload
|
3 | 4 | from unittest.mock import patch, MagicMock
|
4 | 5 | from generic_config_updater.generic_updater import extract_scope
|
| 6 | +from generic_config_updater.generic_updater import GenericConfigUpdaterError |
5 | 7 | import generic_config_updater.change_applier
|
6 | 8 | import generic_config_updater.services_validator
|
7 | 9 | import generic_config_updater.gu_common
|
@@ -49,6 +51,12 @@ def test_extract_scope_multiasic(self, mock_is_multi_asic):
|
49 | 51 | "/asic0123456789/PORTCHANNEL/PortChannel102/admin_status": (
|
50 | 52 | True, "asic0123456789", "/PORTCHANNEL/PortChannel102/admin_status"
|
51 | 53 | ),
|
| 54 | + "/asic1/PORTCHANNEL_INTERFACE/PortChannel106|10.0.0.6/31": ( |
| 55 | + True, "asic1", "/PORTCHANNEL_INTERFACE/PortChannel106|10.0.0.6/31" |
| 56 | + ), |
| 57 | + "/asic1/PORTCHANNEL_INTERFACE/PortChannel106|10.0.0.6~131": ( |
| 58 | + True, "asic1", "/PORTCHANNEL_INTERFACE/PortChannel106|10.0.0.6~131" |
| 59 | + ), |
52 | 60 | "/localhost/BGP_DEVICE_GLOBAL/STATE/tsa_enabled": (
|
53 | 61 | True, "localhost", "/BGP_DEVICE_GLOBAL/STATE/tsa_enabled"
|
54 | 62 | ),
|
@@ -95,7 +103,11 @@ def test_extract_scope_multiasic(self, mock_is_multi_asic):
|
95 | 103 | scope, remainder = extract_scope(test_path)
|
96 | 104 | assert(scope == expectedscope)
|
97 | 105 | assert(remainder == expectedremainder)
|
98 |
| - except Exception: |
| 106 | + except AssertionError: |
| 107 | + assert(not result) |
| 108 | + except GenericConfigUpdaterError: |
| 109 | + assert(not result) |
| 110 | + except jsonpointer.JsonPointerException: |
99 | 111 | assert(not result)
|
100 | 112 |
|
101 | 113 | @patch('sonic_py_common.multi_asic.is_multi_asic')
|
@@ -158,7 +170,11 @@ def test_extract_scope_singleasic(self, mock_is_multi_asic):
|
158 | 170 | scope, remainder = extract_scope(test_path)
|
159 | 171 | assert(scope == expectedscope)
|
160 | 172 | assert(remainder == expectedremainder)
|
161 |
| - except Exception: |
| 173 | + except AssertionError: |
| 174 | + assert(not result) |
| 175 | + except GenericConfigUpdaterError: |
| 176 | + assert(not result) |
| 177 | + except jsonpointer.JsonPointerException: |
162 | 178 | assert(not result)
|
163 | 179 |
|
164 | 180 | @patch('generic_config_updater.change_applier.get_config_db_as_json', autospec=True)
|
|
0 commit comments