diff --git a/.gitignore b/.gitignore index 062294c8..ea472cef 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ doc # other .vscode +__pycache__ diff --git a/Rakefile b/Rakefile index 29d9992c..bb77c527 100644 --- a/Rakefile +++ b/Rakefile @@ -30,8 +30,3 @@ desc 'run project spec' task :project_spec do system('bundle exec parallel_rspec project_spec') end - -desc 'run python spec' -task :python_spec do - system('bundle exec parallel_rspec python_spec') -end diff --git a/assets/python_wrapper_test_files/OpenFile.docx b/assets/python_wrapper_test_files/OpenFile.docx new file mode 100644 index 00000000..a036c724 Binary files /dev/null and b/assets/python_wrapper_test_files/OpenFile.docx differ diff --git a/assets/python_wrapper_test_files/run.docbuilder b/assets/python_wrapper_test_files/run.docbuilder new file mode 100644 index 00000000..eae51572 --- /dev/null +++ b/assets/python_wrapper_test_files/run.docbuilder @@ -0,0 +1,4 @@ +var oDocument = Api.GetDocument(); +var oParagraph = Api.CreateParagraph(); +oParagraph.AddText("This is a paragraph for Run"); +oDocument.Push(oParagraph); diff --git a/lib/doc_builder_testing/doc_builder_python_wrapper.rb b/lib/doc_builder_testing/doc_builder_python_wrapper.rb index 9604173a..0f02973a 100644 --- a/lib/doc_builder_testing/doc_builder_python_wrapper.rb +++ b/lib/doc_builder_testing/doc_builder_python_wrapper.rb @@ -27,8 +27,7 @@ def build(script_file) # Build document and parse it # @param script_file [String] path to script file - # @return [OoxmlParser::CommonDocumentStructure] parsed file if file is Ooxml - # @return [OnlyofficePdfParser::PdfStructure] parsed structure if file is PDF + # @return [OnlyofficePdfParser::PdfStructure, OoxmlParser::Parser, nil] parsed file if file is Ooxml or structure if file is PDF def build_and_parse(script_file) temp_script_data = build_file(script_file) parse(temp_script_data) diff --git a/python/docx/smoke/api/script.py b/python/wrapper/smoke/doc_builder/base_example.py similarity index 86% rename from python/docx/smoke/api/script.py rename to python/wrapper/smoke/doc_builder/base_example.py index 6d8133fc..fe5d5d83 100644 --- a/python/docx/smoke/api/script.py +++ b/python/wrapper/smoke/doc_builder/base_example.py @@ -2,7 +2,6 @@ builder.CreateFile("docx") context = builder.GetContext() -scope = context.CreateScope() globalObj = context.GetGlobal() api = globalObj["Api"] @@ -13,7 +12,7 @@ content = context.CreateArray(1) content[0] = paragraph - document.Call("InsertContent", content) -builder.SaveFile("docx", "result.docx") + +builder.SaveFile("docx", "BaseExample.docx") builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/execute_command.py b/python/wrapper/smoke/doc_builder/execute_command.py new file mode 100644 index 00000000..c5518b36 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/execute_command.py @@ -0,0 +1,19 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +builder.ExecuteCommand('Argument = {"some key": "Some ExecuteCommand value"}') +document = api.Call("GetDocument") +paragraph = api.Call("CreateParagraph") +argument = globalObj['Argument'] +paragraph.Call("AddText", argument["some key"].ToString()) + +content = context.CreateArray(1) +content[0] = paragraph +document.Call("InsertContent", content) + +builder.SaveFile("docx", "ExecuteCommand.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/get_context.py b/python/wrapper/smoke/doc_builder/get_context.py new file mode 100644 index 00000000..d3607882 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/get_context.py @@ -0,0 +1,13 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", "If this paragraph is here, GetContext works") + +builder.SaveFile("docx", "GetContext.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/get_version.py b/python/wrapper/smoke/doc_builder/get_version.py new file mode 100644 index 00000000..ce80c7b8 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/get_version.py @@ -0,0 +1,19 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +version = builder.GetVersion() +document = api.Call("GetDocument") +paragraph = api.Call("CreateParagraph") +paragraph.Call("SetSpacingAfter", 1000, False) +paragraph.Call("AddText", version.decode()) + +content = context.CreateArray(1) +content[0] = paragraph +document.Call("InsertContent", content) + +builder.SaveFile("docx", "GetVersion.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/is_save_with_doctrenderer_mode.py b/python/wrapper/smoke/doc_builder/is_save_with_doctrenderer_mode.py new file mode 100644 index 00000000..4895a913 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/is_save_with_doctrenderer_mode.py @@ -0,0 +1,15 @@ +import json +from python.docbuilder import builder +builder.SetProperty('--use-doctrenderer-scheme', 'true') +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", f"IsSaveWithDoctrendererMode = {builder.IsSaveWithDoctrendererMode()}") + +builder.SaveFile("docx", "IsSaveWithDoctrendererMode.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/open_file.py b/python/wrapper/smoke/doc_builder/open_file.py new file mode 100644 index 00000000..6b652965 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/open_file.py @@ -0,0 +1,5 @@ +from python.docbuilder import builder +builder.OpenFile("assets/python_wrapper_test_files/OpenFile.docx", + "464") +builder.SaveFile("docx", "OpenFile.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/run.py b/python/wrapper/smoke/doc_builder/run.py new file mode 100644 index 00000000..d34be168 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/run.py @@ -0,0 +1,5 @@ +from python.docbuilder import builder +builder.CreateFile("docx") +builder.Run("assets/python_wrapper_test_files/run.docbuilder") +builder.SaveFile("docx", "Run.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/run_text.py b/python/wrapper/smoke/doc_builder/run_text.py new file mode 100644 index 00000000..e516ffb3 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/run_text.py @@ -0,0 +1,10 @@ +from python.docbuilder import builder +builder.CreateFile("docx") +builder.RunText(""" +var oDocument = Api.GetDocument(); +var oParagraph = Api.CreateParagraph(); +oParagraph.AddText("This is a paragraph for RunText"); +oDocument.Push(oParagraph); +""") +builder.SaveFile("docx", "RunText.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/save_file.py b/python/wrapper/smoke/doc_builder/save_file.py new file mode 100644 index 00000000..43ee908e --- /dev/null +++ b/python/wrapper/smoke/doc_builder/save_file.py @@ -0,0 +1,3 @@ +from python.docbuilder import builder +builder.CreateFile("docx") +builder.SaveFile("docx", "SaveFile.docx") diff --git a/python/wrapper/smoke/doc_builder/set_property.py b/python/wrapper/smoke/doc_builder/set_property.py new file mode 100644 index 00000000..f3dd3c28 --- /dev/null +++ b/python/wrapper/smoke/doc_builder/set_property.py @@ -0,0 +1,20 @@ +import json +from python.docbuilder import builder +builder.SetProperty("--argument", json.dumps({"some key": "Some SetProperty value"})) +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = api.Call("CreateParagraph") +argument = globalObj['Argument'] +paragraph.Call("AddText", argument["some key"].ToString()) + +content = context.CreateArray(1) +content[0] = paragraph +document.Call("InsertContent", content) + +builder.SaveFile("docx", "SetProperty.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/set_tmp_folder.py b/python/wrapper/smoke/doc_builder/set_tmp_folder.py new file mode 100644 index 00000000..93218f2d --- /dev/null +++ b/python/wrapper/smoke/doc_builder/set_tmp_folder.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder + +builder.SetTmpFolder("/tmp/folder") +builder.CreateFile("docx") + +context = builder.GetContext(False) +scope = context.CreateScope() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = api.Call("CreateParagraph") +scope.Close() +paragraph.Call("AddText", "Hello, World!") diff --git a/python/wrapper/smoke/doc_builder/write_data.py b/python/wrapper/smoke/doc_builder/write_data.py new file mode 100644 index 00000000..9f4b24bd --- /dev/null +++ b/python/wrapper/smoke/doc_builder/write_data.py @@ -0,0 +1,2 @@ +from python.docbuilder import builder +builder.WriteData("WriteData.log", "Check", False) diff --git a/python/wrapper/smoke/doc_builder_context/create_array.py b/python/wrapper/smoke/doc_builder_context/create_array.py new file mode 100644 index 00000000..e1d5f30e --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/create_array.py @@ -0,0 +1,21 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call('GetDocument') +paragraph1 = api.Call('CreateParagraph') +paragraph1.Call('SetSpacingAfter', 1000, False) +paragraph1.Call('AddText', 'CreateArray') +paragraph2 = api.Call('CreateParagraph') +paragraph2.Call('AddText', 'test') + +content = context.CreateArray(2) +content[0] = paragraph1 +content[1] = paragraph2 +document.Call('InsertContent', content) + +builder.SaveFile("docx", "CreateArray.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/create_null.py b/python/wrapper/smoke/doc_builder_context/create_null.py new file mode 100644 index 00000000..9351cd73 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/create_null.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +value = context.CreateNull() +paragraph.Call("AddText", f"Value is null = {value.IsNull()}") + +builder.SaveFile("docx", "CreateNull.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/create_object.py b/python/wrapper/smoke/doc_builder_context/create_object.py new file mode 100644 index 00000000..44ddc218 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/create_object.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +value = context.CreateObject() +paragraph.Call("AddText", f"Value is object = {value.IsObject()}") + +builder.SaveFile("docx", "CreateObject.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/create_scope.py b/python/wrapper/smoke/doc_builder_context/create_scope.py new file mode 100644 index 00000000..8cbb90f1 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/create_scope.py @@ -0,0 +1,15 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext(False) +scope = context.CreateScope() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", "Without CreateScope script doesn't work") + +scope.Close() +builder.SaveFile("docx", "CreateScope.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/create_undefined.py b/python/wrapper/smoke/doc_builder_context/create_undefined.py new file mode 100644 index 00000000..199f7946 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/create_undefined.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +value = context.CreateUndefined() +paragraph.Call("AddText", f"Value is undefined = {value.IsUndefined()}") + +builder.SaveFile("docx", "CreateUndefined.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/get_global.py b/python/wrapper/smoke/doc_builder_context/get_global.py new file mode 100644 index 00000000..8ed23357 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/get_global.py @@ -0,0 +1,13 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", "If this paragraph is here, GetGlobal works") + +builder.SaveFile("docx", "GetGlobal.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/is_error.py b/python/wrapper/smoke/doc_builder_context/is_error.py new file mode 100644 index 00000000..f8d06b0f --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context/is_error.py @@ -0,0 +1,8 @@ +from python.docbuilder import builder +builder.CreateFile("docx") +result = builder.RunText(""" +var oDocument = Api.GetDocument(); +var oParagraph = Api.GetParagraph(0); +""") +builder.SaveFile("docx", "IsError.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context_scope/close.py b/python/wrapper/smoke/doc_builder_context_scope/close.py new file mode 100644 index 00000000..b4fe72a3 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_context_scope/close.py @@ -0,0 +1,15 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext(False) +scope = context.CreateScope() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +scope.Close() +paragraph.Call("AddText", "Without created scope script doesn't works") + +builder.SaveFile("docx", "Close.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/call.py b/python/wrapper/smoke/doc_builder_value/call.py new file mode 100644 index 00000000..0b1e34f6 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/call.py @@ -0,0 +1,13 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", "This is Call method check") + +builder.SaveFile("docx", "Call.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/clear.py b/python/wrapper/smoke/doc_builder_value/clear.py new file mode 100644 index 00000000..431068af --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/clear.py @@ -0,0 +1,18 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +new_paragraph = api.Call("CreateParagraph") +new_paragraph.Call("AddText", "some content") +paragraph.Call("AddText", f"before clear: {new_paragraph.IsEmpty()}") +paragraph.Call("AddLineBreak") +new_paragraph.Clear() +paragraph.Call("AddText", f"after clear: {new_paragraph.IsEmpty()}") + +builder.SaveFile("docx", "Clear.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/get.py b/python/wrapper/smoke/doc_builder_value/get.py new file mode 100644 index 00000000..07cffb5e --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/get.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", "Some text for Get method") + +paragraphs = document.Call("GetAllParagraphs") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f'Text is {paragraphs.Get(0).Call("GetText").ToString()}') + +builder.SaveFile("docx", "Get.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/get_length.py b/python/wrapper/smoke/doc_builder_value/get_length.py new file mode 100644 index 00000000..4858b9e3 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/get_length.py @@ -0,0 +1,25 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +run1 = api.Call("CreateRun") +run1.Call("AddText", "First run") +paragraph.Call("AddElement", run1) +run1.Call("AddComment", "Comment one", "John", "uid-1") +paragraph.Call("AddLineBreak") +run2 = api.Call("CreateRun") +run2.Call("AddText", "Second run") +paragraph.Call("AddElement", run2) +run2.Call("AddComment", "Comment two", "Jane", "uid-2") + +comments = document.Call("GetAllComments") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"Comments GetLength = {comments.GetLength()}") + +builder.SaveFile("docx", "GetLength.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/get_property.py b/python/wrapper/smoke/doc_builder_value/get_property.py new file mode 100644 index 00000000..2b44cefb --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/get_property.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +color = context.CreateObject() +color['type'] = 'uniColor' +document.SetProperty("color", color) +color = document.GetProperty("color") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", f"Color is {color['type'].ToString()}") + +builder.SaveFile("docx", "GetProperty.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_array.py b/python/wrapper/smoke/doc_builder_value/is_array.py new file mode 100644 index 00000000..ace16792 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_array.py @@ -0,0 +1,22 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +run1 = api.Call("CreateRun") +run1.Call("AddText", "First run") +paragraph.Call("AddElement", run1) +run1.Call("AddComment", "Comment one", "John", "uid-1") + +comments = document.Call("GetAllComments") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"Comments IsArray = {comments.IsArray()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"Comment IsArray = {comments[0].IsArray()}") + +builder.SaveFile("docx", "IsArray.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_bool.py b/python/wrapper/smoke/doc_builder_value/is_bool.py new file mode 100644 index 00000000..44121f75 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_bool.py @@ -0,0 +1,16 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +track_revisions = document.Call("IsTrackRevisions") +paragraph.Call("AddText", f"Paragraph is bool = {paragraph.IsBool()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"IsTrackRevisions is bool = {track_revisions.IsBool()}") + +builder.SaveFile("docx", "IsBool.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_double.py b/python/wrapper/smoke/doc_builder_value/is_double.py new file mode 100644 index 00000000..05863774 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_double.py @@ -0,0 +1,19 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +image = api.Call("CreateImage", + "https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", + 60 * 36000, 35 * 36000) +paragraph.Call("AddDrawing", image) +paragraph.Call("AddText", f'Width is double = {image.Call("GetWidth").IsDouble()}') +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f'LockValue is double = {image.Call("GetLockValue").IsDouble()}') + +builder.SaveFile("docx", "IsDouble.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_empty.py b/python/wrapper/smoke/doc_builder_value/is_empty.py new file mode 100644 index 00000000..8f18ef31 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_empty.py @@ -0,0 +1,16 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +wrong_call = document.Call("GetElmnt", 0) +paragraph.Call("AddText", f"Right call is empty = {paragraph.IsEmpty()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"Wrong call is empty = {wrong_call.IsEmpty()}") + +builder.SaveFile("docx", "IsEmpty.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_function.py b/python/wrapper/smoke/doc_builder_value/is_function.py new file mode 100644 index 00000000..a39b01a7 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_function.py @@ -0,0 +1,16 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] +obj = globalObj['Object'] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", f'globalObj["Api"] is undefined = {api.IsFunction()}') +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f'globalObj["Object"] is undefined = {obj.IsFunction()}') + +builder.SaveFile("docx", "IsFunction.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_int.py b/python/wrapper/smoke/doc_builder_value/is_int.py new file mode 100644 index 00000000..a748a057 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_int.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +content = document.Call("GetContent") +count = document.Call("GetElementsCount") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", f"Content is int = {content.IsInt()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"ElementsCount is int = {count.IsInt()}") + +builder.SaveFile("docx", "IsInt.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_null.py b/python/wrapper/smoke/doc_builder_value/is_null.py new file mode 100644 index 00000000..39f55668 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_null.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +text = paragraph.Call("GetText") +style = paragraph.Call("GetStyle") +paragraph.Call("AddText", f"Text is null = {text.IsNull()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"Style is null = {style.IsNull()}") + +builder.SaveFile("docx", "IsNull.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_object.py b/python/wrapper/smoke/doc_builder_value/is_object.py new file mode 100644 index 00000000..3659f4e5 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_object.py @@ -0,0 +1,16 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +track_revisions = document.Call("IsTrackRevisions") +paragraph.Call("AddText", f"Paragraph is object = {paragraph.IsObject()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"IsTrackRevisions is object = {track_revisions.IsObject()}") + +builder.SaveFile("docx", "IsObject.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_string.py b/python/wrapper/smoke/doc_builder_value/is_string.py new file mode 100644 index 00000000..57d08d62 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_string.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +class_type = paragraph.Call("GetClassType") +charts = paragraph.Call("GetAllCharts") +paragraph.Call("AddText", f'ClassType is string = {class_type.IsString()}') +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f'Charts is string = {charts.IsString()}') + +builder.SaveFile("docx", "IsString.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/is_undefined.py b/python/wrapper/smoke/doc_builder_value/is_undefined.py new file mode 100644 index 00000000..74ed44fc --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/is_undefined.py @@ -0,0 +1,20 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +image = api.Call("CreateImage", + "https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", + 60 * 36000, 35 * 36000) +paragraph.Call("AddDrawing", image) +images = paragraph.Call("GetAllImages") +paragraph.Call("AddText", f"Images[0] is undefined = {images[0].IsUndefined()}") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f"Images[1] is undefined = {images[1].IsUndefined()}") + +builder.SaveFile("docx", "IsUndefined.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/set.py b/python/wrapper/smoke/doc_builder_value/set.py new file mode 100644 index 00000000..042772c3 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/set.py @@ -0,0 +1,20 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call('GetDocument') +paragraph1 = api.Call('CreateParagraph') +paragraph1.Call('AddText', 'Set') +paragraph2 = api.Call('CreateParagraph') +paragraph2.Call('AddText', 'method test') + +content = context.CreateArray(2) +content.Set(1, paragraph1) +content.Set(2, paragraph2) +document.Call('InsertContent', content) + +builder.SaveFile("docx", "Set.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/to_bool.py b/python/wrapper/smoke/doc_builder_value/to_bool.py new file mode 100644 index 00000000..5ee70f9d --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/to_bool.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +track_revisions = document.Call("IsTrackRevisions") +paragraph.Call("AddText", f"IsTrackRevisions = {track_revisions.ToBool()}") + +builder.SaveFile("docx", "ToBool.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/to_double.py b/python/wrapper/smoke/doc_builder_value/to_double.py new file mode 100644 index 00000000..60b4bc5a --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/to_double.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +image = api.Call("CreateImage", + "https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", + 60 * 36000, 35 * 36000) +paragraph.Call("AddDrawing", image) +paragraph.Call("AddText", f'Width = {image.Call("GetWidth").ToDouble()}') + +builder.SaveFile("docx", "ToDouble.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/to_int.py b/python/wrapper/smoke/doc_builder_value/to_int.py new file mode 100644 index 00000000..6c5ffd68 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/to_int.py @@ -0,0 +1,15 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +content = document.Call("GetContent") +count = document.Call("GetElementsCount") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", f"ElementsCount = {count.ToInt()}") + +builder.SaveFile("docx", "ToInt.docx") +builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_value/to_string.py b/python/wrapper/smoke/doc_builder_value/to_string.py new file mode 100644 index 00000000..1cb95918 --- /dev/null +++ b/python/wrapper/smoke/doc_builder_value/to_string.py @@ -0,0 +1,16 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +globalObj = context.GetGlobal() +api = globalObj["Api"] + +document = api.Call("GetDocument") +paragraph = document.Call("GetElement", 0) +paragraph.Call("AddText", "This is ToString method check") +paragraph.Call("AddLineBreak") +paragraph.Call("AddText", f'GetText ToString = {paragraph.Call("GetText").ToString()}') +paragraph.Call("GetText") + +builder.SaveFile("docx", "ToString.docx") +builder.CloseFile() diff --git a/python_spec/docx/smoke/api_spec.rb b/python_spec/docx/smoke/api_spec.rb deleted file mode 100644 index 0ada556d..00000000 --- a/python_spec/docx/smoke/api_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require_relative '../../spec_helper' -describe 'Api section tests', :critical do - it 'Api method' do - docx = builder.build_and_parse('python/docx/smoke/api/script.py') - expect(docx.elements.first.nonempty_runs.first.text).to eq('Hello, World!') - end -end diff --git a/python_spec/spec_helper.rb b/python_spec/spec_helper.rb deleted file mode 100644 index df5ec073..00000000 --- a/python_spec/spec_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require 'rspec' -require 'bundler/setup' -require_relative '../lib/doc_builder_testing' - -# Settings for import docbuilder.py in test scripts -ENV['PYTHONPATH'] = Dir.pwd - -# Get DocBuilderPythonWrapper -# @return [DocBuilderPythonWrapper] -def builder - @builder ||= DocBuilderPythonWrapper.new -end diff --git a/spec/python_wrapper/smoke/doc_builder_context_scope_spec.rb b/spec/python_wrapper/smoke/doc_builder_context_scope_spec.rb new file mode 100644 index 00000000..d511e834 --- /dev/null +++ b/spec/python_wrapper/smoke/doc_builder_context_scope_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' +describe 'CDocBuilderContextScope tests' do + before { skip 'incompatible changes' if builder.semver < Semantic::Version.new('8.2.0') } + + it 'CDocBuilderContextScope | Close method' do + temp_script_data = python_builder.change_output_file('python/wrapper/smoke/doc_builder_context_scope/close.py') + python_builder.build(temp_script_data[:temp_script_file].path) + expect(File.exist?(temp_script_data[:output_file])).to be(false) + end +end diff --git a/spec/python_wrapper/smoke/doc_builder_context_spec.rb b/spec/python_wrapper/smoke/doc_builder_context_spec.rb new file mode 100644 index 00000000..9d11e766 --- /dev/null +++ b/spec/python_wrapper/smoke/doc_builder_context_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' +describe 'CDocBuilderContext tests' do + before { skip 'incompatible changes' if builder.semver < Semantic::Version.new('8.2.0') } + + it 'CDocBuilderContext | CreateArray method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_array.py') + expect(docx.elements[0].nonempty_runs[0].text).to eq('CreateArray') + expect(docx.elements[1].nonempty_runs[0].text).to eq('test') + end + + it 'CDocBuilderContext | CreateNull method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_null.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Value is null = True') + end + + it 'CDocBuilderContext | CreateObject method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_object.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Value is object = True') + end + + # Creates context scope for script, at least one scope must be open + it 'CDocBuilderContext | CreateScope method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_scope.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq("Without CreateScope script doesn't work") + end + + it 'CDocBuilderContext | CreateUndefined method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_undefined.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Value is undefined = True') + end + + it 'CDocBuilderContext | GetGlobal method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_context/get_global.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('If this paragraph is here, GetGlobal works') + end + + it 'CDocBuilderContext | IsError method' do + temp_script_data = python_builder.change_output_file('python/wrapper/smoke/doc_builder_context/is_error.py') + expect { python_builder.build(temp_script_data[:temp_script_file].path) }.to raise_error(include('TypeError: Api.GetParagraph is not a function')) + end +end diff --git a/spec/python_wrapper/smoke/doc_builder_spec.rb b/spec/python_wrapper/smoke/doc_builder_spec.rb new file mode 100644 index 00000000..9492a0b9 --- /dev/null +++ b/spec/python_wrapper/smoke/doc_builder_spec.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +require 'spec_helper' +describe 'CDocBuilder tests' do + before { skip 'incompatible changes' if builder.semver < Semantic::Version.new('8.2.0') } + + it 'CDocBuilder | OpenFile method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/open_file.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('It’s-a me, Mario!') + end + + it 'CDocBuilder | SaveFile method' do + temp_script_data = python_builder.change_output_file('python/wrapper/smoke/doc_builder/save_file.py') + python_builder.build(temp_script_data[:temp_script_file].path) + expect(File.exist?(temp_script_data[:output_file])).to be(true) + end + + it 'CDocBuilder | IsSaveWithDoctrendererMode method' do + skip('https://bugzilla.onlyoffice.com/show_bug.cgi?id=70286') + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/is_save_with_doctrenderer_mode.py') + expect(docx.elements.first.nonempty_runs.first.text).to be('IsSaveWithDoctrendererMode = True') + end + + it 'CDocBuilder | SetTmpFolder method' do + script_file = 'python/wrapper/smoke/doc_builder/set_tmp_folder.py' + tmpdir = Dir.mktmpdir('tmp_folder') + expect(Dir.empty?(tmpdir)).to be(true) + script_file_content = File.read(script_file) + script_file_content.gsub!('/tmp/folder', tmpdir.to_s) + temp_script_file = Tempfile.new([File.basename(script_file), File.extname(script_file)]) + temp_script_file.write(script_file_content) + temp_script_file.close + python_builder.build(temp_script_file.path) + expect(Dir.empty?(tmpdir)).to be(false) + end + + it 'CDocBuilder | ExecuteCommand method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/execute_command.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Some ExecuteCommand value') + end + + # By default, calls CreateScope internally and creates a context + # If scope is to be created separately, the method is called with the False parameter + it 'CDocBuilder | GetContext method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/get_context.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('If this paragraph is here, GetContext works') + end + + it 'CDocBuilder | GetVersion method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/get_version.py') + expect(docx.elements.first.nonempty_runs.first.text).not_to eq('') + end + + it 'CDocBuilder | Run method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/run.py') + expect(docx.elements[1].nonempty_runs.first.text).to eq('This is a paragraph for Run') + end + + it 'CDocBuilder | RunText method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/run_text.py') + expect(docx.elements[1].nonempty_runs.first.text).to eq('This is a paragraph for RunText') + end + + # Is only applied once, before creating the document (CreateFile method) + it 'CDocBuilder | SetProperty method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/set_property.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Some SetProperty value') + end + + it 'CDocBuilder | WriteData method' do + script_file = 'python/wrapper/smoke/doc_builder/write_data.py' + script_file_content = File.read(script_file) + temp_output_file = Tempfile.new([File.basename(script_file), '.log']) + output_path = temp_output_file.path.to_s + script_file_content.gsub!('WriteData.log', output_path) + temp_output_file.close! + temp_script_file = Tempfile.new([File.basename(script_file), File.extname(script_file)]) + temp_script_file.write(script_file_content) + temp_script_file.close + python_builder.build(temp_script_file.path) + expect(File.exist?(output_path)).to be(true) + end + + it 'CDocBuilder | Base script example' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Hello, World!') + end +end diff --git a/spec/python_wrapper/smoke/doc_builder_value_spec.rb b/spec/python_wrapper/smoke/doc_builder_value_spec.rb new file mode 100644 index 00000000..6580edd9 --- /dev/null +++ b/spec/python_wrapper/smoke/doc_builder_value_spec.rb @@ -0,0 +1,120 @@ +# frozen_string_literal: true + +require 'spec_helper' +describe 'CDocBuilderValue tests' do + before { skip 'incompatible changes' if builder.semver < Semantic::Version.new('8.2.0') } + + it 'CDocBuilderValue | Call method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/call.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('This is Call method check') + end + + # Clears CDocBuilderValue object, sets empty value + it 'CDocBuilderValue | Clear method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/clear.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('before clear: False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('after clear: True') + end + + it 'CDocBuilderValue | Get method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/get.py') + expect(docx.elements.first.nonempty_runs[2].text).to eq('Text is Some text for Get method') + end + + it 'CDocBuilderValue | GetLength method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/get_length.py') + expect(docx.elements.first.nonempty_runs[8].text).to eq('Comments GetLength = 2') + end + + it 'CDocBuilderValue | GetProperty / SetProperty method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/get_property.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Color is uniColor') + end + + it 'CDocBuilderValue | IsArray method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_array.py') + expect(docx.elements.first.nonempty_runs[4].text).to eq('Comments IsArray = True') + expect(docx.elements.first.nonempty_runs[6].text).to eq('Comment IsArray = False') + end + + it 'CDocBuilderValue | IsBool method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_bool.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('Paragraph is bool = False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('IsTrackRevisions is bool = True') + end + + it 'CDocBuilderValue | IsDouble method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_double.py') + expect(docx.elements.first.nonempty_runs[1].text).to eq('Width is double = True') + expect(docx.elements.first.nonempty_runs[3].text).to eq('LockValue is double = False') + end + + # Wrapper method, CDocBuilderValue can be empty if call is incorrect or object is cleared (Clear method) + it 'CDocBuilderValue | IsEmpty method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_empty.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('Right call is empty = False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('Wrong call is empty = True') + end + + it 'CDocBuilderValue | IsFunction method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_function.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('globalObj["Api"] is undefined = False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('globalObj["Object"] is undefined = True') + end + + it 'CDocBuilderValue | IsInt method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_int.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('Content is int = False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('ElementsCount is int = True') + end + + it 'CDocBuilderValue | IsNull method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_null.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('Text is null = False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('Style is null = True') + end + + it 'CDocBuilderValue | IsObject method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_object.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('Paragraph is object = True') + expect(docx.elements.first.nonempty_runs[2].text).to eq('IsTrackRevisions is object = False') + end + + it 'CDocBuilderValue | IsString method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_string.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('ClassType is string = True') + expect(docx.elements.first.nonempty_runs[2].text).to eq('Charts is string = False') + end + + it 'CDocBuilderValue | IsUndefined method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_undefined.py') + expect(docx.elements.first.nonempty_runs[1].text).to eq('Images[0] is undefined = False') + expect(docx.elements.first.nonempty_runs[3].text).to eq('Images[1] is undefined = True') + end + + it 'CDocBuilderValue | Set method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/set.py') + expect(docx.elements[0].nonempty_runs[0].text).to eq('Set') + expect(docx.elements[1].nonempty_runs[0].text).to eq('method test') + end + + it 'CDocBuilderValue | ToBool method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_bool.py') + expect(docx.elements.first.nonempty_runs[0].text).to eq('IsTrackRevisions = False') + end + + it 'CDocBuilderValue | ToDouble method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_double.py') + expect(docx.elements.first.nonempty_runs[1].text).to eq('Width = 2160000.0') + end + + it 'CDocBuilderValue | ToInt method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_int.py') + expect(docx.elements.first.nonempty_runs.first.text).to eq('ElementsCount = 1') + end + + it 'CDocBuilderValue | ToString method' do + docx = python_builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_string.py') + expect(docx.elements.first.nonempty_runs[2].text).to eq('GetText ToString = This is ToString method check') + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 231b3155..76285184 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -30,3 +30,12 @@ def builder_platform def web_builder? builder_platform == 'WEB' end + +# Settings for import docbuilder.py in test scripts +ENV['PYTHONPATH'] = Dir.pwd + +# Get DocBuilderPythonWrapper +# @return [DocBuilderPythonWrapper] +def python_builder + @python_builder ||= DocBuilderPythonWrapper.new +end