Esempio n. 1
0
def test_output_to_file(tmpdir, main_mocks):
    outfile = str(tmpdir / "output_file.txt")
    main(["infile.txt", outfile])

    main_mocks.file_loader_type.assert_called_once_with(path=["."], force_mode=None)
    main_mocks.import_.assert_called_once_with("infile.txt")
    main_mocks.template_type.assert_called_once_with({})
    main_mocks.render.assert_called_once_with()

    with open(outfile, "r") as f:
        assert f.read() == "render result"
Esempio n. 2
0
def test_template_variables(main_mocks):
    main(["-v", "foo=bar", "-v", "baz=bip", "infile.txt"])

    main_mocks.file_loader_type.assert_called_once_with(path=["."], force_mode=None)
    main_mocks.import_.assert_called_once_with("infile.txt")
    main_mocks.template_type.assert_called_once_with(
        {
            "foo": "bar",
            "baz": "bip",
        }
    )
    main_mocks.render.assert_called_once_with()