Exemple #1
0
 def test_GetBinnedHotlistViews_Multiple(self):
     """Should correctly bin each hotlist view when passed in multiple views"""
     hotlist_h1 = fake.Hotlist(hotlist_name='h1',
                               hotlist_id=1,
                               owner_ids=[111L],
                               hotlist_item_fields=self.hotlist_item_fields)
     h1_view = hotlist_views.HotlistView(hotlist_h1,
                                         viewed_user_id=222L,
                                         user_auth=self.user_auth,
                                         users_by_id=self.userviews_by_id)
     hotlist_h2 = fake.Hotlist(hotlist_name='h2',
                               hotlist_id=2,
                               owner_ids=[222L],
                               hotlist_item_fields=self.hotlist_item_fields)
     h2_view = hotlist_views.HotlistView(hotlist_h2,
                                         viewed_user_id=222L,
                                         user_auth=self.user_auth,
                                         users_by_id=self.userviews_by_id)
     hotlist_h3 = fake.Hotlist(hotlist_name='h3',
                               hotlist_id=3,
                               owner_ids=[333L],
                               hotlist_item_fields=self.hotlist_item_fields)
     h3_view = hotlist_views.HotlistView(hotlist_h3,
                                         viewed_user_id=222L,
                                         user_auth=self.user_auth,
                                         users_by_id=self.userviews_by_id)
     self.assertEqual(
         ([h2_view], [h1_view], [h3_view]),
         issuedetail._GetBinnedHotlistViews([h1_view, h2_view, h3_view],
                                            involved_users=[111L]))
    def testFriendlyURL(self):
        # owner with obscure_email:false
        hotlist = fake.Hotlist('noObscureHotlist',
                               133,
                               owner_ids=[2],
                               editor_ids=[3])
        hotlist_view = hotlist_views.HotlistView(hotlist,
                                                 self.perms,
                                                 self.user_auth,
                                                 viewed_user_id=3,
                                                 users_by_id=self.users_by_id)
        self.assertEqual(hotlist_view.url,
                         '/u/user2/hotlists/noObscureHotlist')

        #owner with obscure_email:true
        hotlist = fake.Hotlist('ObscureHotlist',
                               133,
                               owner_ids=[1],
                               editor_ids=[3])
        hotlist_view = hotlist_views.HotlistView(hotlist,
                                                 self.perms,
                                                 self.user_auth,
                                                 viewed_user_id=1,
                                                 users_by_id=self.users_by_id)
        self.assertEqual(hotlist_view.url, '/u/1/hotlists/ObscureHotlist')
Exemple #3
0
    def testBanned(self):
        # With a banned user
        hotlist = fake.Hotlist('userBanned', 423, owner_ids=[4])
        hotlist_view = hotlist_views.HotlistView(hotlist, self.user_auth, 1,
                                                 self.users_by_id)
        self.assertFalse(hotlist_view.visible)

        # With a user not banned
        hotlist = fake.Hotlist('userNotBanned', 453, owner_ids=[1])
        hotlist_view = hotlist_views.HotlistView(hotlist, self.user_auth, 1,
                                                 self.users_by_id)
        self.assertTrue(hotlist_view.visible)
Exemple #4
0
 def testAssignFlipperValues_NoShow(self):
     one_issue_hotlist = fake.Hotlist('name1', 122,
                                      [self.hotlist_item_fields[0]])
     no_show_hotlist_flipper = issuedetail._HotlistFlipper(
         self.services, profiler.Profiler(), one_issue_hotlist)
     no_show_hotlist_flipper.AssignFlipperValues(self.mr, None, 0, None, 1)
     self.assertFalse(no_show_hotlist_flipper.show)
Exemple #5
0
 def testNoPermissions(self):
     hotlist = fake.Hotlist('private',
                            333,
                            is_private=True,
                            owner_ids=[1],
                            editor_ids=[2])
     hotlist_view = hotlist_views.HotlistView(hotlist, self.user_auth, 1,
                                              self.users_by_id)
     self.assertFalse(hotlist_view.visible)
     self.assertEqual(hotlist_view.url, '/u/1/hotlists/private')
 def testGetHotlists(self):
   hotlist1 = fake.Hotlist(hotlist_name='hotlist1', hotlist_id=123)
   self.features_service.hotlist_2lc.CacheItem(123, hotlist1)
   self.SetUpGetHotlists(456)
   self.mox.ReplayAll()
   hotlist_dict = self.features_service.GetHotlists(
       self.cnxn, [123, 456])
   self.mox.VerifyAll()
   self.assertItemsEqual([123, 456], hotlist_dict.keys())
   self.assertEqual('hotlist1', hotlist_dict[123].name)
   self.assertEqual('hotlist2', hotlist_dict[456].name)
 def setUp(self):
     self.hotlist = fake.Hotlist('hotlistName',
                                 123,
                                 hotlist_item_fields=[
                                     (2, 0, None, None, ''),
                                     (1, 0, None, None, ''),
                                     (5, 0, None, None, '')
                                 ],
                                 is_private=False,
                                 owner_ids=[111])
     self.user1 = user_pb2.User(user_id=111)
     self.user1_view = framework_views.UserView(self.user1)
 def testGetHotlistsByID(self):
   hotlist1 = fake.Hotlist(hotlist_name='hotlist1', hotlist_id=123)
   self.features_service.hotlist_2lc.CacheItem(123, hotlist1)
   # NOTE: The setup function must take a hotlist_id that is different
   # from what was used in previous tests, otherwise the methods in the
   # setup function will never get called.
   self.SetUpGetHotlists(456)
   self.mox.ReplayAll()
   _, actual_missed = self.features_service.GetHotlistsByID(
       self.cnxn, [123, 456])
   self.mox.VerifyAll()
   self.assertEqual(actual_missed, [])
 def testUpdateHotlistItemsFields_Ranks(self):
   hotlist_item_fields = [
       (11, 1, 333L, 2002, ''), (33, 3, 333L, 2002, ''),
       (55, 3, 333L, 2002, '')]
   hotlist = fake.Hotlist(hotlist_name='hotlist', hotlist_id=345,
                          hotlist_item_fields=hotlist_item_fields)
   self.features_service.hotlist_2lc.CacheItem(345, hotlist)
   relations_to_change = {11: 112, 33: 332, 55: 552}
   issue_ids = [11, 33, 55]
   self.SetUpUpdateHotlistItemsFields(345, issue_ids)
   self.mox.ReplayAll()
   self.features_service.UpdateHotlistItemsFields(
       self.cnxn, 345, new_ranks=relations_to_change)
   self.mox.VerifyAll()
Exemple #10
0
 def test_GetBinnedHotlistViews_OtherUserHasAHotlist(self):
     """user uo1 owns h3; uo1 is an "other"; h3 should go into the "user" bin"""
     # Hotlist h3; user uo1 owns h3; uo3 is an *other* user.
     hotlist_h3 = fake.Hotlist(hotlist_name='h3',
                               hotlist_id=3,
                               owner_ids=[333L],
                               hotlist_item_fields=self.hotlist_item_fields)
     h3_view = hotlist_views.HotlistView(hotlist_h3,
                                         viewed_user_id=222L,
                                         user_auth=self.user_auth,
                                         users_by_id=self.userviews_by_id)
     self.assertEqual(
         ([], [], [h3_view]),
         issuedetail._GetBinnedHotlistViews([h3_view],
                                            involved_users=[111L]))
Exemple #11
0
 def test_GetBinnedHotlistViews_SignedInUserHasAHotlist(self):
     """user ul1 owns h2 and is logged in; h2 should go into the "user" bin"""
     # Hotlist h2; user ul1 owns h2; ul1 is a *logged in* user.
     hotlist_h2 = fake.Hotlist(hotlist_name='h2',
                               hotlist_id=2,
                               owner_ids=[222L],
                               hotlist_item_fields=self.hotlist_item_fields)
     h2_view = hotlist_views.HotlistView(hotlist_h2,
                                         viewed_user_id=222L,
                                         user_auth=self.user_auth,
                                         users_by_id=self.userviews_by_id)
     self.assertEqual(
         ([h2_view], [], []),
         issuedetail._GetBinnedHotlistViews([h2_view],
                                            involved_users=[111L]))
Exemple #12
0
 def test_GetBinnedHotlistViews_IssueOwnerHasAHotlist(self):
     """user u1 owns h1 and the issue; h1 should go into the "involved" bin."""
     # Hotlist h1; user u1 owns h1; u1 is the issue reporter and owner, and so
     # is an *involved* user.
     hotlist_h1 = fake.Hotlist(hotlist_name='h1',
                               hotlist_id=1,
                               owner_ids=[111L],
                               hotlist_item_fields=self.hotlist_item_fields)
     h1_view = hotlist_views.HotlistView(hotlist_h1,
                                         viewed_user_id=222L,
                                         user_auth=self.user_auth,
                                         users_by_id=self.userviews_by_id)
     self.assertEqual(
         ([], [h1_view], []),
         issuedetail._GetBinnedHotlistViews([h1_view],
                                            involved_users=[111L]))
Exemple #13
0
 def testOtherAttributes(self):
     hotlist = fake.Hotlist('hotlistName',
                            123,
                            hotlist_item_fields=[(2, 0, None, None, ''),
                                                 (1, 0, None, None, ''),
                                                 (5, 0, None, None, '')],
                            is_private=False,
                            owner_ids=[1],
                            editor_ids=[2, 3])
     hotlist_view = hotlist_views.HotlistView(hotlist,
                                              self.user_auth,
                                              viewed_user_id=2,
                                              users_by_id=self.users_by_id,
                                              is_starred=True)
     self.assertTrue(hotlist_view.visible, True)
     self.assertEqual(hotlist_view.role_name, 'editor')
     self.assertEqual(hotlist_view.owners, [self.user1_view])
     self.assertEqual(hotlist_view.editors,
                      [self.user2_view, self.user3_view])
     self.assertEqual(hotlist_view.num_issues, 3)
     self.assertTrue(hotlist_view.is_starred)
Exemple #14
0
    def setUp(self):
        self.services = service_manager.Services(config=fake.ConfigService(),
                                                 issue=fake.IssueService(),
                                                 user=fake.UserService(),
                                                 project=fake.ProjectService())
        self.mr = testing_helpers.MakeMonorailRequest()

        issue1 = fake.MakeTestIssue(001,
                                    1,
                                    'issue_summary',
                                    'New',
                                    111L,
                                    project_name='project1',
                                    issue_id=1L)
        self.services.issue.TestAddIssue(issue1)
        issue2 = fake.MakeTestIssue(001,
                                    2,
                                    'issue_summary',
                                    'New',
                                    111L,
                                    project_name='project1',
                                    issue_id=2L)
        self.services.issue.TestAddIssue(issue2)
        issue3 = fake.MakeTestIssue(002,
                                    3,
                                    'issue_summary',
                                    'New',
                                    111L,
                                    project_name='project2',
                                    issue_id=3L)
        self.services.issue.TestAddIssue(issue3)
        ts = 20091111111111
        self.hotlist_item_fields = [(1L, 10, 111L, ts, ''),
                                    (2L, 20, 111L, ts, ''),
                                    (3L, 30, 111L, ts, '')]
        self.hotlist = fake.Hotlist('name', 123, self.hotlist_item_fields)
        self.hotlist_flipper = issuedetail._HotlistFlipper(
            self.services, profiler.Profiler(), self.hotlist)
Exemple #15
0
 def testNoOwner(self):
     hotlist = fake.Hotlist('unowned', 500, owner_ids=[])
     view = hotlist_views.HotlistView(hotlist, self.perms, self.user_auth,
                                      1, self.users_by_id)
     self.assertFalse(view.url)