Exemplo n.º 1
0
    def test_dump(self):

        # Create the object.
        uri = self.uri + self.name
        pop = ProjectionDataSet(self, uri, self.nentries, key_format='S')
        pop.populate()

        # Check some cases with invalid projections.
        self.runWt(['dump', '-x', uri + '('], \
            outfilename='bad1.out', errfilename='err1.out', failure=True)
        self.check_non_empty_file('err1.out')
        self.runWt(['dump', '-x', uri + '(xx)'], \
            outfilename='bad2.out', errfilename='err2.out', failure=True)
        self.check_non_empty_file('err2.out')
        self.runWt(['dump', '-x', uri + pop.projection[:-1]], \
            outfilename='bad3.out', errfilename='err3.out', failure=True)
        self.check_non_empty_file('err3.out')

        # Dump the object with a valid projection.
        self.runWt(['dump', '-x', uri + pop.projection],
                   outfilename='dump.out')

        # Re-load the object in a new home.
        os.mkdir(self.dir)
        self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])

        # Check the database contents.
        self.runWt(['list'], outfilename='list.out')
        self.runWt(['-h', self.dir, 'list'], outfilename='list.out.new')
        s1 = set(open('list.out').read().split())
        s2 = set(open('list.out.new').read().split())
        self.assertEqual(not s1.symmetric_difference(s2), True)

        # Check the object's contents.
        self.reopen_conn(self.dir)
        pop_reload = ProjectionDataSet(self,
                                       uri,
                                       self.nentries,
                                       key_format='S')
        pop_reload.check()
Exemplo n.º 2
0
    def test_dump(self):

        # Create the object.
        uri = self.uri + self.name
        pop = ProjectionDataSet(self, uri, self.nentries, key_format='S')
        pop.populate()

        # Check some cases with invalid projections.
        self.runWt(['dump', '-x', uri + '('], \
            outfilename='bad1.out', errfilename='err1.out', failure=True)
        self.check_non_empty_file('err1.out')
        self.runWt(['dump', '-x', uri + '(xx)'], \
            outfilename='bad2.out', errfilename='err2.out', failure=True)
        self.check_non_empty_file('err2.out')
        self.runWt(['dump', '-x', uri + pop.projection[:-1]], \
            outfilename='bad3.out', errfilename='err3.out', failure=True)
        self.check_non_empty_file('err3.out')

        # Dump the object with a valid projection.
        self.runWt(['dump', '-x', uri + pop.projection], outfilename='dump.out')

        # Re-load the object in a new home.
        os.mkdir(self.dir)
        self.runWt(['-h', self.dir, 'load', '-f', 'dump.out'])

        # Check the database contents.
        self.runWt(['list'], outfilename='list.out')
        self.runWt(['-h', self.dir, 'list'], outfilename='list.out.new')
        s1 = set(open('list.out').read().split())
        s2 = set(open('list.out.new').read().split())
        self.assertEqual(not s1.symmetric_difference(s2), True)

        # Check the object's contents.
        self.reopen_conn(self.dir)
        pop_reload = ProjectionDataSet(self, uri, self.nentries, key_format='S')
        pop_reload.check()