Beispiel #1
0
 def test_searchForTerms_exact_unofficial_source_name(self):
     # Unofficial source packages are not found by search.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf',
                               official=False)
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='snarf')
     terms = list(results)
     self.assertEqual(0, len(terms))
Beispiel #2
0
 def test_searchForTerms_similar_official_source_name(self):
     # Partial source name matches are found.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='pting-snarf-ack')
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='snarf')
     terms = list(results)
     self.assertEqual(1, len(terms))
     self.assertEqual('pting-snarf-ack', terms[0].token)
Beispiel #3
0
 def test_searchForTerms_exact_binary_name(self):
     # Exact binary name matches are found.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf',
                               binary_names='pting-dev pting ack')
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='pting')
     terms = list(results)
     self.assertEqual(1, len(terms))
     self.assertEqual('snarf', terms[0].token)
Beispiel #4
0
 def test_searchForTerms_ppa_archive(self):
     # Packages in PPAs are ignored.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf',
                               official=False,
                               archive=self.factory.makeArchive(
                                   distribution=distro,
                                   purpose=ArchivePurpose.PPA))
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='snarf')
     self.assertEqual(0, results.count())
Beispiel #5
0
 def test_searchForTerms_partner_archive(self):
     # Packages in partner archives are searched.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf',
                               archive=self.factory.makeArchive(
                                   distribution=distro,
                                   purpose=ArchivePurpose.PARTNER))
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='snarf')
     terms = list(results)
     self.assertEqual(1, len(terms))
     self.assertEqual('snarf', terms[0].token)
Beispiel #6
0
 def test_searchForTerms_deduplication(self):
     # Search deduplicates cache rows with the same name, e.g. an
     # official source package that also has an official branch.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf')
     branch = self.factory.makePackageBranch(distroseries=distroseries)
     with person_logged_in(distro.owner):
         distroseries.getSourcePackage('snarf').setBranch(
             PackagePublishingPocket.RELEASE, branch, distro.owner)
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='snarf')
     terms = list(results)
     self.assertEqual(1, len(terms))
     self.assertEqual('snarf', terms[0].token)
Beispiel #7
0
 def test_searchForTerms_ranking(self):
     # Exact matches are ranked higher than similar matches.
     distro = self.factory.makeDistribution(name='fnord')
     distroseries = self.factory.makeDistroSeries(distribution=distro)
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf')
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='snarf-server')
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='pting-devel',
                               binary_names='snarf')
     self.factory.makeDSPCache(distroseries=distroseries,
                               sourcepackagename='pting-client',
                               binary_names='snarf-common')
     vocabulary = DistributionSourcePackageVocabulary(distro)
     results = vocabulary.searchForTerms(query='snarf')
     terms = list(results)
     self.assertEqual(4, len(terms))
     self.assertEqual('snarf', terms[0].token)
     self.assertEqual('pting-devel', terms[1].token)
     self.assertEqual('snarf-server', terms[2].token)
     self.assertEqual('pting-client', terms[3].token)
Beispiel #8
0
 def test_searchForTerms_None(self):
     # Searching for nothing gets you that.
     vocabulary = DistributionSourcePackageVocabulary(
         self.factory.makeDistribution())
     results = vocabulary.searchForTerms()
     self.assertEqual(0, results.count())