コード例 #1
0
def test_yaml_diff(root):
    from batou import output
    from batou._output import TestBackend

    output.backend = TestBackend()

    p = YAMLContent("target.yaml", data={"asdf": 1, "bsdf": 2})
    root.component += p

    with open(p.path, "w") as f:
        assert f.write(json.dumps({"bsdf": 2}, sort_keys=True, indent=4))

    p.deploy()

    # fmt: off
    assert output.backend.output == Ellipsis("""\
host > MyComponent > YAMLContent(\'work/mycomponent/target.yaml\')
  target.yaml ---
  target.yaml +++
  target.yaml @@ -1,3 +1,2 @@
  target.yaml -{
  target.yaml -    "bsdf": 2
  target.yaml -}
  target.yaml +asdf: 1
  target.yaml +bsdf: 2
""")
コード例 #2
0
def test_yaml_diff_not_for_sensitive(output, root):
    p = YAMLContent("target.yaml",
                    data={
                        "asdf": 1,
                        "bsdf": 2
                    },
                    sensitive_data=True)
    root.component += p

    with open(p.path, "w") as f:
        assert f.write(json.dumps({"bsdf": 2}, sort_keys=True, indent=4))

    p.deploy()

    assert output.backend.output == Ellipsis("""\
host > MyComponent > YAMLContent('work/mycomponent/target.yaml')
Not showing diff as it contains sensitive data.
""")