示例#1
0
    def __call__(self, args):
        """
        Execute command for copying dives into logbook file.
        """
        import kenozooid.logbook as kl

        r, f = args.input
        kl.copy_dives(f, r, args.dives, args.logbook)
示例#2
0
    def test_dive_copy_with_no_gases(self):
        """
        Test copying dives having no gas data
        """
        fl = '{}/dive_copy_logbook.uddf'.format(self.tdir)

        kl.copy_dives([self.fin], ['2'], None, fl)
        nodes = ku.find(fl, '//uddf:dive')

        dn = next(nodes)
        self.assertEquals([], list(ku.xp(dn, './/uddf:switchmix/@ref')))
示例#3
0
    def test_dive_copy_existing(self):
        """
        Test copying existing dive
        """
        fl = '{}/dive_copy_logbook.uddf'.format(self.tdir)
        kl.copy_dives([self.fin], ['1'], None, fl)
        kl.copy_dives([self.fin], ['1'], None, fl)  # try to duplicate
        nodes = ku.find(fl, '//uddf:dive')

        dn = next(nodes)
        self.assertTrue(next(nodes, None) is None)
示例#4
0
    def test_dive_copy_with_gases(self):
        """
        Test dive copying with gas data
        """
        fl = '{}/dive_copy_logbook.uddf'.format(self.tdir)

        kl.copy_dives([self.fin], ['1'], None, fl)
        nodes = ku.find(fl, '//uddf:dive')

        dn = next(nodes)
        self.assertEquals(('air', 'ean39'),
                          tuple(ku.xp(dn, './/uddf:switchmix/@ref')))
示例#5
0
    def test_dive_copy_gases_retain(self):
        """
        Test copying dives with no gas data to existing logbook
        """
        fl = '{}/dive_copy_logbook.uddf'.format(self.tdir)

        kl.copy_dives([self.fin], ['1'], None, fl)  # copy gases in
        kl.copy_dives([self.fin], ['2'], None, fl)  # copy no gases

        nodes = ku.find(fl, '//uddf:dive')
        dn = next(nodes)  # 1st dive shall have gases
        self.assertEquals(('air', 'ean39'),
                          tuple(ku.xp(dn, './/uddf:switchmix/@ref')))

        # gas definition section shall be intact
        nodes = ku.find(fl, '//uddf:gasdefinitions')
        self.assertTrue(next(nodes) is not None)
示例#6
0
    def test_dive_copy(self):
        """
        Test copying dive
        """
        fl = '{}/dive_copy_logbook.uddf'.format(self.tdir)

        kl.copy_dives([self.fin], ['1'], None, fl)
        nodes = ku.find(fl, '//uddf:dive')

        dn = next(nodes)
        self.assertTrue(next(nodes, None) is None)

        self.assertEquals('2009-09-19T13:10:23',
                          ku.xp_first(dn, './/uddf:datetime/text()'))
        self.assertEquals('30.2',
                          ku.xp_first(dn, './/uddf:greatestdepth/text()'))
        self.assertEquals('20', ku.xp_first(dn, './/uddf:diveduration/text()'))