def test_outputs(self): prj = BaseProject(projects_folder=testing.output_data_folder()) prj.output_shp = True self.assertTrue(prj.output_shp) prj.output_kml = True self.assertTrue(prj.output_kml) prj.output_svp = True self.assertTrue(prj.output_svp)
def test_clear_project_data(self): prj = BaseProject(projects_folder=testing.output_data_folder()) prj.survey_label = "test" self.assertTrue(len(prj.survey_label) != 0) prj.clear_data() self.assertEqual(len(prj.s57_list), 0) self.assertEqual(len(prj.ss_list), 0) self.assertEqual(len(prj.survey_label), 0)
def test_select_layers_in_cur_grid(self): prj = BaseProject(projects_folder=testing.output_data_folder()) prj.add_to_grid_list(testing.input_test_files(".bag")[0]) prj.set_cur_grid(testing.input_test_files(".bag")[0]) prj.open_to_read_cur_grid() self.assertEqual(len(prj.selected_layers_in_cur_grid), 0) prj.selected_layers_in_cur_grid = [layer_types['depth'], ] self.assertEqual(len(prj.selected_layers_in_cur_grid), 1)
def test_grid_read(self): prj = BaseProject(projects_folder=testing.output_data_folder()) self.assertTrue(prj.cur_grid is None) self.assertFalse(prj.has_grid()) with self.assertRaises(RuntimeError): _ = prj.cur_grid_basename prj.add_to_grid_list(testing.input_test_files(".bag")[0]) prj.set_cur_grid(testing.input_test_files(".bag")[0]) prj.open_to_read_cur_grid() self.assertTrue(prj.cur_grid is not None) self.assertTrue(prj.has_grid()) self.assertGreater(len(prj.cur_grid_basename), 0)
def test_cur_grid_shape(self): prj = BaseProject(projects_folder=testing.output_data_folder()) prj.add_to_grid_list(testing.input_test_files(".bag")[0]) prj.set_cur_grid(testing.input_test_files(".bag")[0]) prj.open_to_read_cur_grid() self.assertEquals(prj.cur_grid_shape[0], 0) self.assertEquals(prj.cur_grid_shape[1], 0)
def test_s57_list_add_real(self): prj = BaseProject(projects_folder=testing.output_data_folder()) prj.add_to_s57_list(testing.input_test_files(".000")[0]) self.assertEqual(len(prj.s57_list), 1) prj.add_to_s57_list(testing.input_test_files(".000")[0]) self.assertEqual(len(prj.s57_list), 1) prj.remove_from_s57_list(testing.input_test_files(".000")[0]) self.assertEqual(len(prj.s57_list), 0)
def test_make_project_survey_label(self): prj = BaseProject(projects_folder=None) prj.add_to_s57_list(testing.input_test_files(".000")[0]) prj.read_feature_file(testing.input_test_files(".000")[0]) self.assertTrue(len(prj.survey_label) != 0) self.assertTrue(len(prj.survey_label) == 6) self.assertEqual(prj.survey_label, "tiny__")
def test_s57_read(self): prj = BaseProject(projects_folder=testing.output_data_folder()) self.assertTrue(prj.cur_s57 is None) self.assertFalse(prj.has_s57()) self.assertEqual(len(prj.cur_s57_basename), 0) prj.read_feature_file(testing.input_test_files(".000")[0]) self.assertTrue(prj.cur_s57 is not None) self.assertTrue(prj.has_s57()) self.assertGreater(len(prj.cur_s57_basename), 0)
def test_raise_window(self): BaseProject.raise_window()
def test_s57_list(self): prj = BaseProject(projects_folder=testing.output_data_folder()) self.assertEqual(len(prj.s57_list), 0)
def test_s57_list_add_fake(self): prj = BaseProject(projects_folder=testing.output_data_folder()) with self.assertRaises(RuntimeError): prj.add_to_s57_list("fake/fake.000")
def test_make_project_survey_label_from_path(self): prj = BaseProject(projects_folder=None) survey_label = prj.make_survey_label_from_path("fake/H012345") self.assertTrue(len(survey_label) != 0) self.assertTrue(len(survey_label) == 6) self.assertEqual(survey_label, "H01234")
def test_init_project_with_folder(self): prj = BaseProject(projects_folder=testing.output_data_folder()) self.assertTrue(os.path.exists(prj.output_folder))
def test_init_project_survey_label(self): prj = BaseProject(projects_folder=None) self.assertTrue(len(prj.survey_label) == 0)
def test_cur_grid_has_layers(self): prj = BaseProject(projects_folder=testing.output_data_folder()) with self.assertRaises(RuntimeError): prj.cur_grid_has_depth_layer() with self.assertRaises(RuntimeError): prj.cur_grid_has_product_uncertainty_layer() with self.assertRaises(RuntimeError): prj.cur_grid_has_density_layer() with self.assertRaises(RuntimeError): prj.cur_grid_has_tvu_qc_layer() with self.assertRaises(RuntimeError): prj.cur_grid_tvu_qc_layers() with self.assertRaises(RuntimeError): prj.set_cur_grid_tvu_qc_name("fake") prj.add_to_grid_list(testing.input_test_files(".bag")[0]) prj.set_cur_grid(testing.input_test_files(".bag")[0]) prj.open_to_read_cur_grid() self.assertTrue(prj.cur_grid_has_depth_layer()) self.assertTrue(prj.cur_grid_has_product_uncertainty_layer()) self.assertFalse(prj.cur_grid_has_density_layer()) self.assertFalse(prj.cur_grid_has_tvu_qc_layer()) self.assertEqual(len(prj.cur_grid_tvu_qc_layers()), 0) self.assertTrue(prj.has_bag_grid()) self.assertFalse(prj.has_csar_grid())
def test_init_project_field_profile(self): prj = BaseProject(projects_folder=testing.output_data_folder(), profile=BaseProject.project_profiles['field']) self.assertEqual(prj.active_profile, BaseProject.project_profiles['field'])
def test_init_project_none_folder(self): prj = BaseProject(projects_folder=None) self.assertTrue(os.path.exists(prj.output_folder))
def test_s57_list_clear(self): prj = BaseProject(projects_folder=testing.output_data_folder()) prj.add_to_s57_list(testing.input_test_files(".000")[0]) prj.clear_s57_list() self.assertEqual(len(prj.s57_list), 0)
def test_default_output_folder(self): out = BaseProject.default_output_folder() self.assertTrue("Base" in out)
def test_output_folder(self): prj = BaseProject(projects_folder=testing.output_data_folder()) with self.assertRaises(RuntimeError): prj.output_folder = "C:/invalid/path/to/folder"
def test_init_project_valid_profile(self): prj = BaseProject(projects_folder=testing.output_data_folder()) self.assertTrue(prj.active_profile in BaseProject.project_profiles.values())
def _bag_checks_v1(self, grid_file: str, idx: int, total: int) -> bool: quantum = 100.0 / total cur_quantum = quantum * idx self.progress.update(value=cur_quantum + quantum * 0.05, text="[%d/%d] File opening" % (idx + 1, total)) # we want to be sure that the label is based on the name of the new file input self._survey = BaseProject.make_survey_label_from_path(grid_file) self._grid_basename = os.path.basename(grid_file) # skip CSAR if not bag.BAGFile.is_bag(bag_path=grid_file): # skip CSAR logger.debug('not a BAG file: %s' % grid_file) return False self._is_vr = bag.BAGFile.is_vr(bag_path=grid_file) if self._is_vr: logger.debug('detected VR BAG') self._bc_report = Report(lib_name=lib_name, lib_version=lib_version) self.progress.update(value=cur_quantum + quantum * 0.15, text="[%d/%d] Structure checking" % (idx + 1, total)) self._bag_checks_v1_structure(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.3, text="[%d/%d] Metadata checking" % (idx + 1, total)) self._bag_checks_v1_metadata(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.5, text="[%d/%d] Elevation checking" % (idx + 1, total)) self._bag_checks_v1_elevation(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.7, text="[%d/%d] Uncertainty checking" % (idx + 1, total)) self._bag_checks_v1_uncertainty(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.85, text="[%d/%d] Tracking list checking" % (idx + 1, total)) self._bag_checks_v1_tracking_list(grid_file=grid_file) self.progress.update(value=cur_quantum + quantum * 0.95, text="[%d/%d] Summary" % (idx + 1, total)) self._bag_checks_v1_summary() output_pdf = os.path.join( self.bagchecks_output_folder, "%s.BCv1.%s.pdf" % (self._grid_basename, datetime.now().strftime("%Y%m%d.%H%M%S"))) if self._noaa_nbs_profile: title_pdf = "BAG Checks v1 - Tests against NOAA OCS Profile" else: title_pdf = "BAG Checks v1 - Tests against General Profile" if self._bc_report.generate_pdf(output_pdf, title_pdf, use_colors=True): self._bc_pdf = output_pdf return True