Beispiel #1
0
 def test_codes_with_result_grid(self):
     # create empty result grid
     self.frame = grid_frame.GridFrame(self.ErMagic, self.method_WD,
                                       "result", "result")
     self.assertFalse(any(self.ErMagic.results))
     col_labels = [
         self.frame.grid.GetColLabelValue(col)
         for col in range(self.frame.grid.GetNumberCols())
     ]
     method_col = col_labels.index('magic_method_codes')
     # fill in name and method codes for one result
     self.frame.grid.SetCellValue(0, 0, 'result1')
     self.frame.grid.SetCellValue(0, method_col, 'code1')
     self.frame.grid.changes = set([0])
     # save changes
     self.frame.onSave(None)
     # there should be a result in the data object, now, with a method code
     res = self.ErMagic.results[0]
     self.assertTrue(any(self.ErMagic.results))
     self.assertEqual('code1', res.pmag_data['magic_method_codes'])
     # make a result grid with that one result
     self.new_frame = grid_frame.GridFrame(self.ErMagic, self.method_WD,
                                           "result", "result")
     # test that the result (and method codes) are written to the new grid
     self.assertEqual('result1', self.new_frame.grid.GetCellValue(0, 0))
     self.assertEqual('code1',
                      self.new_frame.grid.GetCellValue(0, method_col))
Beispiel #2
0
 def setUp(self):
     self.app = wx.App()
     #self.grid = GridFrame(self.ErMagic, self.WD, grid_type, grid_type, self.panel)
     ErMagic = builder.ErMagicBuilder(WD, DMODEL)
     ErMagic.init_default_headers()
     ErMagic.init_actual_headers()
     self.frame = grid_frame.GridFrame(ErMagic, WD, "specimen", "specimen")
     self.pnl = self.frame.GetChildren()[0]
Beispiel #3
0
 def setUp(self):
     self.app = wx.App()
     #self.grid = GridFrame(self.ErMagic, self.WD, grid_type, grid_type, self.panel)
     self.method_WD = os.path.join(WD, 'data_files', 'testing', 'methods')
     self.ErMagic = builder.ErMagicBuilder(self.method_WD, DMODEL)
     self.ErMagic.get_all_magic_info()
     self.ErMagic.init_default_headers()
     self.ErMagic.init_actual_headers()
     self.frame = grid_frame.GridFrame(self.ErMagic, self.method_WD,
                                       "specimen", "specimen")
Beispiel #4
0
    def test_close_grid(self):
        self.frame.grid_frame = grid_frame.GridFrame(self.ErMagic, WD,
                                                     "specimen", "specimen")
        self.assertTrue(self.frame.grid_frame.IsShown())
        menus = self.frame.MenuBar.Menus
        fmenu, fmenu_name = menus[0]
        # once you have the correct menu
        close_id = fmenu.FindItem('Close current grid')
        close_item = fmenu.FindItemById(close_id)

        event = wx.CommandEvent(wx.EVT_MENU.evtType[0], close_id)
        self.frame.GetEventHandler().ProcessEvent(event)
Beispiel #5
0
 def test_without_codes(self):
     other_WD = os.path.join(WD, 'data_files', 'testing', 'my_project')
     self.other_er_magic = builder.ErMagicBuilder(other_WD)
     self.other_er_magic.init_default_headers()
     self.other_er_magic.init_actual_headers()
     self.other_er_magic.get_all_magic_info()
     #self.frame = magic_gui.MainFrame(self.method_WD)
     self.other_frame = grid_frame.GridFrame(self.other_er_magic, other_WD,
                                             "specimen", "specimen")
     spec = self.other_er_magic.specimens[0]
     self.assertNotIn('magic_method_codes',
                      self.other_frame.grid.col_labels)
     self.assertNotIn('magic_method_codes++',
                      self.other_frame.grid.col_labels)
Beispiel #6
0
    def make_grid_frame(self, event):
        """
        Create a GridFrame for data type of the button that was clicked
        """
        if self.grid_frame:
            print '-I- You already have a grid frame open'
            pw.simple_warning("You already have a grid open")
            return

        try:
            grid_type = event.GetButtonObj().Name[:-4]  # remove '_btn'
        except AttributeError:
            grid_type = self.FindWindowById(
                event.Id).Name[:-4]  # remove ('_btn')
        wait = wx.BusyInfo('Making {} grid, please wait...'.format(grid_type))
        wx.Yield()
        # hide mainframe
        self.on_open_grid_frame()
        self.grid_frame = grid_frame.GridFrame(self.er_magic, self.WD,
                                               grid_type, grid_type,
                                               self.panel)
        if self.validation_mode:
            if grid_type in self.validation_mode:
                self.grid_frame.grid.paint_invalid_cells(
                    self.warn_dict[grid_type])
                #self.grid_frame.msg_boxsizer
                current_label = self.grid_frame.msg_text.GetLabel()
                add_text = """\n\nColumns and rows with problem data have been highlighted in blue.
Cells with problem data are highlighted with different colors according to the type of problem.
Red: missing required data
Green: missing or invalid parent
Blue: non-numeric data provided in a numeric field
Gray: unrecognized column
Purple: invalid result child
Yellow: Out-of-range latitude (should be -90 - 90) or longitude (should be 0-360)
Light gray: Unrecognized term in controlled vocabulary

Note: It is possible to have a row highlighted that has no highlighted column.
This means that you are missing information higher up in the data.
For example: a specimen could be missing a site name.
However, you need to fix this in the sample grid, not the specimen grid.
Once each item in the data has its proper parent, validations will be correct.
"""
                self.grid_frame.msg_text.SetLabel(add_text)
        #self.on_finish_change_dir(self.change_dir_dialog)
        del wait