~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

[r=sinzui][no-qa] Remove garbo job to populate branch
        transitively_private column.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from pytz import UTC
18
18
from storm.expr import (
19
 
    And,
20
19
    In,
21
20
    Min,
22
21
    Not,
75
74
    )
76
75
from lp.code.enums import CodeImportResultStatus
77
76
from lp.code.interfaces.codeimportevent import ICodeImportEventSet
78
 
from lp.code.model.branch import Branch
79
77
from lp.code.model.branchjob import (
80
78
    BranchJob,
81
79
    BranchUpgradeJob,
857
855
        self._test_AnswerContactPruner(
858
856
            AccountStatus.SUSPENDED, ONE_DAY_AGO, expected_count=1)
859
857
 
860
 
    def test_populate_transitively_private(self):
861
 
        # Test garbo job to populate the branch transitively_private column.
862
 
 
863
 
        # First delete any existing column data and add stacked branches.
864
 
        # Branches 29 and 30 are explicitly private to start with.
865
 
        con = DatabaseLayer._db_fixture.superuser_connection()
866
 
        try:
867
 
            cur = con.cursor()
868
 
            cur.execute("UPDATE branch set stacked_on=29 where id = 5")
869
 
            cur.execute("UPDATE branch set stacked_on=5 where id = 1")
870
 
            cur.execute("UPDATE branch set transitively_private=NULL")
871
 
            con.commit()
872
 
        finally:
873
 
            con.close()
874
 
        store = IMasterStore(Branch)
875
 
        unmigrated = store.find(
876
 
            Branch, Branch.transitively_private == None).count
877
 
        self.assertNotEqual(0, unmigrated())
878
 
        self.runHourly()
879
 
        self.assertEqual(0, unmigrated())
880
 
        # Check the branches that now should be transitively private.
881
 
        self.assertEqual(4, store.find(
882
 
            Branch,
883
 
            And(Branch.transitively_private == True,
884
 
                Branch.id.is_in([1, 5, 29, 30]))
885
 
        ).count())
886
 
        # Check the branches that now should not be transitively private.
887
 
        self.assertEqual(26, store.find(
888
 
            Branch,
889
 
            And(Branch.transitively_private == False,
890
 
                Branch.id < 30)
891
 
        ).count())
892
 
 
893
858
    def test_BranchJobPruner(self):
894
859
        # Garbo should remove jobs completed over 30 days ago.
895
860
        LaunchpadZopelessLayer.switchDbUser('testadmin')