Skip to content
Snippets Groups Projects
Commit 3438f960 authored by Marko Mecina's avatar Marko Mecina
Browse files

ask before overwriting existing automated test scripts

parent 8092701b
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
viewBox="0 0 26.510696 28.219185"
version="1.1"
id="svg5"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
sodipodi:docname="collapse.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
......@@ -26,7 +26,7 @@
showgrid="false"
inkscape:zoom="2.3786088"
inkscape:cx="183.09022"
inkscape:cy="531.82348"
inkscape:cy="61.17021"
inkscape:window-width="2560"
inkscape:window-height="1385"
inkscape:window-x="0"
......@@ -34,66 +34,43 @@
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<marker
style="overflow:visible"
id="Arrow3-7"
refX="0"
refY="0"
orient="auto-start-reverse"
inkscape:stockid="Arrow3"
markerWidth="11"
markerHeight="11"
viewBox="0 0 4.2071068 7"
inkscape:isstock="true"
inkscape:collect="always"
preserveAspectRatio="xMidYMid"
markerUnits="userSpaceOnUse">
<path
style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
d="M 3,-3 0,0 3,3"
id="arrow3-5"
transform="rotate(180,0.125,0)"
sodipodi:nodetypes="ccc" />
</marker>
<marker
style="overflow:visible"
id="Arrow3-7-5"
refX="0"
refY="0"
orient="auto-start-reverse"
inkscape:stockid="Arrow3"
markerWidth="11"
markerHeight="11"
viewBox="0 0 4.2071068 7"
inkscape:isstock="true"
inkscape:collect="always"
preserveAspectRatio="xMidYMid"
markerUnits="userSpaceOnUse">
<path
style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
d="M 3,-3 0,0 3,3"
id="arrow3-5-6"
transform="rotate(180,0.125,0)"
sodipodi:nodetypes="ccc" />
</marker>
</defs>
id="defs2" />
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-54.299432,-112.5212)">
<path
style="fill:none;stroke:#000000;stroke-width:1.375;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="M 54.986932,126.6308 H 80.122625"
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 54.986328,125.94336 a 0.6875,0.6875 0 0 0 -0.6875,0.6875 0.6875,0.6875 0 0 0 0.6875,0.6875 h 25.136719 a 0.6875,0.6875 0 0 0 0.6875,-0.6875 0.6875,0.6875 0 0 0 -0.6875,-0.6875 z"
id="path2600" />
<g
id="path2600-3-3">
<path
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 67.554687,129.20898 a 0.87199998,0.87199998 0 0 0 -0.871093,0.8711 v 9.78906 a 0.87199998,0.87199998 0 0 0 0.871093,0.87109 0.87199998,0.87199998 0 0 0 0.873047,-0.87109 v -9.78906 a 0.87199998,0.87199998 0 0 0 -0.873047,-0.8711 z"
id="path6" />
<g
id="g5">
<path
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 67.554687,128.57617 -5.269531,5.26953 a 0.78571498,0.78571498 0 0 0 0,1.11133 0.78571498,0.78571498 0 0 0 1.111328,0 l 4.158203,-4.1582 4.158204,4.1582 a 0.78571498,0.78571498 0 0 0 1.111328,0 0.78571498,0.78571498 0 0 0 0,-1.11133 z"
id="path5" />
</g>
</g>
<g
id="path2600-3-3-2">
<path
style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7)"
d="m 67.554779,130.0808 v 9.7876"
id="path2600-3-3" />
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 67.554687,112.52148 a 0.87199998,0.87199998 0 0 0 -0.871093,0.8711 v 9.78906 a 0.87199998,0.87199998 0 0 0 0.871093,0.87109 0.87199998,0.87199998 0 0 0 0.873047,-0.87109 v -9.78906 a 0.87199998,0.87199998 0 0 0 -0.873047,-0.8711 z"
id="path3" />
<g
id="g2">
<path
style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7-5)"
d="m 67.554779,123.1808 v -9.7876"
id="path2600-3-3-2" />
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 62.839844,118.07422 a 0.78571498,0.78571498 0 0 0 -0.554688,0.23047 0.78571498,0.78571498 0 0 0 0,1.10937 l 5.269531,5.27149 5.269532,-5.27149 a 0.78571498,0.78571498 0 0 0 0,-1.10937 0.78571498,0.78571498 0 0 0 -1.111328,0 l -4.158204,4.1582 -4.158203,-4.1582 a 0.78571498,0.78571498 0 0 0 -0.55664,-0.23047 z"
id="path2" />
</g>
</g>
</g>
</svg>
......@@ -7,8 +7,8 @@
viewBox="0 0 26.510681 28.219215"
version="1.1"
id="svg5"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
sodipodi:docname="collapse.svg"
inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
sodipodi:docname="expand.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
......@@ -26,7 +26,7 @@
showgrid="false"
inkscape:zoom="2.3786088"
inkscape:cx="183.09022"
inkscape:cy="531.82348"
inkscape:cy="61.17021"
inkscape:window-width="2560"
inkscape:window-height="1385"
inkscape:window-x="0"
......@@ -34,66 +34,43 @@
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<marker
style="overflow:visible"
id="Arrow3-7-9"
refX="0"
refY="0"
orient="auto-start-reverse"
inkscape:stockid="Arrow3"
markerWidth="11"
markerHeight="11"
viewBox="0 0 4.2071068 7"
inkscape:isstock="true"
inkscape:collect="always"
preserveAspectRatio="xMidYMid"
markerUnits="userSpaceOnUse">
<path
style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
d="M 3,-3 0,0 3,3"
id="arrow3-5-1"
transform="rotate(180,0.125,0)"
sodipodi:nodetypes="ccc" />
</marker>
<marker
style="overflow:visible"
id="Arrow3-7-5-2"
refX="0"
refY="0"
orient="auto-start-reverse"
inkscape:stockid="Arrow3"
markerWidth="11"
markerHeight="11"
viewBox="0 0 4.2071068 7"
inkscape:isstock="true"
inkscape:collect="always"
preserveAspectRatio="xMidYMid"
markerUnits="userSpaceOnUse">
<path
style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
d="M 3,-3 0,0 3,3"
id="arrow3-5-6-7"
transform="rotate(180,0.125,0)"
sodipodi:nodetypes="ccc" />
</marker>
</defs>
id="defs2" />
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-109.32506,-110.6955)">
<path
style="fill:none;stroke:#000000;stroke-width:1.375;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
d="m 110.01256,124.8051 h 25.13569"
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 110.01172,124.11719 a 0.6875,0.6875 0 0 0 -0.6875,0.6875 0.6875,0.6875 0 0 0 0.6875,0.6875 h 25.13672 a 0.6875,0.6875 0 0 0 0.6875,-0.6875 0.6875,0.6875 0 0 0 -0.6875,-0.6875 z"
id="path2600-0" />
<g
id="path2600-3-3-9">
<path
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 122.58008,126.75195 a 0.87199998,0.87199998 0 0 0 -0.8711,0.8711 v 9.78711 a 0.87199998,0.87199998 0 0 0 0.8711,0.87304 0.87199998,0.87199998 0 0 0 0.87305,-0.87304 v -9.78711 a 0.87199998,0.87199998 0 0 0 -0.87305,-0.8711 z"
id="path3" />
<g
id="g2">
<path
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 117.31055,132.5332 a 0.78571498,0.78571498 0 0 0 0,1.11133 l 5.26953,5.26953 5.26953,-5.26953 a 0.78571498,0.78571498 0 0 0 0,-1.11133 0.78571498,0.78571498 0 0 0 -1.11133,0 l -4.1582,4.15821 -4.1582,-4.15821 a 0.78571498,0.78571498 0 0 0 -1.11133,0 z"
id="path2" />
</g>
</g>
<g
id="path2600-3-3-2-3">
<path
style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7-9)"
d="m 122.58041,137.41068 v -9.7876"
id="path2600-3-3-9" />
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 122.58008,111.32813 a 0.87199998,0.87199998 0 0 0 -0.8711,0.87109 v 9.78711 a 0.87199998,0.87199998 0 0 0 0.8711,0.87305 0.87199998,0.87199998 0 0 0 0.87305,-0.87305 v -9.78711 a 0.87199998,0.87199998 0 0 0 -0.87305,-0.87109 z"
id="path5" />
<g
id="g4">
<path
style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7-5-2)"
d="m 122.58041,112.19952 v 9.7876"
id="path2600-3-3-2-3" />
style="color:#000000;fill:#000000;stroke-linecap:round;-inkscape-stroke:none"
d="m 122.58008,110.69531 -5.26953,5.26953 a 0.78571498,0.78571498 0 0 0 0,1.11133 0.78571498,0.78571498 0 0 0 1.11133,0 l 4.1582,-4.1582 4.1582,4.1582 a 0.78571498,0.78571498 0 0 0 1.11133,0 0.78571498,0.78571498 0 0 0 0,-1.11133 z"
id="path4" />
</g>
</g>
</g>
</svg>
Ccs/pixmap/pythons.png

8.83 KiB

......@@ -350,7 +350,7 @@ def make_verification_script(model, model_spec):
def make_documentation(model, model_spec):
return None
return
def make_all(model):
......@@ -363,11 +363,6 @@ def make_all(model):
dc_path = make_documentation(sequence, model)
break
#cs_path = make_command_script(model)
#cms_path = make_command_manually_steps_script(model)
#vf_path = make_verification_script(model)
#dc_path = make_documentation(model)
if cs_path is not None:
paths.append(cs_path)
if cms_path is not None:
......
......@@ -282,25 +282,26 @@ class TstAppWindow(Gtk.ApplicationWindow):
self.btn_export_csv.set_icon_name('text-csv')
self.btn_export_csv.set_tooltip_text('Export current spec to CSV')
self.btn_export_csv.connect('clicked', self.on_generate_csv)
# self.btn_generate_products = Gtk.ToolButton()
# self.btn_generate_products.set_label('Generate scripts')
# self.btn_generate_products.set_icon_name('text-x-python')
# self.btn_generate_products.set_tooltip_text('Generate command.py, verification.py and manually.py')
# self.btn_generate_products.connect('clicked', self.on_generate_products)
self.btn_generate_products = Gtk.ToolButton()
self.btn_generate_products.set_label('Automated test scripts')
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.join(cfg.get('paths', 'ccs'), 'pixmap/pythons.png'), 28, 28)
icon = Gtk.Image.new_from_pixbuf(pixbuf)
self.btn_generate_products.set_icon_widget(icon)
self.btn_generate_products.set_tooltip_text('Generate set of Python scripts for automated testing')
self.btn_generate_products.connect('clicked', self.on_generate_products)
self.btn_generate_script = Gtk.ToolButton()
self.btn_generate_script.set_label('Generate scripts')
self.btn_generate_script.set_label('Generate script')
self.btn_generate_script.set_icon_name('text-x-python')
self.btn_generate_script.set_tooltip_text('Generate Python script of the current test')
self.btn_generate_script.set_tooltip_text('Generate compact Python script of the current test')
self.btn_generate_script.connect('clicked', self.on_generate_barescript)
self.btn_start_ccs_editor = Gtk.ToolButton()
self.btn_start_ccs_editor.set_label('Start CCS')
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
cfg.get('paths', 'ccs') + '/pixmap/ccs_logo_2.svg', 28, 28)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(os.path.join(cfg.get('paths', 'ccs'), 'pixmap/ccs_logo_2.svg'), 28, 28)
icon = Gtk.Image.new_from_pixbuf(pixbuf)
self.btn_start_ccs_editor.set_icon_widget(icon)
self.btn_start_ccs_editor.set_tooltip_text('Start CCS-Editor')
self.btn_start_ccs_editor.connect('clicked', self.on_start_ccs_editor)
self.btn_start_ccs_editor.connect('clicked', self.connect_to_ccs_editor)
self.btn_open_progress_view = Gtk.ToolButton()
self.btn_open_progress_view.set_label('Start ProgressView')
......@@ -315,10 +316,10 @@ class TstAppWindow(Gtk.ApplicationWindow):
self.toolbar.insert(self.btn_save_as, 3)
# self.toolbar.insert(self.btn_show_model_viewer, 2)
self.toolbar.insert(self.btn_export_csv, 4)
# self.toolbar.insert(self.btn_generate_products, 5)
self.toolbar.insert(self.btn_generate_script, 5)
self.toolbar.insert(self.btn_start_ccs_editor, 6)
self.toolbar.insert(self.btn_open_progress_view, 7)
self.toolbar.insert(self.btn_generate_products, 6)
self.toolbar.insert(self.btn_start_ccs_editor, 7)
self.toolbar.insert(self.btn_open_progress_view, 8)
# IDB chooser
self.idb_chooser = Gtk.ToolButton()
......@@ -328,12 +329,12 @@ class TstAppWindow(Gtk.ApplicationWindow):
self.idb_chooser.set_label_widget(label)
self.idb_chooser.set_tooltip_text('Select IDB')
self.idb_chooser.connect('clicked', self.on_set_idb_version)
self.toolbar.insert(self.idb_chooser, 8)
self.toolbar.insert(self.idb_chooser, 9)
# separator
sepa = Gtk.SeparatorToolItem()
sepa.set_expand(True)
self.toolbar.insert(sepa, 9)
self.toolbar.insert(sepa, 10)
# logo
self.unilogo = Gtk.ToolButton()
......@@ -342,7 +343,7 @@ class TstAppWindow(Gtk.ApplicationWindow):
icon = Gtk.Image.new_from_pixbuf(pixbuf)
self.unilogo.set_icon_widget(icon)
self.unilogo.connect('clicked', self.on_about)
self.toolbar.insert(self.unilogo, 10)
self.toolbar.insert(self.unilogo, 11)
self.box.pack_start(self.toolbar, False, True, 0)
self.info_bar = None
......@@ -889,9 +890,6 @@ class TstAppWindow(Gtk.ApplicationWindow):
This function generates out of the current test script model the command script, the verification script and
the documentation file. If it succeeded, a dialog box will be triggered.
"""
# ToDo: remove the reloading, when developing is finished
# import importlib
# importlib.reload(generator)
model = self.current_model()
if not model:
logger.info('Test Files can not be generated without Steps')
......@@ -901,21 +899,38 @@ class TstAppWindow(Gtk.ApplicationWindow):
logger.info('Test Files can not be generated if Test has no name!')
logger.error('Please give the test a name')
return
self.product_paths = generator.make_all(model=model)
existfns = self.check_for_existing_files(model)
if existfns:
dialog = FilesExistDialog(existfns[0])
dialog.set_transient_for(self)
response = dialog.run()
if response != Gtk.ResponseType.OK:
dialog.destroy()
return
dialog.destroy()
self.product_paths = generator.make_all(model)
# triggering the dialog after generation
self.on_generate_products_message_dialog(paths=self.product_paths)
def check_for_existing_files(self, model):
cmdfn = generator.create_script_path(model.name, generator.cmd_scrpt_auxiliary)
runfn = generator.create_script_path(model.name, generator.run_scrpt_auxiliary)
vrcfn = generator.create_script_path(model.name, generator.vrc_scrpt_auxiliary)
if os.path.isfile(cmdfn) or os.path.isfile(runfn) or os.path.isfile(vrcfn):
return cmdfn, runfn, vrcfn
else:
return False
def on_generate_barescript(self, *args):
"""
Generates a compact python test file without all the additional stuff from on_generate_scripts
"""
# dialog = Gtk.FileChooserDialog(
# title="Save script as", parent=self, action=Gtk.FileChooserAction.SAVE)
# dialog.add_buttons(
# Gtk.STOCK_CANCEL,
# Gtk.ResponseType.CANCEL,
# Gtk.STOCK_SAVE,
# Gtk.ResponseType.OK, )
if self.current_test_instance():
# current_json_filename = self.current_test_instance().filename
......@@ -979,7 +994,7 @@ class TstAppWindow(Gtk.ApplicationWindow):
dialog.destroy()
return
def connect_to_ccs_editor(self):
def connect_to_ccs_editor(self, *args):
# get the DBus connection to the CCS-Editor
editor = connect_apps.connect_to_editor()
if editor is None:
......@@ -987,6 +1002,7 @@ class TstAppWindow(Gtk.ApplicationWindow):
self.on_start_ccs_editor(False)
editor = connect_apps.connect_to_app('editor')
editor.Functions('present')
'''
k = 0
while k < 3:
......@@ -1046,11 +1062,11 @@ class TstAppWindow(Gtk.ApplicationWindow):
Gtk.MessageType.QUESTION,
Gtk.ButtonsType.YES_NO,
'Scripts were generated')
message = 'Generated files:\n'
message = 'Generated files in {}:\n\n'.format(os.path.dirname(paths[0]))
for entry in paths:
message += os.path.basename(entry) + '\n'
paths.append(os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), '..')), 'prep_test_env.py'))
message += 'Do you want to open them in CCS?'
message += '\nDo you want to open them in CCS?'
dialog.format_secondary_text(message)
response = dialog.run()
if response == Gtk.ResponseType.YES:
......@@ -1101,13 +1117,14 @@ class TstAppWindow(Gtk.ApplicationWindow):
progress_viewer = self.connect_progress_viewer()
file_names = self.get_log_file_paths_from_json_file_name()
try:
if file_names:
progress_viewer.Activate('open-test-files', [file_names], [])
except Exception as e:
message = 'Could not start ProgressViewer application.'
message = 'Could not load test files for {} in Progress Viewer.'.format(file_names['json_file_path'])
self.logger.error(message)
self.logger.exception(e)
# add a info bar message that the starting of the CCS-Editor failed.
self.add_info_bar(message_type=Gtk.MessageType.ERROR, message=message)
self.add_info_bar(message_type=Gtk.MessageType.WARNING, message=message)
def on_start_ccs_editor(self, *args):
try:
......@@ -1328,5 +1345,15 @@ class ScriptExportDialog(Gtk.FileChooserDialog):
self.csvspec.set_sensitive(False)
class FilesExistDialog(Gtk.MessageDialog):
def __init__(self, existpath):
super().__init__(title='Files exist', message_type=Gtk.MessageType.INFO)
existdir, existfn = os.path.split(existpath)
self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK)
self.set_markup('\n<i>{}*</i> scripts already exist in\n{}\nand will be overwritten!'.format(existfn.replace(generator.cmd_scrpt_auxiliary, ''), existdir))
if __name__ == '__main__':
run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment