Esempio n. 1
0
def test_json_diff(root):
    from batou import output
    from batou._output import TestBackend

    output.backend = TestBackend()

    p = JSONContent("target.json", 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()

    assert output.backend.output == Ellipsis(
        """\
host > MyComponent > JSONContent('work/mycomponent/target.json')
  target.json ---
  target.json +++
  target.json @@ -1,3 +1,4 @@
  target.json  {
  target.json +    "asdf": 1,
  target.json      "bsdf": 2
  target.json  }
"""
    )
Esempio n. 2
0
def test_json_diff_not_for_sensitive(output, root):
    p = JSONContent("target.json",
                    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 > JSONContent('work/mycomponent/target.json')
Not showing diff as it contains sensitive data.
""")