class TestDiveAirDiveOutput2(TestDive): """Test segments output for air dive 2.""" expected_result = [ " DESCENT: at 20m for 1:00 [RT: 1:00], on Air, SP:0.0, END:19m", " CONST: at 20m for 29:00 [RT: 30:00], on Air, SP:0.0, END:19m", " ASCENT: at 9m for 1:06 [RT: 31:06], on Air, SP:0.0, END:8m", " DECO: at 9m for 0:01 [RT: 31:07], on Air, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 32:07], on Air, SP:0.0, END:5m", " DECO: at 6m for 0:01 [RT: 32:08], on Air, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 33:08], on Air, SP:0.0, END:2m", " DECO: at 3m for 0:50 [RT: 33:58], on Air, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 34:58], on Air, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg2 = SegmentDive(20, 30 * 60, self.airtank, 0) self.profile1 = Dive([diveseg2], [self.airtank]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % (idx, self.profile1.output_segments[idx]))
class TestDiveAirDiveOutput2(TestDive): """Test segments output for air dive 2.""" expected_result = [ " DESCENT: at 20m for 1:00 [RT: 1:00], on Air, SP:0.0, END:19m", " CONST: at 20m for 29:00 [RT: 30:00], on Air, SP:0.0, END:19m", " ASCENT: at 9m for 1:06 [RT: 31:06], on Air, SP:0.0, END:8m", " DECO: at 9m for 0:01 [RT: 31:07], on Air, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 32:07], on Air, SP:0.0, END:5m", " DECO: at 6m for 0:01 [RT: 32:08], on Air, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 33:08], on Air, SP:0.0, END:2m", " DECO: at 3m for 0:50 [RT: 33:58], on Air, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 34:58], on Air, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg2 = SegmentDive(20, 30 * 60, self.airtank, 0) self.profile1 = Dive([diveseg2], [self.airtank]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % ( idx, self.profile1.output_segments[idx]))
class TestDiveAirDiveOutput1(TestDive): """Test segments output for air dive 1.""" expected_result = [ " DESCENT: at 30m for 1:30 [RT: 1:30], on Air, SP:0.0, END:29m", " CONST: at 30m for 28:30 [RT: 30:00], on Air, SP:0.0, END:29m", " ASCENT: at 15m for 1:30 [RT: 31:30], on Air, SP:0.0, END:14m", " DECO: at 15m for 0:01 [RT: 31:31], on Air, SP:0.0, END:14m", " ASCENT: at 12m for 1:00 [RT: 32:31], on Air, SP:0.0, END:11m", " DECO: at 12m for 0:20 [RT: 32:51], on Air, SP:0.0, END:11m", " ASCENT: at 9m for 1:00 [RT: 33:51], on Air, SP:0.0, END:8m", " DECO: at 9m for 2:39 [RT: 36:30], on Air, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 37:30], on Air, SP:0.0, END:5m", " DECO: at 6m for 4:59 [RT: 42:29], on Air, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 43:29], on Air, SP:0.0, END:2m", " DECO: at 3m for 12:42 [RT: 56:11], on Air, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 57:11], on Air, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg1 = SegmentDive(30, 30 * 60, self.airtank, 0) self.profile1 = Dive([diveseg1], [self.airtank]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % ( idx, self.profile1.output_segments[idx]))
class TestDiveTxDiveOutput1(TestDive): """Test segments output for tx dive 1.""" expected_result = [ " DESCENT: at 30m for 1:30 [RT: 1:30], on Trimix 21/30, SP:0.0, END:19m", " CONST: at 30m for 28:30 [RT: 30:00], on Trimix 21/30, SP:0.0, END:19m", " ASCENT: at 15m for 1:30 [RT: 31:30], on Trimix 21/30, SP:0.0, END:8m", " DECO: at 15m for 0:01 [RT: 31:31], on Trimix 21/30, SP:0.0, END:8m", " ASCENT: at 12m for 1:00 [RT: 32:31], on Trimix 21/30, SP:0.0, END:6m", " DECO: at 12m for 0:38 [RT: 33:09], on Trimix 21/30, SP:0.0, END:6m", " ASCENT: at 9m for 1:00 [RT: 34:09], on Trimix 21/30, SP:0.0, END:4m", " DECO: at 9m for 3:04 [RT: 37:13], on Trimix 21/30, SP:0.0, END:4m", " ASCENT: at 6m for 1:00 [RT: 38:13], on Trimix 21/30, SP:0.0, END:1m", " DECO: at 6m for 6:25 [RT: 44:38], on Trimix 21/30, SP:0.0, END:1m", " ASCENT: at 3m for 1:00 [RT: 45:38], on Trimix 21/30, SP:0.0, END:0m", " DECO: at 3m for 16:12 [RT: 61:50], on Trimix 21/30, SP:0.0, END:0m", " ASCENT: at 0m for 1:00 [RT: 62:50], on Trimix 21/30, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg1 = SegmentDive(30, 30 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg1], [self.txtank1]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % ( idx, self.profile1.output_segments[idx]))
class TestDiveTxDiveOutput1(TestDive): """Test segments output for tx dive 1.""" expected_result = [ " DESCENT: at 30m for 1:30 [RT: 1:30], on Trimix 21/30, SP:0.0, END:19m", " CONST: at 30m for 28:30 [RT: 30:00], on Trimix 21/30, SP:0.0, END:19m", " ASCENT: at 15m for 1:30 [RT: 31:30], on Trimix 21/30, SP:0.0, END:8m", " DECO: at 15m for 0:01 [RT: 31:31], on Trimix 21/30, SP:0.0, END:8m", " ASCENT: at 12m for 1:00 [RT: 32:31], on Trimix 21/30, SP:0.0, END:6m", " DECO: at 12m for 0:38 [RT: 33:09], on Trimix 21/30, SP:0.0, END:6m", " ASCENT: at 9m for 1:00 [RT: 34:09], on Trimix 21/30, SP:0.0, END:4m", " DECO: at 9m for 3:04 [RT: 37:13], on Trimix 21/30, SP:0.0, END:4m", " ASCENT: at 6m for 1:00 [RT: 38:13], on Trimix 21/30, SP:0.0, END:1m", " DECO: at 6m for 6:25 [RT: 44:38], on Trimix 21/30, SP:0.0, END:1m", " ASCENT: at 3m for 1:00 [RT: 45:38], on Trimix 21/30, SP:0.0, END:0m", " DECO: at 3m for 16:12 [RT: 61:50], on Trimix 21/30, SP:0.0, END:0m", " ASCENT: at 0m for 1:00 [RT: 62:50], on Trimix 21/30, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg1 = SegmentDive(30, 30 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg1], [self.txtank1]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % (idx, self.profile1.output_segments[idx]))
class TestDiveAirDiveOutput1(TestDive): """Test segments output for air dive 1.""" expected_result = [ " DESCENT: at 30m for 1:30 [RT: 1:30], on Air, SP:0.0, END:29m", " CONST: at 30m for 28:30 [RT: 30:00], on Air, SP:0.0, END:29m", " ASCENT: at 15m for 1:30 [RT: 31:30], on Air, SP:0.0, END:14m", " DECO: at 15m for 0:01 [RT: 31:31], on Air, SP:0.0, END:14m", " ASCENT: at 12m for 1:00 [RT: 32:31], on Air, SP:0.0, END:11m", " DECO: at 12m for 0:20 [RT: 32:51], on Air, SP:0.0, END:11m", " ASCENT: at 9m for 1:00 [RT: 33:51], on Air, SP:0.0, END:8m", " DECO: at 9m for 2:39 [RT: 36:30], on Air, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 37:30], on Air, SP:0.0, END:5m", " DECO: at 6m for 4:59 [RT: 42:29], on Air, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 43:29], on Air, SP:0.0, END:2m", " DECO: at 3m for 12:42 [RT: 56:11], on Air, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 57:11], on Air, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg1 = SegmentDive(30, 30 * 60, self.airtank, 0) self.profile1 = Dive([diveseg1], [self.airtank]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % (idx, self.profile1.output_segments[idx]))
class TestDiveAirDiveRunTime2(TestDive): def runTest(self): diveseg2 = SegmentDive(20, 30 * 60, self.airtank, 0) self.profile2 = Dive([diveseg2], [self.airtank]) self.profile2.do_dive() self.assertEqual(seconds_to_mmss(self.profile2.run_time), ' 32:04', 'bad dive runtime (%s)' % seconds_to_mmss(self.profile2.run_time))
class TestDiveAirDiveRunTime3(TestDive): def runTest(self): diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile3 = Dive([diveseg3], [self.airdouble]) self.profile3.do_dive() self.assertEqual(seconds_to_mmss(self.profile3.run_time), '131:05', 'bad dive runtime (%s)' % seconds_to_mmss(self.profile3.run_time))
class TestDiveTxDiveRunTime1(TestDive): def runTest(self): diveseg1 = SegmentDive(30, 30 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg1], [self.txtank1]) self.profile1.do_dive() self.assertEqual(seconds_to_mmss(self.profile1.run_time), ' 55:03', 'bad dive runtime (%s)' % seconds_to_mmss(self.profile1.run_time))
class TestDiveAirDiveRunTime1(TestDive): def runTest(self): diveseg1 = SegmentDive(30, 30 * 60, self.airtank, 0) self.profile1 = Dive([diveseg1], [self.airtank]) self.profile1.do_dive() self.assertEqual(seconds_to_mmss(self.profile1.run_time), ' 48:24', 'bad dive runtime ? (%s)' % seconds_to_mmss(self.profile1.run_time))
class TestDiveNotEnoughGas1(TestDive): def runTest(self): diveseg1 = SegmentDive(60, 30 * 60, self.air12l, 0) self.profile1 = Dive([diveseg1], [self.air12l]) self.profile1.do_dive() self.assertEqual(self.profile1.tanks[0].check_rule(), False, 'Wrong tank status : it should fail the remaining ' 'gas rule test (result:%s)' % self.profile1.tanks[0].check_rule())
class TestRepetitiveDive1(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(40, 20 * 60, self.airtank12, 0) self.profile0 = Dive([diveseg1], [self.airtank12]) self.profile0.do_dive() diveseg2 = SegmentDive(40, 20 * 60, self.airtank, 0) self.profile1 = Dive([diveseg2], [self.airtank], self.profile0) self.profile1.do_surface_interval(20 * 60) self.profile1.do_dive() def test_rt(self): assert seconds_to_mmss(self.profile1.run_time) == ' 68:09', \ 'bad dive runtime ? (%s)' \ % seconds_to_mmss(self.profile1.run_time) def test_otu(self): self.assertAlmostEqual(self.profile1.model.ox_tox.otu, 40.0702502936, 7, 'bad dive OTU ? (%s)' % self.profile1.model.ox_tox.otu) def test_cns(self): self.assertAlmostEqual(self.profile1.model.ox_tox.cns * 100, 14.3091665925, 7, 'bad dive CNS ? (%s)' % (self.profile1.model.ox_tox.cns * 100)) def test_tank_cons(self): self.assertAlmostEqual(self.airtank12.used_gas, 2115.5196384, 7, 'bad used gas (%s)' % self.airtank12.used_gas) def test_tank_cons_rule(self): self.assertEqual(self.profile1.tanks[0].check_rule(), True, 'Wrong tank status : it should pass the remaining ' 'gas rule test (result:%s)' % self.profile1.tanks[0].check_rule()) def test_no_flight(self): no_flight_time = self.profile1.no_flight_time() self.assertEqual(no_flight_time, 5460, 'Bad no flight time: %s' % no_flight_time) def test_no_flight_wo_exc(self): no_flight_time = self.profile1.no_flight_time_wo_exception() self.assertEqual(no_flight_time, 5460, 'Bad no flight time: %s' % no_flight_time) def test_surfaceint(self): self.assertEqual(self.profile1.get_surface_interval(), ' 20:00', 'wrong surface interval:%s' % self.profile1.get_surface_interval())
class TestDiveNotEnoughGas1(TestDive): """Test a profile with not enough gas.""" def runTest(self): """Not enought gas test""" diveseg1 = SegmentDive(60, 30 * 60, self.air12l, 0) self.profile1 = Dive([diveseg1], [self.air12l]) self.profile1.do_dive() self.assertEqual( self.profile1.tanks[0].check_rule(), False, 'Wrong tank status : it should fail the remaining ' 'gas rule test (result:%s)' % self.profile1.tanks[0].check_rule())
class TestRepetitiveTxDive3(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(55, 20 * 60, self.txtank1, 0) self.profile0 = Dive([diveseg1], [self.txtank1]) self.profile0.do_dive() diveseg2 = SegmentDive(50, 20 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg2], [self.txtank1], self.profile0) self.profile1.do_surface_interval(30 * 60) self.profile1.do_dive() diveseg3 = SegmentDive(35, 35 * 60, self.txtank1, 0) self.profile2 = Dive([diveseg3], [self.txtank1], self.profile1) self.profile2.do_surface_interval(60 * 60) # self.profile2.refill_tanks() self.profile2.do_dive() diveseg4 = SegmentDive(55, 20 * 60, self.txtank1, 0) self.profile3 = Dive([diveseg4], [self.txtank1], self.profile2) self.profile3.do_surface_interval(12 * 60 * 60) # self.profile3.refill_tanks() self.profile3.do_dive() def test_rt(self): assert seconds_to_mmss(self.profile3.run_time) == ' 72:40', \ 'bad dive runtime ? (%s)' \ % seconds_to_mmss(self.profile3.run_time) def test_otu(self): self.assertAlmostEqual(self.profile3.model.ox_tox.otu, 115.825853006, 7, 'bad dive OTU ? (%s)' % self.profile3.model.ox_tox.otu) def test_cns(self): self.assertAlmostEqual(self.profile3.model.ox_tox.cns * 100, 12.6208702934, 7, 'bad dive CNS ? (%s)' % (self.profile3.model.ox_tox.cns * 100)) def test_tank_cons(self): self.assertAlmostEqual(self.txtank1.used_gas, 3350.41341833, 7, 'bad used gas (%s)' % self.txtank1.used_gas) def test_tank_cons_rule(self): self.assertEqual(self.profile3.tanks[0].check_rule(), True, 'Wrong tank status : it should pass the remaining ' 'gas rule test (result:%s)' % self.profile2.tanks[0].check_rule()) def test_no_flight(self): no_flight_time = self.profile3.no_flight_time() self.assertEqual(no_flight_time, 7380, 'Bad no flight time: %s' % no_flight_time)
class TestDiveAirDiveOutput2(TestDive): def setUp(self): TestDive.setUp(self) diveseg2 = SegmentDive(20, 30 * 60, self.airtank, 0) self.profile2 = Dive([diveseg2], [self.airtank]) self.profile2.do_dive() def test_segment1(self): self.assertEqual(str(self.profile2.output_segments[0]), ' DESCENT: at 20m for 1:00 [RT: 1:00], ' 'on Air, SP:0.0, END:19m', 'bad segment (%s)' % self.profile2.output_segments[0]) def test_segment2(self): self.assertEqual(str(self.profile2.output_segments[1]), ' CONST: at 20m for 29:00 [RT: 30:00], ' 'on Air, SP:0.0, END:19m', 'bad segment (%s)' % self.profile2.output_segments[1]) def test_segment3(self): self.assertEqual(str(self.profile2.output_segments[2]), ' ASCENT: at 9m for 1:06 [RT: 31:06], ' 'on Air, SP:0.0, END:8m', 'bad segment (%s)' % self.profile2.output_segments[2]) def test_segment4(self): self.assertEqual(str(self.profile2.output_segments[3]), ' DECO: at 9m for 0:01 [RT: 31:07], ' 'on Air, SP:0.0, END:8m', 'bad segment (%s)' % self.profile2.output_segments[3]) def test_segment5(self): self.assertEqual(str(self.profile2.output_segments[4]), ' DECO: at 6m for 0:01 [RT: 31:08], ' 'on Air, SP:0.0, END:5m', 'bad segment (%s)' % self.profile2.output_segments[4]) def test_segment6(self): self.assertEqual(str(self.profile2.output_segments[5]), ' DECO: at 3m for 0:56 [RT: 32:04], ' 'on Air, SP:0.0, END:2m', 'bad segment (%s)' % self.profile2.output_segments[5])
class TestDiveAir70m10min(TestDive): """Test air 70m 10min.""" params = ((70, 10), ) def runTest(self): """Run one test.""" try: diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.airdouble, 0) self.profile1 = Dive([diveseg1], [self.airdouble]) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail("should raise UnauthorizedMod")
class TestRepetitiveTxDive1(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(55, 20 * 60, self.txtank1, 0) self.profile0 = Dive([diveseg1], [self.txtank1]) self.profile0.do_dive() diveseg2 = SegmentDive(50, 20 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg2], [self.txtank1], self.profile0) self.profile1.do_surface_interval(20 * 60) # self.profile1.refill_tanks() self.profile1.do_dive() def test_rt(self): assert seconds_to_mmss(self.profile1.run_time) == '124:44', \ 'bad dive runtime ? (%s)' \ % seconds_to_mmss(self.profile1.run_time) def test_otu(self): self.assertAlmostEqual(self.profile1.model.ox_tox.otu, 55.5549635111, 7, 'bad dive OTU ? (%s)' % self.profile1.model.ox_tox.otu) def test_cns(self): self.assertAlmostEqual(self.profile1.model.ox_tox.cns * 100, 21.1631708375, 7, 'bad dive CNS ? (%s)' % (self.profile1.model.ox_tox.cns * 100)) def test_tank_cons(self): self.assertAlmostEqual(self.txtank1.used_gas, 4006.7619273, 7, 'bad used gas (%s)' % self.txtank1.used_gas) def test_tank_cons_rule(self): self.assertEqual(self.profile1.tanks[0].check_rule(), True, 'Wrong tank status : it should pass the remaining ' 'gas rule test (result:%s)' % self.profile1.tanks[0].check_rule()) def test_no_flight(self): no_flight_time = self.profile1.no_flight_time() self.assertEqual(no_flight_time, 12660, 'Bad no flight time: %s' % no_flight_time)
class TestDiveTxHypo160m10min(TestDive): """Test TxHypo 160m 10min.""" params = ((160, 10), ) def runTest(self): """Run one test.""" try: diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.txhypo, 0) self.profile1 = Dive([diveseg1], [self.txtravel, self.txhypo, self.deco1]) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail('should raise UnauthorizedMod')
class TestDiveTxNormoDecoNx8070m10min(TestDive): """Test txnormo 70m 10min.""" params = ((70, 10), ) def runTest(self): """Run one test.""" try: diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.txtanknormodbl, 0) self.profile1 = Dive([diveseg1], [self.txtanknormodbl, self.deco1]) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail("should raise UnauthorizedMod")
class TestDiveTxHypo160m10min(TestDive): """Test tx hypo 160m 10min.""" params = ((160, 10),) def runTest(self): """Should raise an error.""" try: diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.txhypo, 0) self.profile1 = Dive( [SegmentDive(40, 130, self.txtravel, 0), SegmentDive(40, 30, self.txhypo, 0), diveseg1], [self.txtravel, self.txhypo, self.deco1], ) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail("should raise UnauthorizedMod")
class TestDiveCCAir50m10min(TestDive): """Test air 70m 10min.""" params = ((50, 10),) def runTest(self): """Run one test.""" try: self.setpoint = 1.2 self.dive_tank = self.ccair self.all_tanks = [self.ccair] diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.dive_tank, self.setpoint) self.profile1 = Dive([diveseg1], self.all_tanks) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail("should raise UnauthorizedMod")
class TestDiveAirDiveOutput4(TestDive): """Test segments output for air dive 4.""" expected_result = [ " DESCENT: at 55m for 2:45 [RT: 2:45], on Air, SP:0.0, END:53m", " CONST: at 55m for 27:15 [RT: 30:00], on Air, SP:0.0, END:53m", " ASCENT: at 30m for 2:30 [RT: 32:30], on Air, SP:0.0, END:29m", " DECO: at 30m for 0:01 [RT: 32:31], on Air, SP:0.0, END:29m", " ASCENT: at 27m for 1:00 [RT: 33:31], on Air, SP:0.0, END:26m", " DECO: at 27m for 1:11 [RT: 34:42], on Air, SP:0.0, END:26m", " ASCENT: at 24m for 1:00 [RT: 35:42], on Air, SP:0.0, END:23m", " DECO: at 24m for 1:27 [RT: 37:09], on Air, SP:0.0, END:23m", " ASCENT: at 21m for 1:00 [RT: 38:09], on Air, SP:0.0, END:20m", " DECO: at 21m for 1:35 [RT: 39:44], on Nitrox 50, SP:0.0, END:20m", " ASCENT: at 18m for 1:00 [RT: 40:44], on Nitrox 50, SP:0.0, END:17m", " DECO: at 18m for 2:03 [RT: 42:47], on Nitrox 50, SP:0.0, END:17m", " ASCENT: at 15m for 1:00 [RT: 43:47], on Nitrox 50, SP:0.0, END:14m", " DECO: at 15m for 2:55 [RT: 46:42], on Nitrox 50, SP:0.0, END:14m", " ASCENT: at 12m for 1:00 [RT: 47:42], on Nitrox 50, SP:0.0, END:11m", " DECO: at 12m for 4:13 [RT: 51:55], on Nitrox 50, SP:0.0, END:11m", " ASCENT: at 9m for 1:00 [RT: 52:55], on Nitrox 50, SP:0.0, END:8m", " DECO: at 9m for 6:41 [RT: 59:36], on Nitrox 50, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 60:36], on Nitrox 50, SP:0.0, END:5m", " DECO: at 6m for 7:20 [RT: 67:56], on Oxygen, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 68:56], on Oxygen, SP:0.0, END:2m", " DECO: at 3m for 12:32 [RT: 81:28], on Oxygen, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 82:28], on Oxygen, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile1 = Dive([diveseg3], [self.airdouble, self.decoo2, self.deco2]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % ( idx, self.profile1.output_segments[idx]))
class TestDiveAirDiveOutput4(TestDive): """Test segments output for air dive 4.""" expected_result = [ " DESCENT: at 55m for 2:45 [RT: 2:45], on Air, SP:0.0, END:53m", " CONST: at 55m for 27:15 [RT: 30:00], on Air, SP:0.0, END:53m", " ASCENT: at 30m for 2:30 [RT: 32:30], on Air, SP:0.0, END:29m", " DECO: at 30m for 0:01 [RT: 32:31], on Air, SP:0.0, END:29m", " ASCENT: at 27m for 1:00 [RT: 33:31], on Air, SP:0.0, END:26m", " DECO: at 27m for 1:11 [RT: 34:42], on Air, SP:0.0, END:26m", " ASCENT: at 24m for 1:00 [RT: 35:42], on Air, SP:0.0, END:23m", " DECO: at 24m for 1:27 [RT: 37:09], on Air, SP:0.0, END:23m", " ASCENT: at 21m for 1:00 [RT: 38:09], on Air, SP:0.0, END:20m", " DECO: at 21m for 1:35 [RT: 39:44], on Nitrox 50, SP:0.0, END:20m", " ASCENT: at 18m for 1:00 [RT: 40:44], on Nitrox 50, SP:0.0, END:17m", " DECO: at 18m for 2:03 [RT: 42:47], on Nitrox 50, SP:0.0, END:17m", " ASCENT: at 15m for 1:00 [RT: 43:47], on Nitrox 50, SP:0.0, END:14m", " DECO: at 15m for 2:55 [RT: 46:42], on Nitrox 50, SP:0.0, END:14m", " ASCENT: at 12m for 1:00 [RT: 47:42], on Nitrox 50, SP:0.0, END:11m", " DECO: at 12m for 4:13 [RT: 51:55], on Nitrox 50, SP:0.0, END:11m", " ASCENT: at 9m for 1:00 [RT: 52:55], on Nitrox 50, SP:0.0, END:8m", " DECO: at 9m for 6:41 [RT: 59:36], on Nitrox 50, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 60:36], on Nitrox 50, SP:0.0, END:5m", " DECO: at 6m for 7:20 [RT: 67:56], on Oxygen, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 68:56], on Oxygen, SP:0.0, END:2m", " DECO: at 3m for 12:32 [RT: 81:28], on Oxygen, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 82:28], on Oxygen, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile1 = Dive([diveseg3], [self.airdouble, self.decoo2, self.deco2]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % (idx, self.profile1.output_segments[idx]))
class TestDiveCCRDiveOutput1(TestDive): """Test segments output for ccr dive 1.""" expected_result = [ " DESCENT: at 55m for 2:45 [RT: 2:45], on Trimix 21/30, SP:1.4, END:38m", " CONST: at 55m for 27:15 [RT: 30:00], on Trimix 21/30, SP:1.4, END:38m", " ASCENT: at 30m for 2:30 [RT: 32:30], on Trimix 21/30, SP:1.4, END:21m", " DECO: at 30m for 0:01 [RT: 32:31], on Trimix 21/30, SP:1.4, END:21m", " ASCENT: at 27m for 1:00 [RT: 33:31], on Trimix 21/30, SP:1.4, END:19m", " DECO: at 27m for 0:31 [RT: 34:02], on Trimix 21/30, SP:1.4, END:19m", " ASCENT: at 24m for 1:00 [RT: 35:02], on Trimix 21/30, SP:1.4, END:17m", " DECO: at 24m for 1:02 [RT: 36:04], on Trimix 21/30, SP:1.4, END:17m", " ASCENT: at 21m for 1:00 [RT: 37:04], on Trimix 21/30, SP:1.4, END:15m", " DECO: at 21m for 1:26 [RT: 38:30], on Trimix 21/30, SP:1.4, END:15m", " ASCENT: at 18m for 1:00 [RT: 39:30], on Trimix 21/30, SP:1.4, END:13m", " DECO: at 18m for 1:55 [RT: 41:25], on Trimix 21/30, SP:1.4, END:13m", " ASCENT: at 15m for 1:00 [RT: 42:25], on Trimix 21/30, SP:1.4, END:11m", " DECO: at 15m for 2:21 [RT: 44:46], on Trimix 21/30, SP:1.4, END:11m", " ASCENT: at 12m for 1:00 [RT: 45:46], on Trimix 21/30, SP:1.4, END:9m", " DECO: at 12m for 3:21 [RT: 49:07], on Trimix 21/30, SP:1.4, END:9m", " ASCENT: at 9m for 1:00 [RT: 50:07], on Trimix 21/30, SP:1.4, END:7m", " DECO: at 9m for 5:15 [RT: 55:22], on Trimix 21/30, SP:1.4, END:7m", " ASCENT: at 6m for 1:00 [RT: 56:22], on Trimix 21/30, SP:1.4, END:4m", " DECO: at 6m for 6:44 [RT: 63:06], on Oxygen, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 64:06], on Oxygen, SP:0.0, END:2m", " DECO: at 3m for 12:26 [RT: 76:32], on Oxygen, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 77:32], on Oxygen, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg1 = SegmentDive(55, 30 * 60, self.txtank1, 1.4) self.profile1 = Dive([diveseg1], [self.txtank1, self.decoo2]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % ( idx, self.profile1.output_segments[idx]))
class TestDiveCCTxHypo110m10min(TestDive): """test CC tx hypo 110m 10min.""" params = ((110, 10), ) def runTest(self): """Should raise and error.""" try: self.setpoint = 1.2 self.dive_tank = self.cctxhypo self.all_tanks = [self.cctxhypo] diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.dive_tank, self.setpoint) self.profile1 = Dive([diveseg1], self.all_tanks) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail("should raise UnauthorizedMod")
class TestDiveCCAir50m10min(TestDive): """Test air 70m 10min.""" params = ((50, 10), ) def runTest(self): """Run one test.""" try: self.setpoint = 1.2 self.dive_tank = self.ccair self.all_tanks = [self.ccair] diveseg1 = SegmentDive(self.params[0][0], self.params[0][1] * 60, self.dive_tank, self.setpoint) self.profile1 = Dive([diveseg1], self.all_tanks) self.profile1.do_dive() except UnauthorizedMod: pass else: self.fail("should raise UnauthorizedMod")
class TestDiveAirDiveOutput3(TestDive): """Test segments output for air dive 3.""" expected_result = [ " DESCENT: at 55m for 2:45 [RT: 2:45], on Air, SP:0.0, END:53m", " CONST: at 55m for 27:15 [RT: 30:00], on Air, SP:0.0, END:53m", " ASCENT: at 30m for 2:30 [RT: 32:30], on Air, SP:0.0, END:29m", " DECO: at 30m for 0:01 [RT: 32:31], on Air, SP:0.0, END:29m", " ASCENT: at 27m for 1:00 [RT: 33:31], on Air, SP:0.0, END:26m", " DECO: at 27m for 1:11 [RT: 34:42], on Air, SP:0.0, END:26m", " ASCENT: at 24m for 1:00 [RT: 35:42], on Air, SP:0.0, END:23m", " DECO: at 24m for 1:27 [RT: 37:09], on Air, SP:0.0, END:23m", " ASCENT: at 21m for 1:00 [RT: 38:09], on Air, SP:0.0, END:20m", " DECO: at 21m for 2:34 [RT: 40:43], on Air, SP:0.0, END:20m", " ASCENT: at 18m for 1:00 [RT: 41:43], on Air, SP:0.0, END:17m", " DECO: at 18m for 3:17 [RT: 45:00], on Air, SP:0.0, END:17m", " ASCENT: at 15m for 1:00 [RT: 46:00], on Air, SP:0.0, END:14m", " DECO: at 15m for 5:24 [RT: 51:24], on Air, SP:0.0, END:14m", " ASCENT: at 12m for 1:00 [RT: 52:24], on Air, SP:0.0, END:11m", " DECO: at 12m for 7:02 [RT: 59:26], on Air, SP:0.0, END:11m", " ASCENT: at 9m for 1:00 [RT: 60:26], on Air, SP:0.0, END:8m", " DECO: at 9m for 13:49 [RT: 74:15], on Air, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 75:15], on Air, SP:0.0, END:5m", " DECO: at 6m for 25:28 [RT:100:43], on Air, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT:101:43], on Air, SP:0.0, END:2m", " DECO: at 3m for 52:20 [RT:154:03], on Air, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT:155:03], on Air, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile1 = Dive([diveseg3], [self.airdouble]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % (idx, self.profile1.output_segments[idx]))
class TestDiveAirDiveOutput3(TestDive): """Test segments output for air dive 3.""" expected_result = [ " DESCENT: at 55m for 2:45 [RT: 2:45], on Air, SP:0.0, END:53m", " CONST: at 55m for 27:15 [RT: 30:00], on Air, SP:0.0, END:53m", " ASCENT: at 30m for 2:30 [RT: 32:30], on Air, SP:0.0, END:29m", " DECO: at 30m for 0:01 [RT: 32:31], on Air, SP:0.0, END:29m", " ASCENT: at 27m for 1:00 [RT: 33:31], on Air, SP:0.0, END:26m", " DECO: at 27m for 1:11 [RT: 34:42], on Air, SP:0.0, END:26m", " ASCENT: at 24m for 1:00 [RT: 35:42], on Air, SP:0.0, END:23m", " DECO: at 24m for 1:27 [RT: 37:09], on Air, SP:0.0, END:23m", " ASCENT: at 21m for 1:00 [RT: 38:09], on Air, SP:0.0, END:20m", " DECO: at 21m for 2:34 [RT: 40:43], on Air, SP:0.0, END:20m", " ASCENT: at 18m for 1:00 [RT: 41:43], on Air, SP:0.0, END:17m", " DECO: at 18m for 3:17 [RT: 45:00], on Air, SP:0.0, END:17m", " ASCENT: at 15m for 1:00 [RT: 46:00], on Air, SP:0.0, END:14m", " DECO: at 15m for 5:24 [RT: 51:24], on Air, SP:0.0, END:14m", " ASCENT: at 12m for 1:00 [RT: 52:24], on Air, SP:0.0, END:11m", " DECO: at 12m for 7:02 [RT: 59:26], on Air, SP:0.0, END:11m", " ASCENT: at 9m for 1:00 [RT: 60:26], on Air, SP:0.0, END:8m", " DECO: at 9m for 13:49 [RT: 74:15], on Air, SP:0.0, END:8m", " ASCENT: at 6m for 1:00 [RT: 75:15], on Air, SP:0.0, END:5m", " DECO: at 6m for 25:28 [RT:100:43], on Air, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT:101:43], on Air, SP:0.0, END:2m", " DECO: at 3m for 52:20 [RT:154:03], on Air, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT:155:03], on Air, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile1 = Dive([diveseg3], [self.airdouble]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % ( idx, self.profile1.output_segments[idx]))
class TestDiveCCRDiveOutput1(TestDive): """Test segments output for ccr dive 1.""" expected_result = [ " DESCENT: at 55m for 2:45 [RT: 2:45], on Trimix 21/30, SP:1.4, END:38m", " CONST: at 55m for 27:15 [RT: 30:00], on Trimix 21/30, SP:1.4, END:38m", " ASCENT: at 30m for 2:30 [RT: 32:30], on Trimix 21/30, SP:1.4, END:21m", " DECO: at 30m for 0:01 [RT: 32:31], on Trimix 21/30, SP:1.4, END:21m", " ASCENT: at 27m for 1:00 [RT: 33:31], on Trimix 21/30, SP:1.4, END:19m", " DECO: at 27m for 0:31 [RT: 34:02], on Trimix 21/30, SP:1.4, END:19m", " ASCENT: at 24m for 1:00 [RT: 35:02], on Trimix 21/30, SP:1.4, END:17m", " DECO: at 24m for 1:02 [RT: 36:04], on Trimix 21/30, SP:1.4, END:17m", " ASCENT: at 21m for 1:00 [RT: 37:04], on Trimix 21/30, SP:1.4, END:15m", " DECO: at 21m for 1:26 [RT: 38:30], on Trimix 21/30, SP:1.4, END:15m", " ASCENT: at 18m for 1:00 [RT: 39:30], on Trimix 21/30, SP:1.4, END:13m", " DECO: at 18m for 1:55 [RT: 41:25], on Trimix 21/30, SP:1.4, END:13m", " ASCENT: at 15m for 1:00 [RT: 42:25], on Trimix 21/30, SP:1.4, END:11m", " DECO: at 15m for 2:21 [RT: 44:46], on Trimix 21/30, SP:1.4, END:11m", " ASCENT: at 12m for 1:00 [RT: 45:46], on Trimix 21/30, SP:1.4, END:9m", " DECO: at 12m for 3:21 [RT: 49:07], on Trimix 21/30, SP:1.4, END:9m", " ASCENT: at 9m for 1:00 [RT: 50:07], on Trimix 21/30, SP:1.4, END:7m", " DECO: at 9m for 5:15 [RT: 55:22], on Trimix 21/30, SP:1.4, END:7m", " ASCENT: at 6m for 1:00 [RT: 56:22], on Trimix 21/30, SP:1.4, END:4m", " DECO: at 6m for 6:44 [RT: 63:06], on Oxygen, SP:0.0, END:5m", " ASCENT: at 3m for 1:00 [RT: 64:06], on Oxygen, SP:0.0, END:2m", " DECO: at 3m for 12:26 [RT: 76:32], on Oxygen, SP:0.0, END:2m", " ASCENT: at 0m for 1:00 [RT: 77:32], on Oxygen, SP:0.0, END:0m", ] def setUp(self): """Init of the tests.""" super().setUp() diveseg1 = SegmentDive(55, 30 * 60, self.txtank1, 1.4) self.profile1 = Dive([diveseg1], [self.txtank1, self.decoo2]) self.profile1.do_dive() def test_segments(self): """Check all segments.""" for idx in range(len(self.expected_result)): self.assertEqual( str(self.profile1.output_segments[idx]), self.expected_result[idx], 'bad segment n°%s (%s)' % (idx, self.profile1.output_segments[idx]))
class TestRepetitiveTxDive2(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(55, 20 * 60, self.txtank1, 0) self.profile0 = Dive([diveseg1], [self.txtank1]) self.profile0.do_dive() diveseg2 = SegmentDive(50, 20 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg2], [self.txtank1], self.profile0) self.profile1.do_surface_interval(30 * 60) self.profile1.do_dive() diveseg3 = SegmentDive(35, 35 * 60, self.txtank1, 0) self.profile2 = Dive([diveseg3], [self.txtank1], self.profile1) self.profile2.do_surface_interval(60 * 60) # self.profile2.refill_tanks() self.profile2.do_dive() def test_rt(self): assert seconds_to_mmss(self.profile2.run_time) == '166:21', \ 'bad dive runtime ? (%s)' \ % seconds_to_mmss(self.profile2.run_time) def test_otu(self): self.assertAlmostEqual(self.profile2.model.ox_tox.otu, 86.5037540773, 7, 'bad dive OTU ? (%s)' % self.profile2.model.ox_tox.otu) def test_cns(self): self.assertAlmostEqual(self.profile2.model.ox_tox.cns * 100, 24.2843630006, 7, 'bad dive CNS ? (%s)' % (self.profile2.model.ox_tox.cns * 100)) def test_tank_cons(self): self.assertAlmostEqual(self.txtank1.used_gas, 4979.54636588, 7, 'bad used gas (%s)' % self.txtank1.used_gas) def test_tank_cons_rule(self): self.assertEqual(self.profile2.tanks[0].check_rule(), True, 'Wrong tank status : it should pass the remaining ' 'gas rule test (result:%s)' % self.profile2.tanks[0].check_rule()) def test_no_flight(self): no_flight_time = self.profile2.no_flight_time() self.assertEqual(no_flight_time, 18960, 'Bad no flight time: %s' % no_flight_time)
class TestDiveCCRDiveOutput1(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(55, 30 * 60, self.txtank1, 1.4) self.profile1 = Dive([diveseg1], [self.txtank1, self.decoo2]) self.profile1.do_dive() def test_segment1(self): self.assertEqual(str(self.profile1.output_segments[0]), ' DESCENT: at 55m for 2:45 [RT: 2:45], ' 'on Trimix 21/30, SP:1.4, END:38m', 'bad segment (%s)' % self.profile1.output_segments[0]) def test_segment2(self): self.assertEqual(str(self.profile1.output_segments[1]), ' CONST: at 55m for 27:15 [RT: 30:00], ' 'on Trimix 21/30, SP:1.4, END:38m', 'bad segment (%s)' % self.profile1.output_segments[1]) def test_segment3(self): self.assertEqual(str(self.profile1.output_segments[2]), ' ASCENT: at 30m for 2:30 [RT: 32:30], ' 'on Trimix 21/30, SP:1.4, END:21m', 'bad segment (%s)' % self.profile1.output_segments[2]) def test_segment4(self): self.assertEqual(str(self.profile1.output_segments[3]), ' DECO: at 30m for 0:01 [RT: 32:31], ' 'on Trimix 21/30, SP:1.4, END:21m', 'bad segment (%s)' % self.profile1.output_segments[3]) def test_segment5(self): self.assertEqual(str(self.profile1.output_segments[4]), ' DECO: at 27m for 0:36 [RT: 33:07], ' 'on Trimix 21/30, SP:1.4, END:19m', 'bad segment (%s)' % self.profile1.output_segments[4]) def test_segment6(self): self.assertEqual(str(self.profile1.output_segments[5]), ' DECO: at 24m for 1:08 [RT: 34:15], ' 'on Trimix 21/30, SP:1.4, END:17m', 'bad segment (%s)' % self.profile1.output_segments[5]) def test_segment7(self): self.assertEqual(str(self.profile1.output_segments[6]), ' DECO: at 21m for 1:32 [RT: 35:47], ' 'on Trimix 21/30, SP:1.4, END:15m', 'bad segment (%s)' % self.profile1.output_segments[6]) def test_segment8(self): self.assertEqual(str(self.profile1.output_segments[7]), ' DECO: at 18m for 2:01 [RT: 37:48], ' 'on Trimix 21/30, SP:1.4, END:13m', 'bad segment (%s)' % self.profile1.output_segments[7]) def test_segment9(self): self.assertEqual(str(self.profile1.output_segments[8]), ' DECO: at 15m for 2:14 [RT: 40:02], ' 'on Trimix 21/30, SP:1.4, END:11m', 'bad segment (%s)' % self.profile1.output_segments[8]) def test_segment10(self): self.assertEqual(str(self.profile1.output_segments[9]), ' DECO: at 12m for 3:21 [RT: 43:23], ' 'on Trimix 21/30, SP:1.4, END:9m', 'bad segment (%s)' % self.profile1.output_segments[9]) def test_segment11(self): self.assertEqual(str(self.profile1.output_segments[10]), ' DECO: at 9m for 5:05 [RT: 48:28], ' 'on Trimix 21/30, SP:1.4, END:7m', 'bad segment (%s)' % self.profile1.output_segments[10]) def test_segment12(self): self.assertEqual(str(self.profile1.output_segments[11]), ' DECO: at 6m for 6:28 [RT: 54:56], ' 'on Oxygen, SP:0.0, END:5m', 'bad segment (%s)' % self.profile1.output_segments[11]) def test_segment13(self): self.assertEqual(str(self.profile1.output_segments[12]), ' DECO: at 3m for 11:52 [RT: 66:48], ' 'on Oxygen, SP:0.0, END:2m', 'bad segment (%s)' % self.profile1.output_segments[12])
class TestDiveTxDiveOutput1(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(30, 30 * 60, self.txtank1, 0) self.profile1 = Dive([diveseg1], [self.txtank1]) self.profile1.do_dive() def test_segment1(self): self.assertEqual(str(self.profile1.output_segments[0]), ' DESCENT: at 30m for 1:30 [RT: 1:30], ' 'on Trimix 21/30, SP:0.0, END:19m', 'bad segment (%s)' % self.profile1.output_segments[0]) def test_segment2(self): self.assertEqual(str(self.profile1.output_segments[1]), ' CONST: at 30m for 28:30 [RT: 30:00], ' 'on Trimix 21/30, SP:0.0, END:19m', 'bad segment (%s)' % self.profile1.output_segments[1]) def test_segment3(self): self.assertEqual(str(self.profile1.output_segments[2]), ' ASCENT: at 15m for 1:30 [RT: 31:30], ' 'on Trimix 21/30, SP:0.0, END:8m', 'bad segment (%s)' % self.profile1.output_segments[2]) def test_segment4(self): self.assertEqual(str(self.profile1.output_segments[3]), ' DECO: at 15m for 0:01 [RT: 31:31], ' 'on Trimix 21/30, SP:0.0, END:8m', 'bad segment (%s)' % self.profile1.output_segments[3]) def test_segment5(self): self.assertEqual(str(self.profile1.output_segments[4]), ' DECO: at 12m for 0:43 [RT: 32:14], ' 'on Trimix 21/30, SP:0.0, END:6m', 'bad segment (%s)' % self.profile1.output_segments[4]) def test_segment6(self): self.assertEqual(str(self.profile1.output_segments[5]), ' DECO: at 9m for 3:08 [RT: 35:22], ' 'on Trimix 21/30, SP:0.0, END:4m', 'bad segment (%s)' % self.profile1.output_segments[5]) def test_segment7(self): self.assertEqual(str(self.profile1.output_segments[6]), ' DECO: at 6m for 5:15 [RT: 40:37], ' 'on Trimix 21/30, SP:0.0, END:1m', 'bad segment (%s)' % self.profile1.output_segments[6]) def test_segment8(self): self.assertEqual(str(self.profile1.output_segments[7]), ' DECO: at 3m for 14:26 [RT: 55:03], ' 'on Trimix 21/30, SP:0.0, END:0m', 'bad segment (%s)' % self.profile1.output_segments[7])
class TestDiveAirDiveOutput4(TestDive): def setUp(self): TestDive.setUp(self) diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile3 = Dive([diveseg3], [self.airdouble, self.decoo2, self.deco2]) self.profile3.do_dive() def test_segment1(self): self.assertEqual(str(self.profile3.output_segments[0]), ' DESCENT: at 55m for 2:45 [RT: 2:45], ' 'on Air, SP:0.0, END:53m', 'bad segment (%s)' % self.profile3.output_segments[0]) def test_segment2(self): self.assertEqual(str(self.profile3.output_segments[1]), ' CONST: at 55m for 27:15 [RT: 30:00], ' 'on Air, SP:0.0, END:53m', 'bad segment (%s)' % self.profile3.output_segments[1]) def test_segment3(self): self.assertEqual(str(self.profile3.output_segments[2]), ' ASCENT: at 30m for 2:30 [RT: 32:30], ' 'on Air, SP:0.0, END:29m', 'bad segment (%s)' % self.profile3.output_segments[2]) def test_segment4(self): self.assertEqual(str(self.profile3.output_segments[3]), ' DECO: at 30m for 0:01 [RT: 32:31], ' 'on Air, SP:0.0, END:29m', 'bad segment (%s)' % self.profile3.output_segments[3]) def test_segment5(self): self.assertEqual(str(self.profile3.output_segments[4]), ' DECO: at 27m for 1:15 [RT: 33:46], ' 'on Air, SP:0.0, END:26m', 'bad segment (%s)' % self.profile3.output_segments[4]) def test_segment6(self): self.assertEqual(str(self.profile3.output_segments[5]), ' DECO: at 24m for 1:33 [RT: 35:19], ' 'on Air, SP:0.0, END:23m', 'bad segment (%s)' % self.profile3.output_segments[5]) def test_segment7(self): self.assertEqual(str(self.profile3.output_segments[6]), ' DECO: at 21m for 1:37 [RT: 36:56], ' 'on Nitrox 50, SP:0.0, END:20m', 'bad segment (%s)' % self.profile3.output_segments[6]) def test_segment8(self): self.assertEqual(str(self.profile3.output_segments[7]), ' DECO: at 18m for 2:09 [RT: 39:05], ' 'on Nitrox 50, SP:0.0, END:17m', 'bad segment (%s)' % self.profile3.output_segments[7]) def test_segment9(self): self.assertEqual(str(self.profile3.output_segments[8]), ' DECO: at 15m for 2:59 [RT: 42:04], ' 'on Nitrox 50, SP:0.0, END:14m', 'bad segment (%s)' % self.profile3.output_segments[8]) def test_segment10(self): self.assertEqual(str(self.profile3.output_segments[9]), ' DECO: at 12m for 4:18 [RT: 46:22], ' 'on Nitrox 50, SP:0.0, END:11m', 'bad segment (%s)' % self.profile3.output_segments[9]) def test_segment11(self): self.assertEqual(str(self.profile3.output_segments[10]), ' DECO: at 9m for 5:48 [RT: 52:10], ' 'on Nitrox 50, SP:0.0, END:8m', 'bad segment (%s)' % self.profile3.output_segments[10]) def test_segment12(self): self.assertEqual(str(self.profile3.output_segments[11]), ' DECO: at 6m for 6:40 [RT: 58:50], ' 'on Oxygen, SP:0.0, END:5m', 'bad segment (%s)' % self.profile3.output_segments[11]) def test_segment13(self): self.assertEqual(str(self.profile3.output_segments[12]), ' DECO: at 3m for 11:31 [RT: 70:21], ' 'on Oxygen, SP:0.0, END:2m', 'bad segment (%s)' % self.profile3.output_segments[12])
class TestRepetitiveDive2(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(40, 20 * 60, self.airtank12, 0) self.profile0 = Dive([diveseg1], [self.airtank12]) self.profile0.do_dive() diveseg2 = SegmentDive(30, 40 * 60, self.airtank, 0) self.profile1 = Dive([diveseg2], [self.airtank], self.profile0) self.profile1.do_surface_interval(30 * 60) self.profile1.do_dive() diveseg3 = SegmentDive(25, 35 * 60, self.airtank, 0) self.profile2 = Dive([diveseg3], [self.airtank], self.profile1) self.profile2.do_surface_interval(60 * 60) # self.profile2.refill_tanks() self.profile2.do_dive() def test_rt(self): assert seconds_to_mmss(self.profile2.run_time) == ' 70:18', \ 'bad dive runtime ? (%s)' \ % seconds_to_mmss(self.profile2.run_time) def test_otu(self): self.assertAlmostEqual(self.profile2.model.ox_tox.otu, 66.8427163401, 7, 'bad dive OTU ? (%s)' % self.profile2.model.ox_tox.otu) def test_cns(self): self.assertAlmostEqual(self.profile2.model.ox_tox.cns * 100, 18.1490350581, 7, 'bad dive CNS ? (%s)' % (self.profile2.model.ox_tox.cns * 100)) def test_tank_cons(self): self.assertAlmostEqual(self.airtank.used_gas, 2701.73162947, 7, 'bad used gas (%s)' % self.airtank.used_gas) def test_tank_cons_rule(self): self.assertEqual(self.profile2.tanks[0].check_rule(), True, 'Wrong tank status : it should pass the remaining ' 'gas rule test (result:%s)' % self.profile2.tanks[0].check_rule()) def test_no_flight(self): no_flight_time = self.profile2.no_flight_time() self.assertEqual(no_flight_time, 18360, 'Bad no flight time: %s' % no_flight_time) def test_no_flight_wo_exc(self): no_flight_time = self.profile2.no_flight_time_wo_exception() self.assertEqual(no_flight_time, 18360, 'Bad no flight time: %s' % no_flight_time) def test_surfaceint(self): self.assertEqual(self.profile2.get_surface_interval(), ' 60:00', 'wrong surface interval:%s' % self.profile2.get_surface_interval())
class TestDiveAirDiveOutput3(TestDive): def setUp(self): TestDive.setUp(self) diveseg3 = SegmentDive(55, 30 * 60, self.airdouble, 0) self.profile3 = Dive([diveseg3], [self.airdouble]) self.profile3.do_dive() def test_segment1(self): self.assertEqual(str(self.profile3.output_segments[0]), ' DESCENT: at 55m for 2:45 [RT: 2:45], ' 'on Air, SP:0.0, END:53m', 'bad segment (%s)' % self.profile3.output_segments[0]) def test_segment2(self): self.assertEqual(str(self.profile3.output_segments[1]), ' CONST: at 55m for 27:15 [RT: 30:00], ' 'on Air, SP:0.0, END:53m', 'bad segment (%s)' % self.profile3.output_segments[1]) def test_segment3(self): self.assertEqual(str(self.profile3.output_segments[2]), ' ASCENT: at 30m for 2:30 [RT: 32:30], ' 'on Air, SP:0.0, END:29m', 'bad segment (%s)' % self.profile3.output_segments[2]) def test_segment4(self): self.assertEqual(str(self.profile3.output_segments[3]), ' DECO: at 30m for 0:01 [RT: 32:31], ' 'on Air, SP:0.0, END:29m', 'bad segment (%s)' % self.profile3.output_segments[3]) def test_segment5(self): self.assertEqual(str(self.profile3.output_segments[4]), ' DECO: at 27m for 1:15 [RT: 33:46], ' 'on Air, SP:0.0, END:26m', 'bad segment (%s)' % self.profile3.output_segments[4]) def test_segment6(self): self.assertEqual(str(self.profile3.output_segments[5]), ' DECO: at 24m for 1:33 [RT: 35:19], ' 'on Air, SP:0.0, END:23m', 'bad segment (%s)' % self.profile3.output_segments[5]) def test_segment7(self): self.assertEqual(str(self.profile3.output_segments[6]), ' DECO: at 21m for 2:37 [RT: 37:56], ' 'on Air, SP:0.0, END:20m', 'bad segment (%s)' % self.profile3.output_segments[6]) def test_segment8(self): self.assertEqual(str(self.profile3.output_segments[7]), ' DECO: at 18m for 3:23 [RT: 41:19], ' 'on Air, SP:0.0, END:17m', 'bad segment (%s)' % self.profile3.output_segments[7]) def test_segment9(self): self.assertEqual(str(self.profile3.output_segments[8]), ' DECO: at 15m for 5:26 [RT: 46:45], ' 'on Air, SP:0.0, END:14m', 'bad segment (%s)' % self.profile3.output_segments[8]) def test_segment10(self): self.assertEqual(str(self.profile3.output_segments[9]), ' DECO: at 12m for 6:41 [RT: 53:26], ' 'on Air, SP:0.0, END:11m', 'bad segment (%s)' % self.profile3.output_segments[9]) def test_segment11(self): self.assertEqual(str(self.profile3.output_segments[10]), ' DECO: at 9m for 11:01 [RT: 64:27], ' 'on Air, SP:0.0, END:8m', 'bad segment (%s)' % self.profile3.output_segments[10]) def test_segment12(self): self.assertEqual(str(self.profile3.output_segments[11]), ' DECO: at 6m for 21:36 [RT: 86:03], ' 'on Air, SP:0.0, END:5m', 'bad segment (%s)' % self.profile3.output_segments[11]) def test_segment13(self): self.assertEqual(str(self.profile3.output_segments[12]), ' DECO: at 3m for 45:02 [RT:131:05], ' 'on Air, SP:0.0, END:2m', 'bad segment (%s)' % self.profile3.output_segments[12])
class TestDive(unittest.TestCase): """Generic Test Dive class.""" params = ((0, 0), ) def setUp(self): """Init of the tests.""" # temporary hack (tests): super().setUp() activate_debug_for_tests() # settings.RUN_TIME = True # settings.SURFACE_TEMP = 12 self.air12l = Tank(tank_vol=12.0, tank_pressure=200, tank_rule="10b") self.airtank = Tank(tank_vol=18.0, tank_pressure=200, tank_rule="10b") self.airtank12 = Tank(tank_vol=12.0, tank_pressure=200, tank_rule="10b") self.airdouble = Tank(tank_vol=30.0, tank_pressure=200, tank_rule="10b") # bi15l 200b self.txtank1 = Tank(0.21, 0.30, tank_vol=20.0, tank_pressure=200, tank_rule="10b") self.txtanknormodbl = Tank(0.21, 0.30, tank_vol=30.0, tank_pressure=200, tank_rule="10b") self.txhypo = Tank(0.10, 0.50, tank_vol=30.0, tank_pressure=200) # 2x 15l self.txtravel = Tank(0.21, 0.30, tank_vol=24.0, tank_pressure=200) # 2x S80 self.ccair = Tank(tank_vol=3.0, tank_pressure=200, tank_rule='10b') self.cctxhypo = Tank(0.10, 0.50, tank_vol=3.0, tank_pressure=200, tank_rule='10b') self.setpoint = 1.2 self.deco1 = Tank(0.8, 0.0, tank_vol=7.0, tank_pressure=200, tank_rule="10b") self.deco2 = Tank(0.5, 0.0, tank_vol=7.0, tank_pressure=200, tank_rule="10b") self.decoo2 = Tank(1.0, 0.0, tank_vol=7.0, tank_pressure=200, tank_rule="10b") self.setpoint = 0.0 self.dive_tank = None self.all_tanks = None self.dive_segs = [] def do_dive(self): """do the actual dive. self.params is in the form ((depth, time), (depth, time)) each couple of depth, time is a segment of the same dive. """ if not hasattr(self, 'name'): self.name = '%s:%s' % (self.params[0][0], self.params[0][1]) for param in self.params: self.dive_segs.append( SegmentDive(param[0], param[1] * 60, self.dive_tank, self.setpoint)) self.profile1 = Dive(self.dive_segs, self.all_tanks) self.profile1.do_dive() # self.write_details() def do_repetitive_dive(self): """do the actual dive. self.params is in the form: ((depth, time, interval), (depth, time, interval)) each couple of depth, time, interval is a full dive at the given depth interval is done before the dive. """ if not hasattr(self, 'name'): self.name = '%s:%s' % (self.params[0][0], self.params[0][1]) self.profiles = [] # repetive dive profiles. for param in self.params: if len(self.profiles) > 0: self.profiles.append( Dive([ SegmentDive(param[0], param[1] * 60, self.dive_tank, self.setpoint) ], self.all_tanks, self.profiles[-1])) self.profiles[-1].do_surface_interval(param[2] * 60) else: self.profiles.append( Dive([ SegmentDive(param[0], param[1] * 60, self.dive_tank, self.setpoint) ], self.all_tanks)) self.profiles[-1].do_dive() self.profile1 = self.profiles[-1] # save last dive # self.write_details() def tearDown(self): """After tests.""" # settings.SURFACE_TEMP = 20 settings.RUN_TIME = True @property def details(self): """Output details of the dive. :returns: string :rtype: str """ return '"%s": ["%s", %f, %f, %d, %d, %f, %s], ' % ( self.name, seconds_to_mmss(self.profile1.run_time), self.profile1.model.ox_tox.otu, self.profile1.model.ox_tox.cns * 100, self.profile1.no_flight_time(), self.profile1.full_desat_time(), self.profile1.tanks[0].used_gas, str(self.profile1.tanks[0].check_rule()).lower()) def print_details(self): """print detailed results.""" print(self.details) def write_details(self): """write in /tmp/details.txt the detailed results.""" with open('/tmp/details.txt', 'a') as myfile: myfile.write(self.details + '\n')
class TestDive(unittest.TestCase): """Generic Test Dive class.""" params = ((0, 0), ) def setUp(self): """Init of the tests.""" # temporary hack (tests): super().setUp() activate_debug_for_tests() # settings.RUN_TIME = True # settings.SURFACE_TEMP = 12 self.air12l = Tank(tank_vol=12.0, tank_pressure=200, tank_rule="10b") self.airtank = Tank(tank_vol=18.0, tank_pressure=200, tank_rule="10b") self.airtank12 = Tank(tank_vol=12.0, tank_pressure=200, tank_rule="10b") self.airdouble = Tank(tank_vol=30.0, tank_pressure=200, tank_rule="10b") # bi15l 200b self.txtank1 = Tank(0.21, 0.30, tank_vol=20.0, tank_pressure=200, tank_rule="10b") self.txtanknormodbl = Tank(0.21, 0.30, tank_vol=30.0, tank_pressure=200, tank_rule="10b") self.txhypo = Tank(0.10, 0.50, tank_vol=30.0, tank_pressure=200) # 2x 15l self.txtravel = Tank(0.21, 0.30, tank_vol=24.0, tank_pressure=200) # 2x S80 self.ccair = Tank(tank_vol=3.0, tank_pressure=200, tank_rule='10b') self.cctxhypo = Tank(0.10, 0.50, tank_vol=3.0, tank_pressure=200, tank_rule='10b') self.setpoint = 1.2 self.deco1 = Tank(0.8, 0.0, tank_vol=7.0, tank_pressure=200, tank_rule="10b") self.deco2 = Tank(0.5, 0.0, tank_vol=7.0, tank_pressure=200, tank_rule="10b") self.decoo2 = Tank(1.0, 0.0, tank_vol=7.0, tank_pressure=200, tank_rule="10b") self.setpoint = 0.0 self.dive_tank = None self.all_tanks = None self.dive_segs = [] def do_dive(self): """do the actual dive. self.params is in the form ((depth, time), (depth, time)) each couple of depth, time is a segment of the same dive. """ if not hasattr(self, 'name'): self.name = '%s:%s' % (self.params[0][0], self.params[0][1]) for param in self.params: self.dive_segs.append(SegmentDive(param[0], param[1] * 60, self.dive_tank, self.setpoint)) self.profile1 = Dive(self.dive_segs, self.all_tanks) self.profile1.do_dive() # self.write_details() def do_repetitive_dive(self): """do the actual dive. self.params is in the form: ((depth, time, interval), (depth, time, interval)) each couple of depth, time, interval is a full dive at the given depth interval is done before the dive. """ if not hasattr(self, 'name'): self.name = '%s:%s' % (self.params[0][0], self.params[0][1]) self.profiles = [] # repetive dive profiles. for param in self.params: if len(self.profiles) > 0: self.profiles.append( Dive([SegmentDive(param[0], param[1] * 60, self.dive_tank, self.setpoint)], self.all_tanks, self.profiles[-1])) self.profiles[-1].do_surface_interval(param[2] * 60) else: self.profiles.append( Dive([SegmentDive(param[0], param[1] * 60, self.dive_tank, self.setpoint)], self.all_tanks)) self.profiles[-1].do_dive() self.profile1 = self.profiles[-1] # save last dive # self.write_details() def tearDown(self): """After tests.""" # settings.SURFACE_TEMP = 20 settings.RUN_TIME = True @property def details(self): """Output details of the dive. :returns: string :rtype: str """ return '"%s": ["%s", %f, %f, %d, %d, %f, %s], ' % ( self.name, seconds_to_mmss(self.profile1.run_time), self.profile1.model.ox_tox.otu, self.profile1.model.ox_tox.cns * 100, self.profile1.no_flight_time(), self.profile1.full_desat_time(), self.profile1.tanks[0].used_gas, str(self.profile1.tanks[0].check_rule()).lower()) def print_details(self): """print detailed results.""" print(self.details) def write_details(self): """write in /tmp/details.txt the detailed results.""" with open('/tmp/details.txt', 'a') as myfile: myfile.write(self.details + '\n')
class TestDiveAirDiveOutput1(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(30, 30 * 60, self.airtank, 0) self.profile1 = Dive([diveseg1], [self.airtank]) self.profile1.do_dive() def test_segment1(self): self.assertEqual(str(self.profile1.output_segments[0]), ' DESCENT: at 30m for 1:30 [RT: 1:30], ' 'on Air, SP:0.0, END:29m', 'bad segment (%s)' % self.profile1.output_segments[0]) def test_segment2(self): self.assertEqual(str(self.profile1.output_segments[1]), ' CONST: at 30m for 28:30 [RT: 30:00], ' 'on Air, SP:0.0, END:29m', 'bad segment (%s)' % self.profile1.output_segments[1]) def test_segment3(self): self.assertEqual(str(self.profile1.output_segments[2]), ' ASCENT: at 15m for 1:30 [RT: 31:30], ' 'on Air, SP:0.0, END:14m', 'bad segment (%s)' % self.profile1.output_segments[2]) def test_segment4(self): self.assertEqual(str(self.profile1.output_segments[3]), ' DECO: at 15m for 0:01 [RT: 31:31], ' 'on Air, SP:0.0, END:14m', 'bad segment (%s)' % self.profile1.output_segments[3]) def test_segment5(self): self.assertEqual(str(self.profile1.output_segments[4]), ' DECO: at 12m for 0:25 [RT: 31:56], ' 'on Air, SP:0.0, END:11m', 'bad segment (%s)' % self.profile1.output_segments[4]) def test_segment6(self): self.assertEqual(str(self.profile1.output_segments[5]), ' DECO: at 9m for 2:42 [RT: 34:38], ' 'on Air, SP:0.0, END:8m', 'bad segment (%s)' % self.profile1.output_segments[5]) def test_segment7(self): self.assertEqual(str(self.profile1.output_segments[6]), ' DECO: at 6m for 5:02 [RT: 39:40], ' 'on Air, SP:0.0, END:5m', 'bad segment (%s)' % self.profile1.output_segments[6]) def test_segment8(self): self.assertEqual(str(self.profile1.output_segments[7]), ' DECO: at 3m for 8:44 [RT: 48:24], ' 'on Air, SP:0.0, END:2m', 'bad segment (%s)' % self.profile1.output_segments[7])
class TestRepetitiveDive3(TestDive): def setUp(self): TestDive.setUp(self) diveseg1 = SegmentDive(40, 20 * 60, self.airtank12, 0) self.profile0 = Dive([diveseg1], [self.airtank12]) self.profile0.do_dive() diveseg2 = SegmentDive(30, 40 * 60, self.airtank, 0) self.profile1 = Dive([diveseg2], [self.airtank], self.profile0) self.profile1.do_surface_interval(30 * 60) self.profile1.do_dive() diveseg3 = SegmentDive(25, 35 * 60, self.airtank, 0) self.profile2 = Dive([diveseg3], [self.airtank], self.profile1) self.profile2.do_surface_interval(60 * 60) # self.profile2.refill_tanks() self.profile2.do_dive() diveseg4 = SegmentDive(40, 20 * 60, self.airtank, 0) self.profile3 = Dive([diveseg4], [self.airtank], self.profile2) self.profile3.do_surface_interval(12 * 60 * 60) # self.profile3.refill_tanks() self.profile3.do_dive() def test_rt(self): assert seconds_to_mmss(self.profile3.run_time) == ' 38:36', \ 'bad dive runtime ? (%s)' \ % seconds_to_mmss(self.profile3.run_time) def test_otu(self): self.assertAlmostEqual(self.profile3.model.ox_tox.otu, 86.8657204829, 7, 'bad dive OTU ? (%s)' % self.profile3.model.ox_tox.otu) def test_cns(self): self.assertAlmostEqual(self.profile3.model.ox_tox.cns * 100, 7.75546902304, 7, 'bad dive CNS ? (%s)' % (self.profile3.model.ox_tox.cns * 100)) def test_tank_cons(self): self.assertAlmostEqual(self.airtank.used_gas, 2115.5196384, 7, 'bad used gas (%s)' % self.airtank.used_gas) def test_tank_cons_rule(self): self.assertEqual(self.profile3.tanks[0].check_rule(), True, 'Wrong tank status : it should pass the remaining ' 'gas rule test (result:%s)' % self.profile2.tanks[0].check_rule()) def test_no_flight(self): no_flight_time = self.profile3.no_flight_time() self.assertEqual(no_flight_time, 1620, 'Bad no flight time: %s' % no_flight_time) def test_no_flight_wo_exc(self): no_flight_time = self.profile3.no_flight_time_wo_exception() self.assertEqual(no_flight_time, 1620, 'Bad no flight time: %s' % no_flight_time) def test_surfaceint(self): self.assertEqual(self.profile3.get_surface_interval(), '720:00', 'wrong surface interval:%s' % self.profile3.get_surface_interval())