diff options
author | Alex Yang <yangyang1@zte.com.cn> | 2017-09-16 16:58:18 +0800 |
---|---|---|
committer | Alex Yang <yangyang1@zte.com.cn> | 2017-09-18 14:44:28 +0800 |
commit | 861bb6490d9ee9ddf79cdfce7fe677381ea9c945 (patch) | |
tree | f9dbfe3350be29694f0eaf70c0f7d2b05be9102c /tests/unit/config/test_schemas.py | |
parent | 8ec26b129c0543896cd65af6dd5d33529f56fd24 (diff) |
Some optimizations about unit test
Remove some "if/else".
Rename a variables and a file.
Split a testcase in two cases.
Change-Id: Ic107845ac8eff41ba20e1501c93925586d6cbde9
Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'tests/unit/config/test_schemas.py')
-rw-r--r-- | tests/unit/config/test_schemas.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/tests/unit/config/test_schemas.py b/tests/unit/config/test_schemas.py index 7c7dab28..97bff208 100644 --- a/tests/unit/config/test_schemas.py +++ b/tests/unit/config/test_schemas.py @@ -21,16 +21,11 @@ def conf_file_dir(data_root): return os.path.join(data_root, 'lab_conf') -@pytest.mark.parametrize('deploy_file_name', [ - ('deploy_virtual1.yml'), - ('deploy_virtual_error.yml'), - ('deploy_baremetal.yml')]) -def test_deploy_schema_validate(conf_file_dir, deploy_file_name): +@pytest.mark.parametrize('deploy_file_name, tell_result', [ + ('deploy_virtual1.yml', lambda x: x == []), + ('deploy_virtual_error.yml', lambda x: x != []), + ('deploy_baremetal.yml', lambda x: x == [])]) +def test_deploy_schema_validate(conf_file_dir, deploy_file_name, tell_result): data = yaml.safe_load(open(os.path.join(conf_file_dir, deploy_file_name), 'r')) errors = deploy_schema_validate(data) - if deploy_file_name == 'deploy_virtual1.yml': - assert errors == [] - elif deploy_file_name == 'deploy_virtual_error.yml': - assert errors != [] - elif deploy_file_name == 'deploy_baremetal.yml': - assert errors == [] + assert tell_result(errors) |