Пример #1
0
def get_scan(path: str, file_extension: str, file_type: str) -> Scan:
    """Factory method to return a new Scan instance for the given file type.

    Args:
        path (str): Path to the file that will be read by the `Scan`
        file_extension (str): Extension of file to scan.
        file_type (str): type of file. eg "Raw Files", "SVP Files"

    Returns:
        New `Scan` instance

    Raises:
        NotImplementedError: if `file_type` is not supported
    """
    if (file_extension.lower() == 'all' and file_type == 'Raw Files'):
        return ScanALL(path)
    elif (file_extension.lower() == 'kmall' and file_type == 'Raw Files'):
        return ScanKMALL(path)
    elif (file_extension.lower() == 'gsf' and file_type == 'Raw Files'):
        return ScanGsf(path)
    elif (file_type == 'SVP Files'):
        # could have any extension
        return ScanSvp(path)
    elif (file_type == 'Trueheave Files'):
        # could have any extension
        return ScanTrueheave(path)
    else:
        raise NotImplementedError(
            "File type {} is not supported".format(file_type))
Пример #2
0
 def setUpClass(cls):
     cls.test_file = os.path.abspath(
         os.path.join(os.path.dirname(__file__), "test_data_remote",
                      TEST_FILE))
     cls.test = ScanALL(cls.test_file)
     cls.test.scan_datagram()
     load_test_data()
     print('setUpClass')
Пример #3
0
def get_scan(path: str, file_type: str) -> Scan:
    """Factory method to return a new Scan instance for the given file type.

    Args:
        path (str): Path to the file that will be read by the `Scan`
        file_type (str): Type of file to scan. Currently only `all` files are
            supported.

    Returns:
        New `Scan` instance

    Raises:
        NotImplementedError: if `file_type` is not supported
    """
    if (file_type.lower() == 'all'):
        return ScanALL(path)
    else:
        raise NotImplementedError(
            "File type {} is not supported".format(file_type))
Пример #4
0
 def setUp(self):
     self.test_file = os.path.abspath(
         os.path.join(os.path.dirname(__file__), "test_data", TEST_FILE))
     self.test = ScanALL(self.test_file)
     self.test.scan_datagram()
Пример #5
0
class TestMateScanALL(unittest.TestCase):
    def setUp(self):
        self.test_file = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "test_data", TEST_FILE))
        self.test = ScanALL(self.test_file)
        self.test.scan_datagram()

    def test_time_str(self):
        return self.test._time_str(time.time())

    def test_get_datagram_info(self):
        D = self.test.get_datagram_info('D')
        self.assertEqual(D, None)
        Y = self.test.get_datagram_info('Y')
        self.assertEqual(Y['byteCount'], 81386)

    def test_get_size_n_pings(self):
        self.test.get_size_n_pings(2)

    def test_pings(self):
        self.assertEqual(self.test.get_total_pings('N'), 11)
        self.assertEqual(self.test.get_missed_pings('N'), 0)
        self.assertEqual(self.test.get_total_pings('-'), 0)
        self.assertEqual(self.test.get_missed_pings('-'), 0)
        self.assertEqual(self.test.get_total_pings(), 31)
        self.assertEqual(self.test.get_missed_pings(), 0)
        self.assertTrue(self.test.is_missing_pings_tolerable())
        self.assertTrue(self.test.has_minimum_pings())

    def test_is_size_matched(self):
        self.assertTrue(self.test.is_size_matched())

    def test_is_filename_changed(self):
        self.assertTrue(self.test.is_filename_changed())

    def test_is_date_match(self):
        self.assertTrue(self.test.is_date_match())

    def test_bathymetry_availability(self):
        self.assertEqual(self.test.bathymetry_availability(), scan.A_PARTIAL)

    def test_backscatter_availability(self):
        self.assertEqual(self.test.backscatter_availability(), scan.A_PARTIAL)

    def test_ray_tracing_availability(self):
        self.assertFalse(self.test.ray_tracing_availability())

    def test_ellipsoid_height_availability(self):
        self.assertTrue(self.test.ellipsoid_height_availability())

    def test_PU_status(self):
        self.assertEqual(self.test.PU_status(), scan.A_PASS)