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()) grid_account_module() print("Info: test_module_fail_when_required_args_missing: %s" % exc.value.args[0]["msg"])
def test_module_fail_when_required_args_present(self): """ required arguments are reported as errors """ with pytest.raises(AnsibleExitJson) as exc: set_module_args(self.set_default_args_pass_check()) grid_account_module() exit_json(changed=True, msg="Induced arguments check") print("Info: test_module_fail_when_required_args_present: %s" % exc.value.args[0]["msg"]) assert exc.value.args[0]["changed"]
def test_idempotent_create_na_sg_grid_account_pass(self, mock_request): set_module_args(self.set_args_create_na_sg_grid_account()) my_obj = grid_account_module() mock_request.side_effect = [ SRR["grid_accounts"], # get id SRR["grid_account_record"], # get account SRR["end_of_sequence"], ] with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() print("Info: test_idempotent_create_na_sg_tenant_account_pass: %s" % repr(exc.value.args[0])) assert not exc.value.args[0]["changed"]
def test_update_na_sg_grid_account_pass(self, mock_request): args = self.set_args_create_na_sg_grid_account() args["quota_size"] = 10 set_module_args(args) my_obj = grid_account_module() mock_request.side_effect = [ SRR["grid_accounts"], # get SRR["grid_account_record"], # get SRR["grid_account_record_with_quota"], # put SRR["end_of_sequence"], ] with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() print("Info: test_update_na_sg_tenant_account_pass: %s" % repr(exc.value.args[0])) assert exc.value.args[0]["changed"]
def test_set_na_sg_grid_account_root_password_pass(self, mock_request): args = self.set_args_create_na_sg_grid_account() args["update_password"] = "******" set_module_args(args) my_obj = grid_account_module() mock_request.side_effect = [ SRR["grid_accounts"], # get id SRR["grid_account_record"], # get account SRR["pw_change_good"], # post SRR["end_of_sequence"], ] with pytest.raises(AnsibleExitJson) as exc: my_obj.apply() print("Info: test_set_na_sg_grid_account_root_password_pass: %s" % repr(exc.value.args[0])) assert exc.value.args[0]["changed"]