summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorzhongjun <zhong.jun@zte.com.cn>2017-08-04 15:24:00 +0800
committerzhongjun <zhong.jun@zte.com.cn>2017-08-04 15:52:14 +0800
commite918ac0683aad63d97303b41d2e9ad1532fb6174 (patch)
tree3fbeab33060940900235a470214bca85d4dea862 /tests
parent5808f4ab29f39ed302068af12c796135b8168da8 (diff)
Fix the assert comparison error in test_get_conf.py
Because the list/dict parse can not ensure the element sequence in python, using == method to compare the dict content may cause the fault. we replace it with DeepDiff function. Change-Id: I1db52347e24a0b3968bcf645fd47c4fc5b768dc7 Signed-off-by: zhongjun <zhong.jun@zte.com.cn>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_get_conf.py65
1 files changed, 34 insertions, 31 deletions
diff --git a/tests/unit/test_get_conf.py b/tests/unit/test_get_conf.py
index 66fb2261..10b040aa 100644
--- a/tests/unit/test_get_conf.py
+++ b/tests/unit/test_get_conf.py
@@ -10,6 +10,8 @@
import os
import pytest
+from deepdiff import DeepDiff
+
from deploy.get_conf import (
get_yml_para,
config
@@ -31,34 +33,35 @@ def test_get_yml_para(deploy_file):
def test_config(deploy_file, network_file):
- assert config(deploy_file, network_file) == ({'ens8': [{'ip': '', 'name': 'EXTERNAL'}],
- 'ens3': [{'ip': '', 'name': 'MANAGEMENT'},
- {'ip': '', 'name': 'PUBLICAPI'},
- {'ip': '', 'name': 'STORAGE'},
- {'ip': '', 'name': 'physnet1'}],
- 'ens9': [{'ip': '', 'name': 'HEARTBEAT'}]},
- ['computer01', 'computer02', 'controller01', 'controller02',
- 'controller03'],
- {'MANAGEMENT': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
- 'ip_ranges': [{'start': '10.20.11.3',
- 'end': '10.20.11.10'}]},
- 'STORAGE': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
- 'ip_ranges': [{'start': '10.20.11.3',
- 'end': '10.20.11.10'}]},
- 'EXTERNAL': {'cidr': '172.10.101.0/24', 'gateway': '172.10.101.1',
- 'ip_ranges': [{'start': '172.10.101.2',
- 'end': '172.10.101.20'}],
- 'network_name': 'admin_external',
- 'mapping': 'physnet1'},
- 'PUBLICAPI': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
- 'ip_ranges': [{'start': '10.20.11.3',
- 'end': '10.20.11.10'}]},
- 'physnet1': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
- 'ip_ranges': [{'start': '10.20.11.3',
- 'end': '10.20.11.10'}]},
- 'HEARTBEAT': {'cidr': '100.20.11.0/24', 'gateway': '100.20.11.1',
- 'ip_ranges': [{'start': '100.20.11.3',
- 'end': '100.20.11.10'}]}},
- '10.20.11.11', '/dev/sdb',
- {'controller01': [], 'controller02': [], 'controller03': [],
- 'computer01': [], 'computer02': []})
+ result = config(deploy_file, network_file)
+ expect = ({'ens8': [{'ip': '', 'name': 'EXTERNAL'}],
+ 'ens3': [{'ip': '', 'name': 'MANAGEMENT'},
+ {'ip': '', 'name': 'PUBLICAPI'},
+ {'ip': '', 'name': 'STORAGE'},
+ {'ip': '', 'name': 'physnet1'}],
+ 'ens9': [{'ip': '', 'name': 'HEARTBEAT'}]},
+ ['computer01', 'computer02', 'controller01', 'controller02', 'controller03'],
+ {'MANAGEMENT': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3',
+ 'end': '10.20.11.10'}]},
+ 'STORAGE': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3',
+ 'end': '10.20.11.10'}]},
+ 'EXTERNAL': {'cidr': '172.10.101.0/24', 'gateway': '172.10.101.1',
+ 'ip_ranges': [{'start': '172.10.101.2',
+ 'end': '172.10.101.20'}],
+ 'network_name': 'admin_external',
+ 'mapping': 'physnet1'},
+ 'PUBLICAPI': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3',
+ 'end': '10.20.11.10'}]},
+ 'physnet1': {'cidr': '10.20.11.0/24', 'gateway': '10.20.11.1',
+ 'ip_ranges': [{'start': '10.20.11.3',
+ 'end': '10.20.11.10'}]},
+ 'HEARTBEAT': {'cidr': '100.20.11.0/24', 'gateway': '100.20.11.1',
+ 'ip_ranges': [{'start': '100.20.11.3',
+ 'end': '100.20.11.10'}]}},
+ '10.20.11.11', '/dev/sdb',
+ {'controller01': [], 'controller02': [], 'controller03': [],
+ 'computer01': [], 'computer02': []})
+ assert DeepDiff(result, expect) == {}