def test_module_pass_when_required_args_present(self): ''' required arguments are present ''' with pytest.raises(AnsibleExitJson) as exc: set_module_args(self.set_default_args_pass_check()) pool_module() exit_json(changed=True, msg="Induced arguments check") print('Info: test_module_pass_when_required_args_present: %s' % exc.value.args[0]['msg']) assert exc.value.args[0]['changed']
def test_delete_aws_netapp_cvs_pool_fail(self, get_delete_api, get_aws_api): set_module_args(self.set_args_delete_aws_netapp_cvs_pool()) my_obj = pool_module() my_pool = { "name": "Dummyname", "poolId": "1f63b3d0-4fd4-b4fe-1ed6-c62f5f20d975", "region": "us-east-1", "serviceLevel": "extreme", "sizeInBytes": 40000000000000000, "state": "available", "vendorID": "Dummy" } get_delete_api.return_value = my_pool, "Error" get_aws_api.return_value = my_pool with pytest.raises(AnsibleFailJson) as exc: my_obj.apply() print('Info: test_delete_aws_netapp_cvs_pool_fail: %s' % repr(exc.value)) assert exc.value.args[0]['msg'] is not None
def test_create_aws_netapp_cvs_pool_pass(self, get_post_api, get_aws_api): set_module_args(self.set_args_create_aws_netapp_cvs_pool()) my_obj = pool_module() my_pool = { "name": "Dummyname", "poolId": "1f63b3d0-4fd4-b4fe-1ed6-c62f5f20d975", "region": "us-east-1", "serviceLevel": "extreme", "sizeInBytes": 40000000000000000, "state": "available", "vendorID": "Dummy" } get_aws_api.return_value = None get_post_api.return_value = None, None with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() print('Info: test_create_aws_netapp_cvs_pool_pass: %s' % repr(exc.value)) assert exc.value.args[0]['changed']
def test_module_fail_when_required_args_missing(self): ''' required arguments are reported as errors ''' with pytest.raises(AnsibleFailJson) as exc: set_module_args(self.set_default_args_fail_check()) pool_module() print('Info: test_module_fail_when_required_args_missing: %s' % exc.value.args[0]['msg'])