Exemplo n.º 1
0
 def test_toTerm_dsp_no_distribution(self):
     # The vocabulary can convert a DSP to a term even if it does not yet
     # have a distribution.
     dsp = self.factory.makeDistributionSourcePackage(
         sourcepackagename='foo', with_db=False)
     vocabulary = DistributionSourcePackageVocabulary(None)
     term = vocabulary.toTerm(dsp)
     self.assertEqual(dsp.name, term.token)
     self.assertEqual(dsp.name, term.title)
     self.assertEqual(dsp, term.value)
Exemplo n.º 2
0
 def test_toTerm_dsp_with_cacheless_distribution(self):
     # A DSP that is not official is accepted, provided that the
     # distribution has no cached package names.
     dsp = self.factory.makeDistributionSourcePackage(
         sourcepackagename='foo', with_db=False)
     vocabulary = DistributionSourcePackageVocabulary(dsp.distribution)
     term = vocabulary.toTerm(dsp)
     self.assertEqual(dsp.name, term.token)
     self.assertEqual(dsp.name, term.title)
     self.assertEqual(dsp, term.value)
Exemplo n.º 3
0
 def test_toTerm_dsp(self):
     # The DSP's distribution is used when a DSP is passed.
     spph = self.factory.makeSourcePackagePublishingHistory()
     dsp = spph.distroseries.distribution.getSourcePackage(
         spph.sourcepackagerelease.sourcepackagename)
     vocabulary = DistributionSourcePackageVocabulary(dsp)
     term = vocabulary.toTerm(dsp)
     self.assertEqual(dsp.name, term.token)
     self.assertEqual(dsp.name, term.title)
     self.assertEqual(dsp, term.value)
Exemplo n.º 4
0
 def test_toTerm_spn_with_cacheless_distribution(self):
     # An SPN with no official DSP is accepted, provided that the
     # distribution has no cached package names.
     distro = self.factory.makeDistribution()
     spn = self.factory.makeSourcePackageName()
     vocabulary = DistributionSourcePackageVocabulary(distro)
     term = vocabulary.toTerm(spn)
     self.assertEqual(spn.name, term.token)
     self.assertEqual(spn.name, term.title)
     self.assertEqual(distro, term.value.distribution)
     self.assertEqual(spn, term.value.sourcepackagename)
Exemplo n.º 5
0
 def test_toTerm_dsp_and_binary_names(self):
     # The DSP can be passed with a string on binary names that will be
     # cached as a list in DSP.binary_names.
     spph = self.factory.makeSourcePackagePublishingHistory()
     dsp = spph.distroseries.distribution.getSourcePackage(
         spph.sourcepackagerelease.sourcepackagename)
     vocabulary = DistributionSourcePackageVocabulary(dsp)
     term = vocabulary.toTerm((dsp, 'one two'))
     self.assertEqual(dsp.name, term.token)
     self.assertEqual(dsp.name, term.title)
     self.assertEqual(dsp, term.value)
     self.assertEqual(['one', 'two'], term.value.binary_names)