From bd172820b0a4f77ffbbca1ace273f409e5073974 Mon Sep 17 00:00:00 2001 From: Christopher Granabetter <christopher.granabetter@univie.ac.at> Date: Tue, 21 Jan 2025 16:23:01 +0100 Subject: [PATCH] added Requirements and TM/TC to TST --- Tst/json_to_csv.py | 24 +++++----- Tst/tst/data_model.py | 24 ++++++++++ Tst/tst/dnd_data_parser.py | 11 +++-- Tst/tst/view.py | 92 +++++++++++++++++++++++++++++++------- 4 files changed, 119 insertions(+), 32 deletions(-) diff --git a/Tst/json_to_csv.py b/Tst/json_to_csv.py index 366d6d6..07f1ab4 100755 --- a/Tst/json_to_csv.py +++ b/Tst/json_to_csv.py @@ -13,24 +13,26 @@ def run(jfile, outfile): else: data = json.loads(jfile) - header = 'Item|Description|Verification|TestResult' - name = '{}|{}|Test spec. version: {}| IASW-{}'.format(data['_name'], replace_newline(data['_description']), + header = 'Item|Description|TMTC|Verification|TestResult' + name = '{}|{}|Test spec. version: {}| IASW-{}|'.format(data['_name'], replace_newline(data['_description']), data['_spec_version'], data['_iasw_version']) # Date from last time the json file was changed + current date - date = 'Date||{}|'.format(datetime.datetime.now().strftime('%Y-%m-%d')) - testcomment = 'Comment|{}||'.format(replace_newline(data['_comment'])) - precond = 'Precond.|{}||'.format(replace_newline(data['_precon_descr'])) - postcond = 'Postcond.|{}||'.format(replace_newline(data['_postcon_descr'])) + date = 'Date||{}||'.format(datetime.datetime.now().strftime('%Y-%m-%d')) + testcomment = 'Comment|{}|||'.format(replace_newline(data['_comment'])) + precond = 'Precond.|{}|||'.format(replace_newline(data['_precon_descr'])) + postcond = 'Postcond.|{}|||'.format(replace_newline(data['_postcon_descr'])) + requirements = 'Requ.|{}|||'.format(replace_newline(data['_requirements'])) steps = [] for step in data['sequences'][0]['steps']: - line = 'Step {}|{}|{}|'.format(step['_step_number'], replace_newline(step['_description']), - replace_newline(step['_verification_description'])) + line = 'Step {}|{}|{}|{}|'.format(step['_step_number'], replace_newline(step['_description']), + replace_newline(step['_tmtc_comment']), + replace_newline(step['_verification_description'])) steps.append(line) if step['_step_comment'] != '': - comment = 'Comment|{}||'.format(replace_newline(step['_step_comment'])) + comment = 'Comment|{}|||'.format(replace_newline(step['_step_comment'])) steps.append(comment) if outfile[-1] == '/': # If only path is given but no filename @@ -38,9 +40,9 @@ def run(jfile, outfile): with open(outfile, 'w') as fd: if len(data['_comment']) != 0: - buf = '\n'.join([header, name, date, testcomment, precond] + steps + [postcond]) + buf = '\n'.join([header, name, date, testcomment, requirements, precond] + steps + [postcond]) else: - buf = '\n'.join([header, name, date, precond] + steps + [postcond]) + buf = '\n'.join([header, name, date, requirements, precond] + steps + [postcond]) buf = buf.replace('_', '\\_') fd.write(buf) diff --git a/Tst/tst/data_model.py b/Tst/tst/data_model.py index 0dd1752..56ef871 100644 --- a/Tst/tst/data_model.py +++ b/Tst/tst/data_model.py @@ -113,6 +113,7 @@ class Step: self._description = '' self._command_code = '' self._step_comment = '' + self._tmtc_comment = '' self._verification_code = '' self._verification_description = '' self._is_active = True @@ -144,6 +145,7 @@ class Step: new_step.description = copy.copy(self.description) new_step.command_code = copy.copy(self.command_code) new_step.step_comment = copy.copy(self.step_comment) + new_step.tmtc_comment = copy.copy(self.tmtc_comment) new_step.verification_code = copy.copy(self.verification_code) new_step.verification_description = copy.copy(self.verification_description) new_step.is_active = copy.copy(self.is_active) @@ -224,6 +226,15 @@ class Step: assert isinstance(value, str) self._step_comment = value + @property + def tmtc_comment(self): + return self._tmtc_comment + + @tmtc_comment.setter + def tmtc_comment(self, value: str): + assert isinstance(value, str) + self._tmtc_comment = value + @property def verification_code(self): return self._verification_code @@ -288,6 +299,7 @@ class Step: self.description = step['_description'] self.command_code = step['_command_code'] self.step_comment = step['_step_comment'] + self.tmtc_comment = step['_tmtc_comment'] self.verification_code = step['_verification_code'] self.verification_description = step['_verification_description'] self.is_active = step['_is_active'] @@ -902,6 +914,7 @@ class TestSpecification: self._description = '' self._spec_version = '' self._iasw_version = '' + self._requirements = '' self._primary_counter_locked = False self._precon_name = '' self._precon_code = '' @@ -924,6 +937,7 @@ class TestSpecification: new_testspec.description = copy.copy(self.description) new_testspec.spec_version = copy.copy(self.spec_version) new_testspec.iasw_version = copy.copy(self.iasw_version) + new_testspec.requirements = copy.copy(self.requirements) new_testspec.primary_counter_locked = copy.copy(self.primary_counter_locked) new_testspec.precon_name = copy.copy(self.precon_name) new_testspec.precon_code = copy.copy(self.precon_code) @@ -985,6 +999,15 @@ class TestSpecification: assert isinstance(value, str) self._iasw_version = value + @property + def requirements(self): + return self._requirements + + @requirements.setter + def requirements(self, value: str): + assert isinstance(value, str) + self._requirements = value + @property def precon_name(self): return self._precon_name @@ -1082,6 +1105,7 @@ class TestSpecification: self.description = json_data['_description'] self.spec_version = json_data['_spec_version'] self.iasw_version = json_data['_iasw_version'] + self.requirements = json_data['_requirements'] self.primary_counter_locked = json_data['_primary_counter_locked'] self.precon_name = json_data['_precon_name'] self.precon_code = json_data['_precon_code'] diff --git a/Tst/tst/dnd_data_parser.py b/Tst/tst/dnd_data_parser.py index 18b414b..cfe8571 100644 --- a/Tst/tst/dnd_data_parser.py +++ b/Tst/tst/dnd_data_parser.py @@ -17,7 +17,7 @@ data_type_snippet = 'snippet' data_type_step = 'step' -def create_datastring(data_type, sequence='', step_number='', description='', comment='', command_code='', verification_code='', verification_descr='', logger=logger): +def create_datastring(data_type, sequence='', step_number='', description='', comment='', tmtc='', command_code='', verification_code='', verification_descr='', logger=logger): if data_type == data_type_snippet: step_number = '' # build the data string @@ -27,6 +27,7 @@ def create_datastring(data_type, sequence='', step_number='', description='', co data_string += separator + step_number data_string += separator + description data_string += separator + comment + data_string += separator + tmtc data_string += separator + command_code data_string += separator + verification_code data_string += separator + verification_descr @@ -49,15 +50,17 @@ def read_datastring(data_string: str, logger=logger) -> dict: step_number = data[2] description = data[3] comment = data[4] - command_code = data[5] - verification_code = data[6] - verification_descr = data[7] + tmtc = data[5] + command_code = data[6] + verification_code = data[7] + verification_descr = data[8] data_dict = { 'data_type': data_type, 'sequence': sequence, 'step_number': step_number, 'description': description, 'comment': comment, + 'tmtc': tmtc, 'command_code': command_code, 'verification_code': verification_code, 'verification_descr' : verification_descr diff --git a/Tst/tst/view.py b/Tst/tst/view.py index ea2441e..e564168 100644 --- a/Tst/tst/view.py +++ b/Tst/tst/view.py @@ -135,7 +135,7 @@ class Board(Gtk.Box): self.test_meta_data_iasw_box.pack_start(self.test_meta_data_iasw_version_label, False, False, 4) self.test_meta_data_iasw_box.pack_end(self.test_meta_data_iasw_version, False, False, 0) self.test_meta_data_info.pack_start(self.test_meta_data_iasw_box, True, True, 0) - # IASW Software Version + # IASW Requirements self.test_meta_data_req_label = Gtk.Label() self.test_meta_data_req_label.set_text('Requirements:') self.test_meta_data_req = Gtk.Entry(width_chars=25) @@ -300,6 +300,7 @@ class Board(Gtk.Box): self.test_meta_data_desc.connect('changed', self.on_test_desc_change) self.test_meta_data_spec_version.connect('changed', self.on_test_spec_version_change) self.test_meta_data_iasw_version.connect('changed', self.on_test_iasw_version_change) + self.test_meta_data_req.connect('changed', self.on_test_requirements_change) self.text_meta_data_test_is_locked.connect('toggled', self.on_test_locked_toggled) self.test_meta_data_comment.get_buffer().connect('changed', self.on_comment_change) self.custom_import_buffer.connect('changed', self.on_custom_import_change) @@ -353,6 +354,8 @@ class Board(Gtk.Box): self.test_meta_data_spec_version.set_text(self.model.spec_version) # set the Software version of the test specification from the data model self.test_meta_data_iasw_version.set_text(self.model.iasw_version) + # set the Requirements of the test specification from the data model + self.test_meta_data_req.set_text(self.model.requirements) # set the pre-condition name if self.model.precon_name: found = False @@ -553,6 +556,14 @@ class Board(Gtk.Box): # update the data model viewer self.app.update_model_viewer() + def on_test_requirements_change(self, widget): + # get the IASW Version out of the text buffer of the widget + requirements = widget.get_text() + # update the model + self.model.requirements = requirements + # update the data model viewer + self.app.update_model_viewer() + def on_test_locked_toggled(self, *args): # toggle the value in the widget self.test_is_locked = not self.test_is_locked @@ -794,9 +805,13 @@ class StepWidget(Gtk.EventBox): # fields for commands and verification # lm = GtkSource.LanguageManager() + # Area for Commands and TM/TC + self.commands_and_tmtc_box = Gtk.Grid() + self.commands_and_tmtc_box.set_column_homogeneous(False) + # Area for the commands - self.whole_commands_box = Gtk.Box() - self.whole_commands_box.set_orientation(Gtk.Orientation.VERTICAL) + #self.whole_commands_box = Gtk.Box() + #self.whole_commands_box.set_orientation(Gtk.Orientation.VERTICAL) # Make the label, inside a own Box to show it on the left side self.lbl_box_commands = Gtk.Box() self.lbl_box_commands.set_orientation(Gtk.Orientation.HORIZONTAL) @@ -809,7 +824,7 @@ class StepWidget(Gtk.EventBox): # Make the area where the real command is entered # self.detail_box.pack_start(self.lbl_box_commands, True, True, 0) self.commands_scrolled_window = Gtk.ScrolledWindow() - self.commands_scrolled_window.set_size_request(-1, 200) + self.commands_scrolled_window.set_size_request(600, 200) self.commands_view = GtkSource.View() self.commands_view.set_auto_indent(True) self.commands_view.set_wrap_mode(Gtk.WrapMode.WORD) @@ -836,14 +851,16 @@ class StepWidget(Gtk.EventBox): # self.commands_buffer.set_style_scheme(self.board.current_scheme) self.commands_scrolled_window.add(self.commands_view) - self.whole_commands_box.pack_start(self.lbl_box_commands, False, False, 0) - self.whole_commands_box.pack_start(self.commands_scrolled_window, True, True, 0) - self.detail_box.pack_start(self.whole_commands_box, True, True, 0) + #self.whole_commands_box.pack_start(self.lbl_box_commands, False, False, 0) + #self.whole_commands_box.pack_start(self.commands_scrolled_window, True, True, 0) + + #self.commands_and_tmtc_box.pack_start(self.whole_commands_box, True, True, 0) + #self.detail_box.pack_start(self.commands_and_tmtc_box, True, True, 0) # Area for TM/TC - self.whole_tmtc_box = Gtk.Box() - self.whole_tmtc_box.set_orientation(Gtk.Orientation.VERTICAL) + #self.whole_tmtc_box = Gtk.Box() + #self.whole_tmtc_box.set_orientation(Gtk.Orientation.VERTICAL) # box for TM/TC self.tmtc_box = Gtk.Box() self.tmtc_box.set_orientation(Gtk.Orientation.HORIZONTAL) @@ -852,19 +869,19 @@ class StepWidget(Gtk.EventBox): self.tmtc_box.pack_start(self.tmtc_label, False, False, 0) self.tmtc_scrolled_window = Gtk.ScrolledWindow() - self.tmtc_scrolled_window.set_size_request(-1, 10) + self.tmtc_scrolled_window.set_size_request(195, 200) self.tmtc_view = GtkSource.View() self.tmtc_view.set_auto_indent(True) self.tmtc_view.set_wrap_mode(Gtk.WrapMode.WORD) - self.tmtc_view.set_show_line_numbers(True) + #self.tmtc_view.set_show_line_numbers(True) # self.tmtc_view.set_show_right_margin(True) self.tmtc_view.set_monospace(True) - self.tmtc_view.set_highlight_current_line(True) + #self.tmtc_view.set_highlight_current_line(True) self.tmtc_view.set_indent_on_tab(True) self.tmtc_view.set_insert_spaces_instead_of_tabs(True) self.tmtc_view.set_indent_width(4) self.tmtc_view.set_auto_indent(True) - self.tmtc_buffer = self.tmtc_view.get_buffer() + self.tmtc_comment_buffer = self.tmtc_view.get_buffer() # draganddrop here """ self.tmtc_view.drag_dest_set(Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY) @@ -875,14 +892,23 @@ class StepWidget(Gtk.EventBox): self.tmtc_view.connect("drag-leave", self.on_drag_leave) """ - self.tmtc_buffer.set_language(lngg) + self.tmtc_comment_buffer.set_language(lngg) # self.tmtc_buffer.set_style_scheme(self.board.current_scheme) self.tmtc_scrolled_window.add(self.tmtc_view) - self.whole_tmtc_box.pack_start(self.tmtc_box, False, False, 0) - self.whole_tmtc_box.pack_start(self.tmtc_scrolled_window, True, True, 0) - self.detail_box.pack_start(self.whole_tmtc_box, True, True, 0) + #self.whole_tmtc_box.pack_start(self.tmtc_box, False, False, 0) + #self.whole_tmtc_box.pack_start(self.tmtc_scrolled_window, True, True, 0) + # self.commands_and_tmtc_box.pack_start(self.whole_tmtc_box, True, True, 0) + # self.detail_box.pack_start(self.commands_and_tmtc_box, True, True, 0) + #ADD everything to the whole grid + self.commands_and_tmtc_box.set_column_spacing(10) + self.commands_and_tmtc_box.attach(self.lbl_box_commands, 0, 0, 3, 1) + self.commands_and_tmtc_box.attach(self.commands_scrolled_window, 0, 1, 3, 5) + self.commands_and_tmtc_box.attach_next_to(self.tmtc_box, self.lbl_box_commands, Gtk.PositionType.RIGHT, 3, 1) + self.commands_and_tmtc_box.attach_next_to(self.tmtc_scrolled_window, self.commands_scrolled_window, Gtk.PositionType.RIGHT, 3, 5) + self.detail_box.pack_start(self.commands_and_tmtc_box, True, True, 0) + # area for the verification self.whole_verification_box = Gtk.Grid() @@ -976,6 +1002,7 @@ class StepWidget(Gtk.EventBox): self.desc_text_buffer.connect('changed', self.on_description_buffer_changed) self.commands_buffer.connect('changed', self.on_commands_buffer_changed) self.step_comment_buffer.connect('changed', self.on_step_comment_buffer_changed) + self.tmtc_comment_buffer.connect('changed', self.on_tmtc_buffer_changed) self.verification_buffer.connect('changed', self.on_verification_buffer_changed) self.verification_description_buffer.connect('changed', self.on_verification_description_buffer_changed) @@ -1074,6 +1101,7 @@ class StepWidget(Gtk.EventBox): self.set_description_in_widget() self.set_commands_in_widget() self.set_step_comment_in_widget() + self.set_tmtc_comment_in_widget() self.set_verification_in_widget() self.set_verification_description_in_widget() self.set_start_sequence_in_widget() @@ -1112,6 +1140,13 @@ class StepWidget(Gtk.EventBox): step_comment = self.model.get_sequence(self.sequence).steps[stp_ndx].step_comment self.step_comment_buffer.set_text(step_comment) return + + def set_tmtc_comment_in_widget(self): + """ gets the commands comment from the model and sets it in the commands comment buffer in order to display it """ + stp_ndx = self.model.get_sequence(self.sequence).get_step_index(self.step_number) + tmtc_comment = self.model.get_sequence(self.sequence).steps[stp_ndx].tmtc_comment + self.tmtc_comment_buffer.set_text(tmtc_comment) + return def set_verification_in_widget(self): """ gets the commands from the model and sets it in the commands buffer in order to display it """ @@ -1198,6 +1233,7 @@ class StepWidget(Gtk.EventBox): step_number = step.step_number description = step.description comment = step.step_comment + tmtc = step.tmtc_comment command_code = step.command_code verification_code = step.verification_code verification_descr = step.verification_description @@ -1207,6 +1243,7 @@ class StepWidget(Gtk.EventBox): step_number, description, comment, + tmtc, command_code, verification_code, verification_descr, @@ -1285,6 +1322,7 @@ class StepWidget(Gtk.EventBox): step.description = data['description'] step.command_code = data['command_code'] step.step_comment = data['comment'] + step.tmtc_comment = data['tmtc'] step.verification_code = data['verification_code'] step.verification_description = data['verification_descr'] if drag_source_type == dnd_data_parser.data_type_step: # a step is moved @@ -1386,6 +1424,24 @@ class StepWidget(Gtk.EventBox): # update the data model viewer self.app.update_model_viewer() + def on_tmtc_buffer_changed(self, text_buffer): + """ + Signal 'changed' for the tmtc comment buffer + """ + # get the text of the commands comment out of the buffer of the widget + tmtc_comment = self.read_out_text_buffer(text_buffer) + # Setting the commands string for a step in the data model + # find the correct step within the data model + stp_ndx = self.model.get_sequence(self.sequence).get_step_index(self.step_number) + step_in_data_model = self.model.get_sequence(self.sequence).steps[stp_ndx] + # use the setter of the data model + if isinstance(step_in_data_model, data_model.Step): + step_in_data_model.tmtc_comment = tmtc_comment + else: + self.logger('step with the step number {} could not be found'.format(self.step_number)) + # update the data model viewer + self.app.update_model_viewer() + def on_verification_buffer_changed(self, text_buffer): """ Signal 'changed' for the verification source buffer @@ -1702,6 +1758,7 @@ class InterStepWidget(Gtk.Box): # set the data into the test script data model new_step.description = data['description'] new_step.step_comment = data['comment'] + new_step.tmtc_comment = data['tmtc'] new_step.command_code = data['command_code'] new_step.verification_code = data['verification_code'] new_step.verification_description = data['verification_descr'] @@ -1726,6 +1783,7 @@ class InterStepWidget(Gtk.Box): # set the data into the test script data model new_step.description = data['description'] new_step.step_comment = data['comment'] + new_step.tmtc_comment = data['tmtc'] new_step.command_code = data['command_code'] new_step.verification_code = data['verification_code'] new_step.verification_description = data['verification_descr'] -- GitLab