From a8edd5c1dadcf79b5d0212db0e73d9a7648d1b78 Mon Sep 17 00:00:00 2001 From: lemonowl Date: Fri, 13 Sep 2024 10:00:24 +0300 Subject: [PATCH] wrapper tests --- .../wrapper/smoke/doc_builder/get_context.py | 3 +- .../wrapper/smoke/doc_builder/get_version.py | 2 +- .../{iInitialize.py => initialize.py} | 0 python/wrapper/smoke/doc_builder/run_text.py | 2 +- python/wrapper/smoke/doc_builder/save_file.py | 3 + .../wrapper/smoke/doc_builder/set_property.py | 2 +- .../smoke/doc_builder_context/create_array.py | 2 +- .../smoke/doc_builder_context/create_null.py | 2 +- .../smoke/doc_builder_context/create_scope.py | 14 ++++ .../doc_builder_context/create_undefined.py | 2 +- .../smoke/doc_builder_context/get_global.py | 14 ++++ .../smoke/doc_builder_context_scope/close.py | 15 ++++ python/wrapper/smoke/doc_builder_value/get.py | 2 +- .../smoke/doc_builder_value/is_bool.py | 14 +--- .../smoke/doc_builder_value/is_double.py | 20 +++++ .../smoke/doc_builder_value/is_empty.py | 17 ++++ .../smoke/doc_builder_value/is_function.py | 17 ++++ .../wrapper/smoke/doc_builder_value/is_int.py | 18 ++++ .../smoke/doc_builder_value/is_null.py | 10 +-- .../smoke/doc_builder_value/is_object.py | 5 +- .../smoke/doc_builder_value/is_string.py | 7 +- .../smoke/doc_builder_value/is_undefined.py | 21 +++++ python/wrapper/smoke/doc_builder_value/set.py | 2 +- .../smoke/doc_builder_value/to_bool.py | 2 +- .../smoke/doc_builder_value/to_double.py | 18 ++++ .../wrapper/smoke/doc_builder_value/to_int.py | 16 ++++ .../smoke/doc_builder_context_scope_spec.rb | 9 +- .../wrapper/smoke/doc_builder_context_spec.rb | 20 ++--- python_spec/wrapper/smoke/doc_builder_spec.rb | 84 ++++++++++--------- .../wrapper/smoke/doc_builder_value_spec.rb | 81 ++++++++++-------- 30 files changed, 303 insertions(+), 121 deletions(-) rename python/wrapper/smoke/doc_builder/{iInitialize.py => initialize.py} (100%) diff --git a/python/wrapper/smoke/doc_builder/get_context.py b/python/wrapper/smoke/doc_builder/get_context.py index 0f5c95cc..5f97a443 100644 --- a/python/wrapper/smoke/doc_builder/get_context.py +++ b/python/wrapper/smoke/doc_builder/get_context.py @@ -1,6 +1,7 @@ from python.docbuilder import builder builder.CreateFile("docx") context = builder.GetContext() +scope = context.CreateScope() globalObj = context.GetGlobal() -builder.SaveFile("docx", "BaseExample.docx") +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 index 86dbaf58..e031ee61 100644 --- a/python/wrapper/smoke/doc_builder/get_version.py +++ b/python/wrapper/smoke/doc_builder/get_version.py @@ -16,5 +16,5 @@ content[0] = paragraph document.Call("InsertContent", content) -builder.SaveFile("docx", "BaseExample.docx") +builder.SaveFile("docx", "GetVersion.docx") builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder/iInitialize.py b/python/wrapper/smoke/doc_builder/initialize.py similarity index 100% rename from python/wrapper/smoke/doc_builder/iInitialize.py rename to python/wrapper/smoke/doc_builder/initialize.py diff --git a/python/wrapper/smoke/doc_builder/run_text.py b/python/wrapper/smoke/doc_builder/run_text.py index 28f9475d..8ecb3c14 100644 --- a/python/wrapper/smoke/doc_builder/run_text.py +++ b/python/wrapper/smoke/doc_builder/run_text.py @@ -5,5 +5,5 @@ oParagraph.AddText("This is a paragraph for RunText"); oDocument.Push(oParagraph); """) -builder.SaveFile("docx", "Run.docx") +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 index e69de29b..43ee908e 100644 --- a/python/wrapper/smoke/doc_builder/save_file.py +++ 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 index 40d1274a..11cf3278 100644 --- a/python/wrapper/smoke/doc_builder/set_property.py +++ b/python/wrapper/smoke/doc_builder/set_property.py @@ -17,5 +17,5 @@ content[0] = paragraph document.Call("InsertContent", content) -builder.SaveFile("docx", "ExecuteCommand.docx") +builder.SaveFile("docx", "SetProperty.docx") builder.CloseFile() diff --git a/python/wrapper/smoke/doc_builder_context/create_array.py b/python/wrapper/smoke/doc_builder_context/create_array.py index 3a21c86c..2d2e01d8 100644 --- a/python/wrapper/smoke/doc_builder_context/create_array.py +++ b/python/wrapper/smoke/doc_builder_context/create_array.py @@ -18,5 +18,5 @@ content[1] = paragraph2 document.Call('InsertContent', content) -builder.SaveFile("docx", "BaseExample.docx") +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 index d790f154..64cc101c 100644 --- a/python/wrapper/smoke/doc_builder_context/create_null.py +++ b/python/wrapper/smoke/doc_builder_context/create_null.py @@ -11,5 +11,5 @@ value = context.CreateNull() paragraph.Call("AddText", f"Value is null = {value.IsNull()}") -builder.SaveFile("docx", "BaseExample.docx") +builder.SaveFile("docx", "CreateNull.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 index e69de29b..fa7ecea1 100644 --- a/python/wrapper/smoke/doc_builder_context/create_scope.py +++ b/python/wrapper/smoke/doc_builder_context/create_scope.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +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 works") + +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 index c7a285a9..11624037 100644 --- a/python/wrapper/smoke/doc_builder_context/create_undefined.py +++ b/python/wrapper/smoke/doc_builder_context/create_undefined.py @@ -11,5 +11,5 @@ value = context.CreateUndefined() paragraph.Call("AddText", f"Value is undefined = {value.IsUndefined()}") -builder.SaveFile("docx", "BaseExample.docx") +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 index e69de29b..18ff0dd1 100644 --- a/python/wrapper/smoke/doc_builder_context/get_global.py +++ b/python/wrapper/smoke/doc_builder_context/get_global.py @@ -0,0 +1,14 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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_scope/close.py b/python/wrapper/smoke/doc_builder_context_scope/close.py index e69de29b..ce87e288 100644 --- a/python/wrapper/smoke/doc_builder_context_scope/close.py +++ 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() +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/get.py b/python/wrapper/smoke/doc_builder_value/get.py index ff874361..0c7a9f6f 100644 --- a/python/wrapper/smoke/doc_builder_value/get.py +++ b/python/wrapper/smoke/doc_builder_value/get.py @@ -15,5 +15,5 @@ paragraph.Call("AddLineBreak") paragraph.Call("AddText", f"Comment text is {comments.Get(0).Call("GetText").ToString()}") -builder.SaveFile("docx", "IsArray.docx") +builder.SaveFile("docx", "Get.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 index 6cf9a44f..1795ff62 100644 --- a/python/wrapper/smoke/doc_builder_value/is_bool.py +++ b/python/wrapper/smoke/doc_builder_value/is_bool.py @@ -8,16 +8,10 @@ document = api.Call("GetDocument") paragraph = document.Call("GetElement", 0) -paragraph.Call("AddText", "Some text") -paragraph.Call("AddComment", "Comment one", "John", "uid-1") - -comments = document.Call("GetAllComments") -text = comments[0].Call("GetText") -delete = comments[0].Call("Delete") -paragraph.Call("AddLineBreak") -paragraph.Call("AddText", f"Text IsBool = {text.IsBool()}") +track_revisions = document.Call("IsTrackRevisions") +paragraph.Call("AddText", f"Paragraph is bool = {paragraph.IsBool()}") paragraph.Call("AddLineBreak") -paragraph.Call("AddText", f"Delete result IsBool = {delete.IsBool()}") +paragraph.Call("AddText", f"IsTrackRevisions is bool = {track_revisions.IsBool()}") -builder.SaveFile("docx", "IsArray.docx") +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 index e69de29b..0f989c34 100644 --- a/python/wrapper/smoke/doc_builder_value/is_double.py +++ b/python/wrapper/smoke/doc_builder_value/is_double.py @@ -0,0 +1,20 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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 index e69de29b..768d6020 100644 --- a/python/wrapper/smoke/doc_builder_value/is_empty.py +++ b/python/wrapper/smoke/doc_builder_value/is_empty.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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 index e69de29b..5d60a340 100644 --- a/python/wrapper/smoke/doc_builder_value/is_function.py +++ b/python/wrapper/smoke/doc_builder_value/is_function.py @@ -0,0 +1,17 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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 index e69de29b..aa438cf4 100644 --- a/python/wrapper/smoke/doc_builder_value/is_int.py +++ b/python/wrapper/smoke/doc_builder_value/is_int.py @@ -0,0 +1,18 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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 index c58650f4..af45cd02 100644 --- a/python/wrapper/smoke/doc_builder_value/is_null.py +++ b/python/wrapper/smoke/doc_builder_value/is_null.py @@ -8,11 +8,11 @@ document = api.Call("GetDocument") paragraph = document.Call("GetElement", 0) -value1 = context.CreateNull() -value2 = context.CreateObject() -paragraph.Call("AddText", f"Value 1 is null = {value.IsNull()}") +text = paragraph.Call("GetText") +style = paragraph.Call("GetStyle") +paragraph.Call("AddText", f"Text is null = {text.IsNull()}") paragraph.Call("AddLineBreak") -paragraph.Call("AddText", f"Value 2 is null = {value.IsNull()}") +paragraph.Call("AddText", f"Style is null = {style.IsNull()}") -builder.SaveFile("docx", "BaseExample.docx") +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 index 21ecb671..b3e52f04 100644 --- a/python/wrapper/smoke/doc_builder_value/is_object.py +++ b/python/wrapper/smoke/doc_builder_value/is_object.py @@ -8,7 +8,10 @@ document = api.Call("GetDocument") paragraph = document.Call("GetElement", 0) -paragraph.Call("AddText", f"Global API is object = {api.IsObject()}") +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 index 253a0364..640cf1f8 100644 --- a/python/wrapper/smoke/doc_builder_value/is_string.py +++ b/python/wrapper/smoke/doc_builder_value/is_string.py @@ -8,10 +8,11 @@ document = api.Call("GetDocument") paragraph = document.Call("GetElement", 0) -paragraph.Call("AddText", "This is IsString method check") +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'GetText is string = {paragraph.Call("GetText").IsString()}') -paragraph.Call("GetText") +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 index e69de29b..fa3c146e 100644 --- a/python/wrapper/smoke/doc_builder_value/is_undefined.py +++ b/python/wrapper/smoke/doc_builder_value/is_undefined.py @@ -0,0 +1,21 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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 index 0339cf35..f5b3aca7 100644 --- a/python/wrapper/smoke/doc_builder_value/set.py +++ b/python/wrapper/smoke/doc_builder_value/set.py @@ -17,5 +17,5 @@ content.Set(2, paragraph2) document.Call('InsertContent', content) -builder.SaveFile("docx", "BaseExample.docx") +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 index b3c7732b..76c4efcc 100644 --- a/python/wrapper/smoke/doc_builder_value/to_bool.py +++ b/python/wrapper/smoke/doc_builder_value/to_bool.py @@ -16,5 +16,5 @@ paragraph.Call("AddLineBreak") paragraph.Call("AddText", f"Delete result = {delete.ToBool()}") -builder.SaveFile("docx", "IsArray.docx") +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 index e69de29b..6db246ef 100644 --- a/python/wrapper/smoke/doc_builder_value/to_double.py +++ b/python/wrapper/smoke/doc_builder_value/to_double.py @@ -0,0 +1,18 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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 index e69de29b..18ae8d21 100644 --- a/python/wrapper/smoke/doc_builder_value/to_int.py +++ b/python/wrapper/smoke/doc_builder_value/to_int.py @@ -0,0 +1,16 @@ +from python.docbuilder import builder +builder.CreateFile("docx") + +context = builder.GetContext() +scope = context.CreateScope() +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_spec/wrapper/smoke/doc_builder_context_scope_spec.rb b/python_spec/wrapper/smoke/doc_builder_context_scope_spec.rb index ba1eb0a8..d1da9bc8 100644 --- a/python_spec/wrapper/smoke/doc_builder_context_scope_spec.rb +++ b/python_spec/wrapper/smoke/doc_builder_context_scope_spec.rb @@ -2,8 +2,9 @@ require_relative '../../spec_helper' describe 'CDocBuilderContextScope tests', :critical do - # it "CDocBuilderContextScope | Close method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_context_scope/close.py') - # expect('').to eq('') - # end + it 'CDocBuilderContextScope | Close method' do + temp_script_data = builder.change_output_file('python/wrapper/smoke/doc_builder_context_scope/close.py') + 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/python_spec/wrapper/smoke/doc_builder_context_spec.rb b/python_spec/wrapper/smoke/doc_builder_context_spec.rb index e452bf2b..ca4d4b98 100644 --- a/python_spec/wrapper/smoke/doc_builder_context_spec.rb +++ b/python_spec/wrapper/smoke/doc_builder_context_spec.rb @@ -10,7 +10,7 @@ it 'CDocBuilderContext | CreateNull method' do docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_null.py') - expect(docx.elements[0].nonempty_runs[0].text).to eq('Value is null = True') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Value is null = True') end # it 'CDocBuilderContext | CreateObject method' do @@ -18,20 +18,20 @@ # expect('').to eq('') # end - # it 'CDocBuilderContext | CreateScope method' do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_scope.py') - # expect('').to eq('') - # end + it 'CDocBuilderContext | CreateScope method' do + docx = 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 works") + end it 'CDocBuilderContext | CreateUndefined method' do docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_context/create_undefined.py') - expect(docx.elements[0].nonempty_runs[0].text).to eq('Value is undefined = True') + expect(docx.elements.first.nonempty_runs.first.text).to eq('Value is undefined = True') end - # it 'CDocBuilderContext | GetGlobal method' do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_context/get_global.py') - # expect('').to eq('') - # end + it 'CDocBuilderContext | GetGlobal method' do + docx = 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 # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_context/is_error.py') diff --git a/python_spec/wrapper/smoke/doc_builder_spec.rb b/python_spec/wrapper/smoke/doc_builder_spec.rb index 0f9c606c..7572bbfe 100644 --- a/python_spec/wrapper/smoke/doc_builder_spec.rb +++ b/python_spec/wrapper/smoke/doc_builder_spec.rb @@ -2,82 +2,84 @@ require_relative '../../spec_helper' describe 'CDocBuilder tests', :critical do - # it "CDocBuilder | CreateFile method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # it 'CDocBuilder | CreateFile method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/create_file.py') # end - it "CDocBuilder | OpenFile method" do + it 'CDocBuilder | OpenFile method' do docx = 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 - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') - # end + it 'CDocBuilder | SaveFile method' do + temp_script_data = builder.change_output_file('python/wrapper/smoke/doc_builder/save_file.py') + builder.build(temp_script_data[:temp_script_file].path) + expect(File.exist?(temp_script_data[:output_file])).to be(true) + end - # it "CDocBuilder | CloseFile method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # it 'CDocBuilder | CloseFile method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/close_file.py') # end - - # it "CDocBuilder | Initialize method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # + # it 'CDocBuilder | Initialize method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/initialize.py') # end - - # it "CDocBuilder | Dispose method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # + # it 'CDocBuilder | Dispose method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/dispose.py') # end - - # it "CDocBuilder | IsSaveWithDoctrendererMode method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # + # it 'CDocBuilder | IsSaveWithDoctrendererMode method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/is_save_with_doctrenderer_mode.py') # end - - # it "CDocBuilder | SetTmpFolder method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # + # it 'CDocBuilder | SetTmpFolder method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/set_tmp_folder.py') # end - it "CDocBuilder | ExecuteCommand method" do + it 'CDocBuilder | ExecuteCommand method' do docx = 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 - # it "CDocBuilder | GetContext method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') + # it 'CDocBuilder | GetContext method' do + # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/get_context.py') # expect().to eq() # end - it "CDocBuilder | GetVersion method" do + it 'CDocBuilder | GetVersion method' do docx = 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 + it 'CDocBuilder | Run method' do docx = 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 + it 'CDocBuilder | RunText method' do docx = 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 - it "CDocBuilder | SetProperty method" do + it 'CDocBuilder | SetProperty method' do docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/set_property.py') - expect(docx.elements.first.nonempty_runs.first.text).not_to eq('') + 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 - # 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 - # builder.build('tmp/write_data.py20240902-114437-ks391u.py') - # File.exist?output_path - # 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 + builder.build(temp_script_file.path) + expect(File.exist?(output_path)).to be(true) + end it 'CDocBuilder | Base script example' do docx = builder.build_and_parse('python/wrapper/smoke/doc_builder/base_example.py') diff --git a/python_spec/wrapper/smoke/doc_builder_value_spec.rb b/python_spec/wrapper/smoke/doc_builder_value_spec.rb index 3c352c80..1f485656 100644 --- a/python_spec/wrapper/smoke/doc_builder_value_spec.rb +++ b/python_spec/wrapper/smoke/doc_builder_value_spec.rb @@ -37,50 +37,57 @@ it 'CDocBuilderValue | IsBool method' do skip 'https://bugzilla.onlyoffice.com/show_bug.cgi?id=70046' docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_bool.py') - expect(docx.elements.first.nonempty_runs[4].text).to eq('Text IsBool = False') - expect(docx.elements.first.nonempty_runs[6].text).to eq('Delete result IsBool = True') - + expect(docx.elements.first.nonempty_runs[0].text).to eq('Text IsBool = False') + expect(docx.elements.first.nonempty_runs[2].text).to eq('Delete result IsBool = True') end - # it "CDocBuilderValue | IsDouble method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_double.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | IsDouble method' do + docx = 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 - # it "CDocBuilderValue | IsEmpty method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_empty.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | IsEmpty method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_function.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | IsFunction method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_int.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | IsInt method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_null.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | IsNull method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_object.py') - expect(docx.elements.first.nonempty_runs.first.text).to eq('Global API is object = True') + 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_string.py') - expect(docx.elements.first.nonempty_runs[2].text).to eq('GetText is string = True') + 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/is_undefined.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | IsUndefined method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/set.py') @@ -93,15 +100,15 @@ expect(docx.elements.first.nonempty_runs[2].text).to eq('Delete result = True') end - # it "CDocBuilderValue | ToDouble method" do - # docx = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_double.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | ToDouble method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_int.py') - # expect('').to eq('') - # end + it 'CDocBuilderValue | ToInt method' do + docx = 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 = builder.build_and_parse('python/wrapper/smoke/doc_builder_value/to_string.py')