summaryrefslogtreecommitdiffstats
path: root/ansible_collections/dellemc/enterprise_sonic/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/dellemc/enterprise_sonic/tests/unit')
-rwxr-xr-xansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh2
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml43
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml46
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml38
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml28
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml29
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml18
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml30
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml34
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml50
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml37
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml31
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml40
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml48
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml61
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml163
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml252
-rw-r--r--ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py87
18 files changed, 1037 insertions, 0 deletions
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh
new file mode 100755
index 000000000..ac35117ec
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/run_test_cases.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+pytest -vvvv test_diff_util.py
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml
new file mode 100644
index 000000000..ddab89945
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_01_dict_diff_with_key_name.yaml
@@ -0,0 +1,43 @@
+---
+want:
+ name: tacacs
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ name: radius
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+diff:
+ name: tacacs
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml
new file mode 100644
index 000000000..f7bd8a521
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_02_dict_diff_with_key_other.yaml
@@ -0,0 +1,46 @@
+---
+test_keys:
+ - config:
+ - method
+want:
+ method: tacacs
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ method: radius
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+diff:
+ method: tacacs
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml
new file mode 100644
index 000000000..e09fe74a8
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_03_dict_diff_without_key.yaml
@@ -0,0 +1,38 @@
+---
+want:
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ auth_type: pap
+ key: pap
+ source_interface: Eth 11
+ timeout: 12
+ host:
+ name: my_host1
+ auth_type: pap
+ key: pap
+ port: 55
+ timeout: 11
+ priority: 2
+ vrf: default
+diff:
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ timeout: 12
+ priority: 3
+ vrf: mgmt
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml
new file mode 100644
index 000000000..0d754337a
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_04_dict_diff_with_similar_dict.yaml
@@ -0,0 +1,28 @@
+---
+want:
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+diff: {}
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml
new file mode 100644
index 000000000..8a3e2e4a3
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_05_dict_diff_left_only.yaml
@@ -0,0 +1,29 @@
+---
+want:
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ key: chap
+ host:
+ name: my_host
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+diff:
+ auth_type: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ auth_type: chap
+ key: chap
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml
new file mode 100644
index 000000000..78c65d27a
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_06_dict_diff_left_only_with_none.yaml
@@ -0,0 +1,18 @@
+---
+want:
+ auth_type: chap
+ key:
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ auth_type:
+ port:
+ timeout: 15
+have:
+ key: chap
+diff:
+ auth_type: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ timeout: 15
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml
new file mode 100644
index 000000000..b2307a034
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_07_dict_diff_skeleton_only.yaml
@@ -0,0 +1,30 @@
+---
+skeleton: True
+want:
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ key: pap
+ host:
+ name: my_host1
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+diff:
+ auth_type: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ auth_type: chap
+ key: chap
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml
new file mode 100644
index 000000000..b2317f779
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_08_list_diff_with_key_name.yaml
@@ -0,0 +1,34 @@
+---
+want:
+ - name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+have:
+ - name: vrf1
+ router_id: 100.2.2.30
+ log_neighbor_changes: False
+ - name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - name: vrf3
+ router_id: 102.2.2.30
+ log_neighbor_changes: True
+diff:
+ - name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml
new file mode 100644
index 000000000..e3e9701c6
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_09_list_diff_with_multi_keys.yaml
@@ -0,0 +1,50 @@
+---
+test_keys:
+ - config:
+ - vrf_name
+ - bgp_as
+want:
+ - bgp_as: 51
+ vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - bgp_as: 52
+ vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - bgp_as: 53
+ vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - bgp_as: 54
+ vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+have:
+ - bgp_as: 50
+ vrf_name: vrf1
+ - bgp_as: 51
+ vrf_name: vrf1
+ router_id: 100.2.2.30
+ log_neighbor_changes: False
+ - bgp_as: 52
+ vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - bgp_as: 53
+ vrf_name: vrf3
+ router_id: 102.2.2.30
+ log_neighbor_changes: True
+diff:
+ - bgp_as: 51
+ vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - bgp_as: 53
+ vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - bgp_as: 54
+ vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml
new file mode 100644
index 000000000..3d4494b9d
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_10_list_diff_with_key_other.yaml
@@ -0,0 +1,37 @@
+---
+test_keys:
+ - config:
+ - vrf_name
+want:
+ - vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+have:
+ - vrf_name: vrf1
+ router_id: 100.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf3
+ router_id: 102.2.2.30
+ log_neighbor_changes: True
+diff:
+ - vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml
new file mode 100644
index 000000000..b5826a5ab
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_11_list_diff_with_similar_list.yaml
@@ -0,0 +1,31 @@
+---
+test_keys:
+ - config:
+ - vrf_name
+want:
+ - vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+have:
+ - vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+diff: []
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml
new file mode 100644
index 000000000..b491385ea
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_12_list_diff_with_left_only.yaml
@@ -0,0 +1,40 @@
+---
+test_keys:
+ - config:
+ - vrf_name
+want:
+ - vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf5
+ router_id: 114.2.2.30
+ log_neighbor_changes: True
+have:
+ - vrf_name: default
+ router_id: 100.2.2.30
+ log_neighbor_changes: False
+diff:
+ - vrf_name: vrf1
+ router_id: 110.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf5
+ router_id: 114.2.2.30
+ log_neighbor_changes: True
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml
new file mode 100644
index 000000000..b15fea916
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_13_list_diff_with_left_only_with_none.yaml
@@ -0,0 +1,48 @@
+---
+test_keys:
+ - config:
+ - vrf_name
+want:
+ - vrf_name: vrf1
+ router_id:
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ log_neighbor_changes:
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf5
+ router_id: 114.2.2.30
+ log_neighbor_changes: True
+ best_path:
+ as_path:
+ med:
+ value: 5
+ id: i1
+have:
+ - vrf_name: default
+ router_id: 100.2.2.30
+ log_neighbor_changes: False
+
+diff:
+ - vrf_name: vrf1
+ log_neighbor_changes: True
+ - vrf_name: vrf2
+ router_id: 111.2.2.30
+ - vrf_name: vrf3
+ router_id: 112.2.2.30
+ log_neighbor_changes: False
+ - vrf_name: vrf4
+ router_id: 113.2.2.30
+ log_neighbor_changes: True
+ - vrf_name: vrf5
+ router_id: 114.2.2.30
+ log_neighbor_changes: True
+ best_path:
+ as_path:
+ value: 5
+ id: i1
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml
new file mode 100644
index 000000000..b2ead5709
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_14_list_diff_skeleton_only.yaml
@@ -0,0 +1,61 @@
+---
+skeleton: True
+want:
+ - name: radius
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+ - name: tacacs
+ auth_type: chap
+ key: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ name: my_host
+ auth_type: chap
+ key: chap
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+have:
+ - name: radius
+ key: pap
+ host:
+ name: my_host1
+ port: 55
+ timeout: 12
+ priority: 3
+ vrf: mgmt
+ - name: tacacs
+ auth_type: pap
+ source_interface: Eth 11
+ timeout: 11
+ host:
+ name: my_host_03
+ auth_type: pap
+ timeout: 13
+ priority: 4
+diff:
+ - name: radius
+ auth_type: chap
+ source_interface: Eth 12
+ timeout: 12
+ host:
+ auth_type: chap
+ key: chap
+ - name: tacacs
+ key: chap
+ host:
+ key: chap
+ port: 55
+ vrf: mgmt
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml
new file mode 100644
index 000000000..77565dfff
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_15_list_of_list_diff.yaml
@@ -0,0 +1,163 @@
+---
+test_keys:
+ - marks:
+ - year
+ - subjects:
+ - code
+want:
+ - name: test1
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 55
+ - code: E
+ mark: 76
+ - code: S
+ mark: 57
+ - year: 2
+ subjects:
+ - code: M
+ mark: 85
+ - code: E
+ mark: 56
+ - code: S
+ mark: 87
+ - year: 3
+ subjects:
+ - code: M
+ mark: 55
+ - code: E
+ mark: 96
+ - code: S
+ mark: 57
+ - year: 4
+ subjects:
+ - code: M
+ mark: 65
+ - code: E
+ mark: 56
+ - code: S
+ mark: 67
+ - name: test2
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 55
+ - code: E
+ mark: 76
+ - code: S
+ mark: 57
+ - year: 2
+ subjects:
+ - code: M
+ mark: 85
+ - code: E
+ mark: 56
+ - code: S
+ mark: 87
+ - code: G
+ mark: 58
+ - name: test3
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 56
+have:
+ - name: test1
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 75
+ - code: E
+ mark: 76
+ - code: S
+ mark: 77
+ - year: 2
+ subjects:
+ - code: M
+ mark: 85
+ - code: E
+ mark: 86
+ - code: S
+ mark: 87
+ - year: 3
+ subjects:
+ - code: M
+ mark: 95
+ - code: E
+ mark: 96
+ - code: S
+ mark: 97
+ - year: 4
+ subjects:
+ - code: M
+ mark: 65
+ - code: E
+ mark: 66
+ - code: S
+ mark: 67
+ - name: test2
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 75
+ - code: E
+ mark: 76
+ - code: S
+ mark: 77
+ - year: 2
+ subjects:
+ - code: M
+ mark: 85
+ - code: E
+ mark: 86
+ - code: S
+ mark: 87
+diff:
+ - name: test1
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 55
+ - code: S
+ mark: 57
+ - year: 2
+ subjects:
+ - code: E
+ mark: 56
+ - year: 3
+ subjects:
+ - code: M
+ mark: 55
+ - code: S
+ mark: 57
+ - year: 4
+ subjects:
+ - code: E
+ mark: 56
+ - name: test2
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 55
+ - code: S
+ mark: 57
+ - year: 2
+ subjects:
+ - code: E
+ mark: 56
+ - code: G
+ mark: 58
+ - name: test3
+ marks:
+ - year: 1
+ subjects:
+ - code: M
+ mark: 56
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml
new file mode 100644
index 000000000..a6d40b8b0
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_16_complex_list_with_dict_diff.yaml
@@ -0,0 +1,252 @@
+---
+test_keys:
+ - config:
+ - vrf_name
+ - bgp_as
+ - afis:
+ - afi
+ - safi
+ - redistribute:
+ - protocol
+ - route_advertise_list:
+ - advertise_afi
+want:
+ - bgp_as: 51
+ vrf_name: vrf1
+ address_family:
+ afis:
+ - afi: ipv4
+ safi: unicast
+ max_path:
+ ebgp: 2
+ ibgp: 3
+ redistribute:
+ - metric: "20"
+ protocol: connected
+ route_map: rmap_reg1
+ - metric: "26"
+ protocol: ospf
+ route_map: rmap_reg2
+ - metric: "25"
+ protocol: static
+ route_map: rmap_reg3
+ - afi: ipv6
+ safi: unicast
+ max_path:
+ ebgp: 3
+ ibgp: 4
+ redistribute:
+ - metric: "21"
+ protocol: connected
+ route_map: rmap_reg3
+ - metric: "27"
+ protocol: ospf
+ route_map: rmap_reg1
+ - metric: "28"
+ protocol: static
+ route_map: rmap_reg2
+ - afi: l2vpn
+ safi: evpn
+ advertise_all_vni: True
+ route_advertise_list:
+ - advertise_afi: ipv4
+ route_map: rmap_reg1
+ - advertise_afi: ipv6
+ route_map: rmap_reg2
+ - bgp_as: 52
+ vrf_name: vrf2
+ address_family:
+ afis:
+ - afi: ipv4
+ safi: unicast
+ max_path:
+ ebgp: 3
+ ibgp: 2
+ redistribute:
+ - metric: "21"
+ protocol: connected
+ route_map: rmap_reg1
+ - metric: "27"
+ protocol: ospf
+ route_map: rmap_reg2.1
+ - metric: "25"
+ protocol: static
+ route_map: rmap_reg3.1
+ - afi: ipv6
+ safi: unicast
+ max_path:
+ ebgp: 3
+ ibgp: 4
+ redistribute:
+ - metric: "22"
+ protocol: connected
+ route_map: rmap_rega
+ - metric: "28"
+ protocol: ospf
+ route_map: rmap_regb.1
+ - metric: "28"
+ protocol: static
+ route_map: rmap_regc.1
+ - afi: l2vpn
+ safi: evpn
+ route_advertise_list:
+ - advertise_afi: ipv6
+ route_map: rmap_reg2
+have:
+ - bgp_as: 50
+ vrf_name: vrf1
+ address_family:
+ afis:
+ - afi: ipv4
+ safi: unicast
+ max_path:
+ ebgp: 2
+ ibgp: 3
+ redistribute:
+ - metric: "20"
+ protocol: connected
+ route_map: rmap_reg1
+ - metric: "26"
+ protocol: ospf
+ route_map: rmap_reg2
+ - metric: "25"
+ protocol: static
+ route_map: rmap_reg3
+ - afi: ipv6
+ safi: unicast
+ max_path:
+ ebgp: 3
+ ibgp: 4
+ redistribute:
+ - metric: "21"
+ protocol: connected
+ route_map: rmap_reg3
+ - metric: "27"
+ protocol: ospf
+ route_map: rmap_reg1
+ - metric: "28"
+ protocol: static
+ route_map: rmap_reg2
+ - afi: l2vpn
+ safi: evpn
+ advertise_all_vni: True
+ route_advertise_list:
+ - advertise_afi: ipv4
+ route_map: rmap_reg1
+ - advertise_afi: ipv6
+ route_map: rmap_reg2
+ - bgp_as: 52
+ vrf_name: vrf2
+ address_family:
+ afis:
+ - afi: ipv4
+ safi: unicast
+ max_path:
+ ebgp: 1
+ ibgp: 2
+ redistribute:
+ - metric: "20"
+ protocol: connected
+ route_map: rmap_reg1
+ - metric: "26"
+ protocol: ospf
+ route_map: rmap_reg2
+ - metric: "25"
+ protocol: static
+ route_map: rmap_reg3
+ - afi: ipv6
+ safi: unicast
+ max_path:
+ ebgp: 3
+ ibgp: 2
+ redistribute:
+ - metric: "21"
+ protocol: connected
+ route_map: rmap_rega
+ - metric: "27"
+ protocol: ospf
+ route_map: rmap_regb
+ - metric: "28"
+ protocol: static
+ route_map: rmap_regc
+ - afi: l2vpn
+ safi: evpn
+ route_advertise_list:
+ - advertise_afi: ipv4
+ route_map: rmap_reg1
+diff:
+ - bgp_as: 51
+ vrf_name: vrf1
+ address_family:
+ afis:
+ - afi: ipv4
+ safi: unicast
+ max_path:
+ ebgp: 2
+ ibgp: 3
+ redistribute:
+ - metric: "20"
+ protocol: connected
+ route_map: rmap_reg1
+ - metric: "26"
+ protocol: ospf
+ route_map: rmap_reg2
+ - metric: "25"
+ protocol: static
+ route_map: rmap_reg3
+ - afi: ipv6
+ safi: unicast
+ max_path:
+ ebgp: 3
+ ibgp: 4
+ redistribute:
+ - metric: "21"
+ protocol: connected
+ route_map: rmap_reg3
+ - metric: "27"
+ protocol: ospf
+ route_map: rmap_reg1
+ - metric: "28"
+ protocol: static
+ route_map: rmap_reg2
+ - afi: l2vpn
+ safi: evpn
+ advertise_all_vni: True
+ route_advertise_list:
+ - advertise_afi: ipv4
+ route_map: rmap_reg1
+ - advertise_afi: ipv6
+ route_map: rmap_reg2
+ - bgp_as: 52
+ vrf_name: vrf2
+ address_family:
+ afis:
+ - afi: ipv4
+ safi: unicast
+ max_path:
+ ebgp: 3
+ redistribute:
+ - metric: "21"
+ protocol: connected
+ - metric: "27"
+ protocol: ospf
+ route_map: rmap_reg2.1
+ - protocol: static
+ route_map: rmap_reg3.1
+ - afi: ipv6
+ safi: unicast
+ max_path:
+ ibgp: 4
+ redistribute:
+ - metric: "22"
+ protocol: connected
+ - metric: "28"
+ protocol: ospf
+ route_map: rmap_regb.1
+ - protocol: static
+ route_map: rmap_regc.1
+ - afi: l2vpn
+ safi: evpn
+ route_advertise_list:
+ - advertise_afi: ipv6
+ route_map: rmap_reg2
diff --git a/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py
new file mode 100644
index 000000000..65f384a1e
--- /dev/null
+++ b/ansible_collections/dellemc/enterprise_sonic/tests/unit/utils/test_diff_util.py
@@ -0,0 +1,87 @@
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+
+import unittest
+import os
+import yaml
+
+import sys
+sys.path.append('/root/.ansible/collections')
+
+from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import (
+ get_diff,
+)
+
+
+class TestDiffUtils(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ def read_and_compare(self, file_name):
+ file_name = os.path.join(os.path.dirname(__file__), file_name)
+ file_stream = open(file_name, "r")
+ data = yaml.full_load(file_stream)
+ file_stream.close()
+
+ want = data.get('want', [])
+ have = data.get('have', [])
+ diff_exp = data.get('diff', [])
+ test_keys = data.get('test_keys', None)
+ is_skeleton = data.get('skeleton', None)
+
+ diff_act = get_diff(want, have, test_keys, is_skeleton=is_skeleton)
+
+ self.assertEqual(diff_exp, diff_act)
+
+ def test_01_dict_diff_with_key_name(self):
+ self.read_and_compare("test_01_dict_diff_with_key_name.yaml")
+
+ def test_02_dict_diff_with_key_other(self):
+ self.read_and_compare("test_02_dict_diff_with_key_other.yaml")
+
+ def test_03_dict_diff_without_key(self):
+ self.read_and_compare("test_03_dict_diff_without_key.yaml")
+
+ def test_04_dict_diff_with_similar_dict(self):
+ self.read_and_compare("test_04_dict_diff_with_similar_dict.yaml")
+
+ def test_05_dict_diff_left_only(self):
+ self.read_and_compare("test_05_dict_diff_left_only.yaml")
+
+ def test_06_dict_diff_left_only_with_none(self):
+ self.read_and_compare("test_06_dict_diff_left_only_with_none.yaml")
+
+ def test_07_dict_diff_skeleton_only(self):
+ self.read_and_compare("test_07_dict_diff_skeleton_only.yaml")
+
+ def test_08_list_diff_with_key_name(self):
+ self.read_and_compare("test_08_list_diff_with_key_name.yaml")
+
+ def test_09_list_diff_with_multi_keys(self):
+ self.read_and_compare("test_09_list_diff_with_multi_keys.yaml")
+
+ def test_10_list_diff_with_key_other(self):
+ self.read_and_compare("test_10_list_diff_with_key_other.yaml")
+
+ def test_11_list_diff_with_similar_list(self):
+ self.read_and_compare("test_11_list_diff_with_similar_list.yaml")
+
+ def test_12_list_diff_with_left_only(self):
+ self.read_and_compare("test_12_list_diff_with_left_only.yaml")
+
+ def test_13_list_diff_with_left_only_with_none(self):
+ self.read_and_compare("test_13_list_diff_with_left_only_with_none.yaml")
+
+ def test_14_list_diff_skeleton_only(self):
+ self.read_and_compare("test_14_list_diff_skeleton_only.yaml")
+
+ def test_15_list_of_list_diff(self):
+ self.read_and_compare("test_15_list_of_list_diff.yaml")
+
+ def test_16_complex_list_with_dict_diff(self):
+ self.read_and_compare("test_16_complex_list_with_dict_diff.yaml")