Esempio n. 1
0
    def Prepare(self):

        self._htpa = HydrusTagArchive.HydrusTagPairArchive(self._path)

        self._htpa.BeginBigJob()

        self._iterator = self._htpa.IteratePairs()
Esempio n. 2
0
    def Prepare(self):

        self._time_started = HydrusData.GetNow()

        self._htpa = HydrusTagArchive.HydrusTagPairArchive(self._path)

        pair_type = content_types_to_pair_types[self._content_type]

        self._htpa.SetPairType(pair_type)

        self._htpa.BeginBigJob()
 def run_test( source, destination_path, content_type, expected_data ):
     
     destination = ClientMigration.MigrationDestinationHTPA( self, destination_path, content_type )
     
     job = ClientMigration.MigrationJob( self, 'test', source, destination )
     
     job.Run()
     
     hta = HydrusTagArchive.HydrusTagPairArchive( destination_path )
     
     result = list( hta.IteratePairs() )
     
     self.assertEqual( set( result ), set( expected_data ) )
     
     hta.Close()
Esempio n. 4
0
    def _test_pairs_htpa_to_list(self, content_type):
        def run_test(source, expected_data):

            destination = ClientMigration.MigrationDestinationListPairs(self)

            job = ClientMigration.MigrationJob(self, 'test', source,
                                               destination)

            job.Run()

            self.assertEqual(set(destination.GetDataReceived()),
                             set(expected_data))

        (current, pending, to_be_pended,
         deleted) = pair_types_to_pools[content_type]

        htpa_path = os.path.join(TestController.DB_DIR, 'htpa.db')

        htpa = HydrusTagArchive.HydrusTagPairArchive(htpa_path)

        if content_type == HC.CONTENT_TYPE_TAG_PARENTS:

            htpa.SetPairType(HydrusTagArchive.TAG_PAIR_TYPE_PARENTS)

        elif content_type == HC.CONTENT_TYPE_TAG_SIBLINGS:

            htpa.SetPairType(HydrusTagArchive.TAG_PAIR_TYPE_SIBLINGS)

        htpa.BeginBigJob()

        htpa.AddPairs(current)

        htpa.CommitBigJob()

        htpa.Optimise()

        htpa.Close()

        del htpa

        #

        # test tag filter, left, right, both

        free_filter = HydrusTags.TagFilter()

        namespace_filter = HydrusTags.TagFilter()

        namespace_filter.SetRule(':', HC.FILTER_WHITELIST)
        namespace_filter.SetRule('', HC.FILTER_BLACKLIST)

        test_filters = []

        test_filters.append((free_filter, free_filter))
        test_filters.append((namespace_filter, free_filter))
        test_filters.append((free_filter, namespace_filter))
        test_filters.append((namespace_filter, namespace_filter))

        for (left_tag_filter, right_tag_filter) in test_filters:

            source = ClientMigration.MigrationSourceHTPA(
                self, htpa_path, left_tag_filter, right_tag_filter)

            expected_data = [(left_tag, right_tag)
                             for (left_tag, right_tag) in current
                             if left_tag_filter.TagOK(left_tag)
                             and right_tag_filter.TagOK(right_tag)]

            run_test(source, expected_data)

        #

        os.remove(htpa_path)