def __init__(self, master, cpacs_path, cpacs_out_path, submodule_list, **kwargs): tk.Frame.__init__(self, master, **kwargs) self.pack(fill=tk.BOTH) self.submodule_list = submodule_list self.cpacs_out_path = cpacs_out_path # Notebook for tabs self.tabs = ttk.Notebook(self) self.tabs.grid(row=0, column=0, columnspan=3) #pack()#expand=1, side=tk.LEFT) self.tixi = cpsf.open_tixi(cpacs_path) if len(apm.get_aeromap_uid_list(self.tixi)) == 0 : aeromap_uid = 'AeroMap_1point' csv_path = os.path.join(MODULE_DIR,'..','..','test','AeroMaps','Aeromap_1point.csv') apm.aeromap_from_csv(self.tixi, aeromap_uid, csv_path) # Generate AeroMaps Edition tab aeromap_tap = AeroMapTab(self.tabs, self.tixi) # Generate Auto Tab ============= self.tab_list = [] self._update_all() # General button self.update_button = tk.Button(self, text='Update', command=self._update_all) self.update_button.grid(row=1, column=1,sticky='E') self.close_button = tk.Button(self, text='Save & Quit', command=self._save_quit) self.close_button.grid(row=1, column=2,sticky='W')
def test_aeromap_from_csv(): """Test the function 'aeromap_from_csv'""" tixi = open_tixi(CPACS_IN_PATH) aeromap_uid = 'test_aeromap' csv_path = os.path.join(MODULE_DIR, 'ToolInput', 'Aeromap_test.csv') aeromap_from_csv(tixi, aeromap_uid, csv_path) AeroCoef = get_aeromap(tixi, aeromap_uid) assert AeroCoef.get_count() == 24 for i in range(12): assert AeroCoef.alt[i] == 0 for j in range(12, 24): print(i) assert AeroCoef.alt[j] == 12000 # Is is useful to test all the value? # def test_check_aeromap(): """ Test the function 'check_aeromap'""" # def test_get_aeromap (): """ Test the function 'get_aeromap'""" # def test_save_parameters(): """ Test the function 'save_parameters'""" # def test_save_coefficients(): """ Test the function 'save_coefficients'"""
def _import_csv(self, event=None): template_csv_dir = os.path.join(MODULE_DIR,'..','..','test','AeroMaps') csv_path = self.filename = filedialog.askopenfilename(initialdir = template_csv_dir, title = "Select a CSV file" ) new_aeromap_uid = os.path.splitext(os.path.basename(csv_path))[0] apm.aeromap_from_csv(self.tixi, new_aeromap_uid, csv_path) self.listBox.selection_clear(0, tk.END) self._update()
def test_static_stability_analysis(): """Test function 'staticStabilityAnalysis' """ MODULE_DIR = os.path.dirname(os.path.abspath(__file__)) cpacs_path = os.path.join(MODULE_DIR,'ToolInput','CPACSTestStability.xml') cpacs_out_path = os.path.join(MODULE_DIR,'ToolInput', 'CPACSTestStability.xml') csv_path = MODULE_DIR + '/ToolInput/csvtest.csv' tixi = open_tixi(cpacs_path) # Get Aeromap UID list uid_list = get_aeromap_uid_list(tixi) aeromap_uid = uid_list[0] # Import aeromap from the CSV to the xml aeromap_from_csv(tixi, aeromap_uid, csv_path) close_tixi(tixi, cpacs_out_path) # Make the static stability analysis, on the modified xml file static_stability_analysis(cpacs_path, cpacs_out_path) # Assert that all error messages are present log_path = os.path.join(LIB_DIR,'StabilityStatic','staticstability.log') graph_cruising = False errors = '' #Open log file with open(log_path, "r") as f : # For each line in the log file for line in f : # if the info insureing that the graph of cruising aoa VS mach has been generated. if 'graph : cruising aoa vs mach genrated' in line : graph_cruising = True # if 'warning' or 'error ' is in line if 'ERROR' in line : # check if error type (altitude) is in line errors += line # Assert that all error type happend only once. assert graph_cruising == True