~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/scripts/tests/test_garbo.py

  • Committer: Colin Watson
  • Date: 2012-01-05 14:21:46 UTC
  • mto: This revision was merged to the branch mainline in revision 14643.
  • Revision ID: cjwatson@canonical.com-20120105142146-v2odsixhltybljzb
Add garbo job to clean up broken SPR.dsc_binaries values.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Test the database garbage collector."""
1026
1026
        self.runDaily()
1027
1027
        self.assertEqual(0, unreferenced_msgsets.count())
1028
1028
 
 
1029
    def test_SourcePackageReleaseDscBinariesUpdater_updates_incorrect(self):
 
1030
        # SourcePackageReleaseDscBinariesUpdater fixes incorrectly-separated
 
1031
        # dsc_binaries values.
 
1032
        LaunchpadZopelessLayer.switchDbUser('testadmin')
 
1033
        three = [
 
1034
            self.factory.getUniqueString(),
 
1035
            self.factory.getUniqueString(),
 
1036
            self.factory.getUniqueString(),
 
1037
            ]
 
1038
        spr_three = self.factory.makeSourcePackageRelease(
 
1039
            dsc_binaries=" ".join(three))
 
1040
        transaction.commit()
 
1041
        self.runDaily()
 
1042
        self.assertEqual(", ".join(three), spr_three.dsc_binaries)
 
1043
 
 
1044
    def test_SourcePackageReleaseDscBinariesUpdater_skips_correct(self):
 
1045
        # SourcePackageReleaseDscBinariesUpdater leaves correct dsc_binaries
 
1046
        # values alone.
 
1047
        LaunchpadZopelessLayer.switchDbUser('testadmin')
 
1048
        one = self.factory.getUniqueString()
 
1049
        spr_one = self.factory.makeSourcePackageRelease(dsc_binaries=one)
 
1050
        three = ", ".join([
 
1051
            self.factory.getUniqueString(),
 
1052
            self.factory.getUniqueString(),
 
1053
            self.factory.getUniqueString(),
 
1054
            ])
 
1055
        spr_three = self.factory.makeSourcePackageRelease(dsc_binaries=three)
 
1056
        transaction.commit()
 
1057
        self.runDaily()
 
1058
        self.assertEqual(one, spr_one.dsc_binaries)
 
1059
        self.assertEqual(three, spr_three.dsc_binaries)
 
1060
 
 
1061
    def test_SourcePackageReleaseDscBinariesUpdater_skips_broken(self):
 
1062
        # There have been a few instances of Binary fields in PPA packages
 
1063
        # that are formatted like a dependency relationship field, complete
 
1064
        # with (>= ...).  This is completely invalid (and failed to build),
 
1065
        # but does exist historically, so we have to deal with it.
 
1066
        # SourcePackageReleaseDscBinariesUpdater leaves such fields well
 
1067
        # alone.
 
1068
        LaunchpadZopelessLayer.switchDbUser('testadmin')
 
1069
        broken = "%s (>= 1), %s" % (
 
1070
            self.factory.getUniqueString(), self.factory.getUniqueString())
 
1071
        spr_broken = self.factory.makeSourcePackageRelease(
 
1072
            dsc_binaries=broken)
 
1073
        transaction.commit()
 
1074
        self.runDaily()
 
1075
        self.assertEqual(broken, spr_broken.dsc_binaries)
 
1076
 
1029
1077
 
1030
1078
class TestGarboTasks(TestCaseWithFactory):
1031
1079
    layer = LaunchpadZopelessLayer