Esempio n. 1
0
 def test_getDirect_not_found(self):
     # DistributionSourcePackageInDatabase.getDirect() returns None if a
     # DSP does not exist in the database. It does not modify the mapping
     # cache.
     distribution = self.factory.makeDistribution()
     sourcepackagename = self.factory.makeSourcePackageName()
     flush_database_updates()
     with StormStatementRecorder() as recorder:
         dsp = DistributionSourcePackageInDatabase.getDirect(
             distribution, sourcepackagename)
         self.assertIs(None, dsp)
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     self.assertEqual({},
                      DistributionSourcePackageInDatabase._cache.items())
 def test_getDirect_not_found(self):
     # DistributionSourcePackageInDatabase.getDirect() returns None if a
     # DSP does not exist in the database. It does not modify the mapping
     # cache.
     distribution = self.factory.makeDistribution()
     sourcepackagename = self.factory.makeSourcePackageName()
     flush_database_updates()
     with StormStatementRecorder() as recorder:
         dsp = DistributionSourcePackageInDatabase.getDirect(
             distribution, sourcepackagename)
         self.assertIs(None, dsp)
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     self.assertEqual(
         {}, DistributionSourcePackageInDatabase._cache.items())
Esempio n. 3
0
 def test_getDirect_found(self):
     # DistributionSourcePackageInDatabase.getDirect() returns the
     # DSPInDatabase if one already exists in the database. It also adds
     # the new mapping to the mapping cache.
     distribution = self.factory.makeDistribution()
     sourcepackagename = self.factory.makeSourcePackageName()
     dsp = DistributionSourcePackageInDatabase.new(distribution,
                                                   sourcepackagename)
     flush_database_updates()
     with StormStatementRecorder() as recorder:
         dsp_found = DistributionSourcePackageInDatabase.getDirect(
             dsp.distribution, dsp.sourcepackagename)
         self.assertIs(dsp, dsp_found)
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     self.assertEqual({(distribution.id, sourcepackagename.id): dsp.id},
                      DistributionSourcePackageInDatabase._cache.items())
 def test_getDirect_found(self):
     # DistributionSourcePackageInDatabase.getDirect() returns the
     # DSPInDatabase if one already exists in the database. It also adds
     # the new mapping to the mapping cache.
     distribution = self.factory.makeDistribution()
     sourcepackagename = self.factory.makeSourcePackageName()
     dsp = DistributionSourcePackageInDatabase.new(
         distribution, sourcepackagename)
     flush_database_updates()
     with StormStatementRecorder() as recorder:
         dsp_found = DistributionSourcePackageInDatabase.getDirect(
             dsp.distribution, dsp.sourcepackagename)
         self.assertIs(dsp, dsp_found)
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     self.assertEqual(
         {(distribution.id, sourcepackagename.id): dsp.id},
         DistributionSourcePackageInDatabase._cache.items())