예제 #1
0
파일: test_file.py 프로젝트: admdev8/batou
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  }
"""
    )
예제 #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.
""")