Esempio n. 1
0
 def test_empty(self):
     set_module_args(
         data={},
     )
     with pytest.raises(AnsibleExitJson) as context:
         flatten_nested_dict.main()
     assert context.value.args[0] == {"data": [], "changed": False}
Esempio n. 2
0
 def test_min(self):
     set_module_args(
         # just a file that exists on almost any platform
         config={
             "regexes": [{
                 "regex": "127.0.0.1",
                 "name": "hosts"
             }],
             "patterns": {
                 "console": [{
                     "id": 1,
                     "logstash": "",
                     "msg": "Overcloud stack installation: SUCCESS.",
                     "pattern": "Stack overcloud CREATE_COMPLETE",
                     "tag": "info",
                 }]
             },
         },
         files={"console": "/etc/hosts"},
     )
     with pytest.raises(AnsibleExitJson) as context:
         sova.main()
     assert context.value.args[0]["changed"] is True
     assert context.value.args[0]["processed_files"] == ["/etc/hosts"]
     assert "message" in context.value.args[0]
     assert context.value.args[0]["tags"] == []
Esempio n. 3
0
 def test_invalid_args(self):
     set_module_args(
         data="invalid",
     )
     with pytest.raises(AnsibleFailJson) as context:
         flatten_nested_dict.main()
     assert context.value.args[0]["failed"] is True
     assert "msg" in context.value.args[0]
Esempio n. 4
0
 def test_one(self):
     set_module_args(data=yaml.safe_load(SAMPLE_INPUT_1)["data"])
     with pytest.raises(AnsibleExitJson) as context:
         flatten_nested_dict.main()
     assert context.value.args[0]["changed"] is False
     assert context.value.args[0]["data"] == yaml.safe_load(SAMPLE_OUTPUT_1)["data"]