Beispiel #1
0
    def test_dive_profile_block_parsing(self):
        """
        Test dive profile data block parsing
        """
        dump = ostc_parser.get_data(od.RAW_DATA_OSTC)
        profiles = tuple(ostc_parser.profiles(dump.profiles))
        h, p = profiles[0]
        header = ostc_parser.header(h)
        dive = tuple(ostc_parser.dive_data(header, p))
        # 217 samples, but dive time is 32:09 (sampling 10)
        self.assertEquals(193, len(dive))

        self.assertAlmostEquals(3.0, dive[0].depth, 3)
        self.assertFalse(dive[0].alarm)
        self.assertAlmostEquals(23.0, dive[1].depth, 3)
        self.assertFalse(dive[1].alarm)

        self.assertAlmostEquals(29.5, dive[5].temp, 3)
        self.assertEquals(5, dive[5].alarm)
        self.assertEquals(2, dive[5].current_gas)
        self.assertEquals(0, dive[5].deco_depth)
        self.assertEquals(7, dive[5].deco_time)

        self.assertAlmostEquals(29.0, dive[23].temp, 3)
        self.assertFalse(dive[23].alarm)
        self.assertFalse(dive[23].current_gas)
        self.assertEquals(3, dive[23].deco_depth)
        self.assertEquals(1, dive[23].deco_time)
Beispiel #2
0
    def test_gas_info_error(self):
        """
        Test OSTC error when fetching gas mix from header
        """
        dives = ostc_parser.profiles(od.RAW_DATA_OSTC_MK2_194)
        header, profile = list(dives)[7]
        header = ostc_parser.header(header)
        dc = OSTCDataParser()

        self.assertRaises(ValueError, dc._get_gas, None, 255)
Beispiel #3
0
    def test_invalid_profile(self):
        """
        Test parsing invalid profile
        """
        data = tuple(ostc_parser.profiles(ku._dump_decode(od.DATA_OSTC_BROKEN)))
        assert 32 == len(data)

        # dive no 31 is broken (count from 0)
        h, p = data[30]
        header = ostc_parser.header(h)
        dive_data = ostc_parser.dive_data(header, p)
        self.assertRaises(ValueError, tuple, dive_data)
Beispiel #4
0
 def test_dive_profile_header_parsing_191(self):
     """
     Test dive profile header parsing (>= 1.91)
     """
     dump = ostc_parser.get_data(od.RAW_DATA_OSTC_MK2_194)
     profiles = tuple(ostc_parser.profiles(dump.profiles))
     header = ostc_parser.header(profiles[8][0])
     self.assertEquals(0x21, header.version)
     self.assertEquals(7, header.month)
     self.assertEquals(28, header.day)
     self.assertEquals(11, header.year)
     self.assertEquals(22, header.hour)
     self.assertEquals(31, header.minute)
     self.assertEquals(6016, header.max_depth)
     self.assertEquals(64, header.dive_time_m)
     self.assertEquals(4, header.dive_time_s)
     self.assertEquals(57, header.min_temp)
     self.assertEquals(975, header.surface_pressure)
     self.assertEquals(248, header.desaturation)
     self.assertEquals(21, header.gas1_o2)
     self.assertEquals(47, header.gas2_o2)
     self.assertEquals(100, header.gas3_o2)
     self.assertEquals(12, header.gas4_o2)
     self.assertEquals(17, header.gas5_o2)
     self.assertEquals(10, header.gas6_o2)
     self.assertEquals(0, header.gas1_he)
     self.assertEquals(0, header.gas2_he)
     self.assertEquals(0, header.gas3_he)
     self.assertEquals(45, header.gas4_he)
     self.assertEquals(37, header.gas5_he)
     self.assertEquals(50, header.gas6_he)
     self.assertEquals(4, header.gas)
     self.assertEquals(1, header.ver1)
     self.assertEquals(93, header.ver2)
     self.assertEquals(4066, header.voltage)
     self.assertEquals(4, header.sampling)
     self.assertEquals(47, header.div_temp)
     self.assertEquals(47, header.div_deco)
     self.assertEquals(16, header.div_gf)
     self.assertEquals(48, header.div_ppo2)
     self.assertEquals(144, header.div_deco_debug)
     self.assertEquals(16, header.div_cns)
     self.assertEquals(100, header.salnity)
     self.assertEquals(36, header.max_cns)
     self.assertEquals(2085, header.avg_depth)
     self.assertEquals(4123, header.dive_time_total_s)
     self.assertEquals(10, header.gf_lo)
     self.assertEquals(85, header.gf_hi)
     self.assertEquals(5, header.deco_type)
     self.assertEquals(0, header.reserved1)
     self.assertEquals(0, header.reserved2)
     self.assertEquals(0, header.reserved3)
Beispiel #5
0
 def test_data_get(self):
     """
     Test OSTC data getting (< 1.91)
     """
     dump = ostc_parser.get_data(od.RAW_DATA_OSTC)
     profile = tuple(ostc_parser.profiles(dump.profiles))
     # five dives expected
     self.assertEquals(5, len(profile))
     for header, block in profile:
         self.assertEquals(b'\xfa\xfa', header[:2])
         self.assertEquals(0x20, header[2])
         self.assertEquals(b'\xfb\xfb', header[-2:])
         self.assertEquals(47, len(header))
         self.assertEquals(b'\xfd\xfd', block[-2:])
Beispiel #6
0
    def test_date_bug(self):
        """
        Test OSTC date bug
        """
        data = tuple(ostc_parser.profiles(ku._dump_decode(od.DATA_OSTC_DATE_BUG)))
        d1 = data[16]
        d2 = data[17]

        # dive 17 and 18 - incorrect month information
        header = ostc_parser.header(d1[0])
        self.assertEquals(1, header.month)

        header = ostc_parser.header(d2[0])
        self.assertEquals(1, header.month)
Beispiel #7
0
    def test_gas_info(self):
        """
        Test OSTC gas fetching from header
        """
        dives = ostc_parser.profiles(od.RAW_DATA_OSTC_MK2_194)
        header, profile = list(dives)[7]
        header = ostc_parser.header(header)
        dc = OSTCDataParser()

        self.assertEquals('air', dc._get_gas(header, 1).id)
        self.assertEquals('ean47', dc._get_gas(header, 2).id)
        self.assertEquals('o2', dc._get_gas(header, 3).id)
        self.assertEquals('tx1340', dc._get_gas(header, 4).id)
        self.assertEquals('tx1737', dc._get_gas(header, 5).id)
        self.assertEquals('tx1050', dc._get_gas(header, 6).id)
Beispiel #8
0
 def test_data_get_191(self):
     """
     Test OSTC data getting (>= 1.91)
     """
     dump = ostc_parser.get_data(od.RAW_DATA_OSTC_MK2_194)
     profile = tuple(ostc_parser.profiles(dump.profiles))
     # five dives expected
     self.assertEquals(9, len(profile))
     for i, (header, block) in enumerate(profile):
         self.assertEquals(b'\xfa\xfa', header[:2])
         if i < 2:
             self.assertEquals(0x20, header[2])
             self.assertEquals(47, len(header))
         else:
             self.assertEquals(0x21, header[2])
             self.assertEquals(57, len(header))
         self.assertEquals(b'\xfb\xfb', header[-2:])
         self.assertEquals(b'\xfd\xfd', block[-2:])
Beispiel #9
0
 def test_dive_profile_header_parsing(self):
     """
     Test dive profile header parsing (< 1.91)
     """
     dump = ostc_parser.get_data(od.RAW_DATA_OSTC)
     profile = tuple(ostc_parser.profiles(dump.profiles))
     header = ostc_parser.header(profile[0][0])
     self.assertEquals(0x20, header.version)
     self.assertEquals(1, header.month)
     self.assertEquals(31, header.day)
     self.assertEquals(9, header.year)
     self.assertEquals(23, header.hour)
     self.assertEquals(41, header.minute)
     self.assertEquals(7500, header.max_depth)
     self.assertEquals(32, header.dive_time_m)
     self.assertEquals(9, header.dive_time_s)
     self.assertEquals(275, header.min_temp)
     self.assertEquals(1025, header.surface_pressure)
     self.assertEquals(920, header.desaturation)
     self.assertEquals(21, header.gas1_o2)
     self.assertEquals(32, header.gas2_o2)
     self.assertEquals(21, header.gas3_o2)
     self.assertEquals(21, header.gas4_o2)
     self.assertEquals(21, header.gas5_o2)
     self.assertEquals(32, header.gas6_o2)
     self.assertEquals(0, header.gas1_he)
     self.assertEquals(0, header.gas2_he)
     self.assertEquals(0, header.gas3_he)
     self.assertEquals(0, header.gas4_he)
     self.assertEquals(0, header.gas5_he)
     self.assertEquals(0, header.gas6_he)
     self.assertEquals(1, header.gas)
     self.assertEquals(1, header.ver1)
     self.assertEquals(26, header.ver2)
     self.assertEquals(4066, header.voltage)
     self.assertEquals(10, header.sampling)
     self.assertEquals(38, header.div_temp)
     self.assertEquals(38, header.div_deco)
     self.assertEquals(32, header.div_gf)
     self.assertEquals(48, header.div_ppo2)
     self.assertEquals(0, header.div_deco_debug)
     self.assertEquals(0, header.div_cns)
     self.assertEquals(0, header.salnity)
     self.assertEquals(0, header.max_cns)