diff --git a/tests/main.py b/tests/main.py new file mode 100644 index 0000000..adae5ee --- /dev/null +++ b/tests/main.py @@ -0,0 +1,21 @@ +from docxtpl.__main__ import main +import sys +from pathlib import Path + +TEMPLATE_PATH = 'templates/template_for_main_test.docx' +JSON_PATH = 'templates/json_for_main_test.json' +OUTPUT_FILENAME = 'output/output_for_main_test.docx' +OVERWRITE = '-o' + + +# Simulate command line arguments, running with overwrite flag so test can be +# run repeatedly without need for confirmation: +sys.argv[1:] = [TEMPLATE_PATH, JSON_PATH, OUTPUT_FILENAME, OVERWRITE] + +main() + +output_path = Path(OUTPUT_FILENAME) + +if output_path.exists(): + print(f'File {output_path.resolve()} exists.') + diff --git a/tests/templates/json_for_main_test.json b/tests/templates/json_for_main_test.json new file mode 100644 index 0000000..535e175 --- /dev/null +++ b/tests/templates/json_for_main_test.json @@ -0,0 +1,8 @@ +{"json_dict_var" : {"json_dict_var":"successfully inserted"}, +"json_array_var": ["json","array","var","successfully", "inserted"], +"json_string_var":"json_string_var successfully inserted", +"json_int_var":123, +"json_float_var":1.234, +"json_true_var":true, +"json_false_var":false, +"json_none_var":null} \ No newline at end of file diff --git a/tests/templates/template_for_main_test.docx b/tests/templates/template_for_main_test.docx new file mode 100644 index 0000000..88b6250 Binary files /dev/null and b/tests/templates/template_for_main_test.docx differ