~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/model/tests/test_bugtask.py

  • Committer: Curtis Hovey
  • Date: 2012-01-06 16:52:46 UTC
  • mto: This revision was merged to the branch mainline in revision 14653.
  • Revision ID: curtis.hovey@canonical.com-20120106165246-r7m6ir75f7mvh7f2
Reverted userCanUnassign to 2009 rules, any logged in user can unassign.
Removed redundant tests because they all use login_person.

Show diffs side-by-side

added added

removed removed

Lines of Context:
769
769
            self.assertTrue(
770
770
                self.series_bugtask.userCanSetAnyAssignee(self.regular_user))
771
771
 
772
 
    def test_userCanUnassign_regular_user(self):
773
 
        # Ordinary users can unassign themselves...
774
 
        login_person(self.regular_user)
775
 
        self.assertEqual(self.target_bugtask.assignee, self.regular_user)
776
 
        self.assertEqual(self.series_bugtask.assignee, self.regular_user)
777
 
        self.assertTrue(
778
 
            self.target_bugtask.userCanUnassign(self.regular_user))
779
 
        self.assertTrue(
780
 
            self.series_bugtask.userCanUnassign(self.regular_user))
781
 
        # ...but not other assignees.
 
772
    def test_userCanUnassign_logged_in_user(self):
 
773
        # Ordinary users can unassign any user or team.
782
774
        login_person(self.target_owner_member)
783
775
        other_user = self.factory.makePerson()
784
776
        self.series_bugtask.transitionToAssignee(other_user)
785
777
        self.target_bugtask.transitionToAssignee(other_user)
786
778
        login_person(self.regular_user)
787
 
        self.assertFalse(
 
779
        self.assertTrue(
788
780
            self.target_bugtask.userCanUnassign(self.regular_user))
789
 
        self.assertFalse(
 
781
        self.assertTrue(
790
782
            self.series_bugtask.userCanUnassign(self.regular_user))
791
783
 
792
784
    def test_userCanSetAnyAssignee_target_owner(self):
797
789
        self.assertTrue(
798
790
            self.series_bugtask.userCanSetAnyAssignee(self.target.owner))
799
791
 
800
 
    def test_userCanUnassign_target_owner(self):
801
 
        # The target owner can unassign anybody.
802
 
        login_person(self.target_owner_member)
803
 
        self.assertTrue(
804
 
            self.target_bugtask.userCanUnassign(self.target_owner_member))
805
 
        self.assertTrue(
806
 
            self.series_bugtask.userCanUnassign(self.target_owner_member))
807
 
 
808
792
    def test_userCanSetAnyAssignee_bug_supervisor(self):
809
793
        # A bug supervisor can assign anybody.
810
794
        if self.supervisor_member is not None:
816
800
                self.series_bugtask.userCanSetAnyAssignee(
817
801
                    self.supervisor_member))
818
802
 
819
 
    def test_userCanUnassign_bug_supervisor(self):
820
 
        # A bug supervisor can unassign anybody.
821
 
        if self.supervisor_member is not None:
822
 
            login_person(self.supervisor_member)
823
 
            self.assertTrue(
824
 
                self.target_bugtask.userCanUnassign(self.supervisor_member))
825
 
            self.assertTrue(
826
 
                self.series_bugtask.userCanUnassign(self.supervisor_member))
827
 
 
828
803
    def test_userCanSetAnyAssignee_driver(self):
829
804
        # A project driver can assign anybody.
830
805
        login_person(self.driver_member)
833
808
        self.assertTrue(
834
809
            self.series_bugtask.userCanSetAnyAssignee(self.driver_member))
835
810
 
836
 
    def test_userCanUnassign_driver(self):
837
 
        # A project driver can unassign anybody.
838
 
        login_person(self.driver_member)
839
 
        self.assertTrue(
840
 
            self.target_bugtask.userCanUnassign(self.driver_member))
841
 
        self.assertTrue(
842
 
            self.series_bugtask.userCanUnassign(self.driver_member))
843
 
 
844
811
    def test_userCanSetAnyAssignee_series_driver(self):
845
812
        # A series driver can assign anybody to series bug tasks.
846
813
        login_person(self.driver_member)
858
825
                self.target_bugtask.userCanSetAnyAssignee(
859
826
                    self.series_driver_member))
860
827
 
861
 
    def test_userCanUnassign_series_driver(self):
862
 
        # The target owner can unassign anybody from series bug tasks...
863
 
        login_person(self.series_driver_member)
864
 
        self.assertTrue(
865
 
            self.series_bugtask.userCanUnassign(self.series_driver_member))
866
 
        # ...but not from tasks of the main product/distribution.
867
 
        self.assertFalse(
868
 
            self.target_bugtask.userCanUnassign(self.series_driver_member))
869
 
 
870
828
    def test_userCanSetAnyAssignee_launchpad_admins(self):
871
829
        # Launchpad admins can assign anybody.
872
830
        login_person(self.target_owner_member)
875
833
        self.assertTrue(self.target_bugtask.userCanSetAnyAssignee(foo_bar))
876
834
        self.assertTrue(self.series_bugtask.userCanSetAnyAssignee(foo_bar))
877
835
 
878
 
    def test_userCanUnassign_launchpad_admins(self):
879
 
        # Launchpad admins can unassign anybody.
880
 
        login_person(self.target_owner_member)
881
 
        foo_bar = getUtility(IPersonSet).getByEmail('foo.bar@canonical.com')
882
 
        login_person(foo_bar)
883
 
        self.assertTrue(self.target_bugtask.userCanUnassign(foo_bar))
884
 
        self.assertTrue(self.series_bugtask.userCanUnassign(foo_bar))
885
 
 
886
836
    def test_userCanSetAnyAssignee_bug_importer(self):
887
837
        # The bug importer celebrity can assign anybody.
888
838
        login_person(self.target_owner_member)
893
843
        self.assertTrue(
894
844
            self.series_bugtask.userCanSetAnyAssignee(bug_importer))
895
845
 
896
 
    def test_userCanUnassign_launchpad_bug_importer(self):
897
 
        # The bug importer celebrity can unassign anybody.
898
 
        login_person(self.target_owner_member)
899
 
        bug_importer = getUtility(ILaunchpadCelebrities).bug_importer
900
 
        login_person(bug_importer)
901
 
        self.assertTrue(self.target_bugtask.userCanUnassign(bug_importer))
902
 
        self.assertTrue(self.series_bugtask.userCanUnassign(bug_importer))
903
 
 
904
846
 
905
847
class TestProductBugTaskPermissionsToSetAssignee(
906
848
    TestBugTaskPermissionsToSetAssigneeMixin, TestCaseWithFactory):