コード例 #1
0
 def testUsersInvolvedInHotlists_Normal(self):
     hotlist1 = features_pb2.Hotlist(owner_ids=[111L, 222L],
                                     editor_ids=[333L, 444L, 555L],
                                     follower_ids=[123L])
     hotlist2 = features_pb2.Hotlist(owner_ids=[111L],
                                     editor_ids=[222L, 123L])
     self.assertEqual(
         set([111L, 222L, 333L, 444L, 555L, 123L]),
         features_bizobj.UsersInvolvedInHotlists([hotlist1, hotlist2]))
コード例 #2
0
 def testUsersInvolvedInHotlists_Normal(self):
   hotlist1 = features_pb2.Hotlist(
       owner_ids=[111, 222], editor_ids=[333, 444, 555],
       follower_ids=[123])
   hotlist2 = features_pb2.Hotlist(
       owner_ids=[111], editor_ids=[222, 123])
   self.assertEqual(set([111, 222, 333, 444, 555, 123]),
                    features_bizobj.UsersInvolvedInHotlists([hotlist1,
                                                             hotlist2]))
コード例 #3
0
    def testMembersWithGivenIDs(self):
        h = features_pb2.Hotlist()

        # empty GivenIDs give empty member lists from originally empty member lists
        owners, editors, followers = hotlist_helpers.MembersWithGivenIDs(
            h, set(), 'follower')
        self.assertFalse(owners)
        self.assertFalse(editors)
        self.assertFalse(followers)

        # empty GivenIDs return original non-empty member lists
        h.owner_ids.extend([1, 2, 3])
        h.editor_ids.extend([4, 5, 6])
        h.follower_ids.extend([7, 8, 9])
        owners, editors, followers = hotlist_helpers.MembersWithGivenIDs(
            h, set(), 'editor')
        self.assertEqual(owners, h.owner_ids)
        self.assertEqual(editors, h.editor_ids)
        self.assertEqual(followers, h.follower_ids)

        # non-member GivenIDs return updated member lists
        owners, editors, followers = hotlist_helpers.MembersWithGivenIDs(
            h, {10, 11, 12}, 'owner')
        self.assertEqual(owners, [1, 2, 3, 10, 11, 12])
        self.assertEqual(editors, [4, 5, 6])
        self.assertEqual(followers, [7, 8, 9])

        # member GivenIDs return updated member lists
        owners, editors, followers = hotlist_helpers.MembersWithGivenIDs(
            h, {1, 4, 7}, 'editor')
        self.assertEqual(owners, [2, 3])
        self.assertEqual(editors, [5, 6, 1, 4, 7])
        self.assertEqual(followers, [8, 9])
コード例 #4
0
    def testMembersWithoutGivenIDs(self):
        h = features_pb2.Hotlist()
        owners, editors, followers = hotlist_helpers.MembersWithoutGivenIDs(
            h, set())
        # Check lists are empty
        self.assertFalse(owners)
        self.assertFalse(editors)
        self.assertFalse(followers)

        h.owner_ids.extend([1, 2, 3])
        h.editor_ids.extend([4, 5, 6])
        h.follower_ids.extend([7, 8, 9])
        owners, editors, followers = hotlist_helpers.MembersWithoutGivenIDs(
            h, {10, 11, 12})
        self.assertEqual(h.owner_ids, owners)
        self.assertEqual(h.editor_ids, editors)
        self.assertEqual(h.follower_ids, followers)

        owners, editors, followers = hotlist_helpers.MembersWithoutGivenIDs(
            h, set())
        self.assertEqual(h.owner_ids, owners)
        self.assertEqual(h.editor_ids, editors)
        self.assertEqual(h.follower_ids, followers)

        owners, editors, followers = hotlist_helpers.MembersWithoutGivenIDs(
            h, {1, 4, 7})
        self.assertEqual([2, 3], owners)
        self.assertEqual([5, 6], editors)
        self.assertEqual([8, 9], followers)
コード例 #5
0
  def testGetHotlistRoleName(self):
    hotlist = features_pb2.Hotlist()
    hotlist.owner_ids.append(111L)
    hotlist.editor_ids.append(222L)
    hotlist.follower_ids.append(333L)

    self.assertEquals(None, framework_helpers.GetHotlistRoleName(
        set(), hotlist))

    self.assertEquals(
        'Owner', framework_helpers.GetHotlistRoleName({111L}, hotlist))
    self.assertEquals(
        'Editor', framework_helpers.GetHotlistRoleName({222L}, hotlist))
    self.assertEquals(
        'Follower', framework_helpers.GetHotlistRoleName({333L}, hotlist))

    self.assertEquals(
        'Owner',
        framework_helpers.GetHotlistRoleName({111L, 222L, 999L}, hotlist))
    self.assertEquals(
        'Editor',
        framework_helpers.GetHotlistRoleName({222L, 333L, 999L}, hotlist))
    self.assertEquals(
        'Follower',
        framework_helpers.GetHotlistRoleName({333L, 999L}, hotlist))
コード例 #6
0
  def testIssueIsInHotlist(self):
    hotlist = features_pb2.Hotlist(items=self.hotlistitems)
    for issue in self.issues:
      self.assertTrue(features_bizobj.IssueIsInHotlist(hotlist, issue.issue_id))

    self.assertFalse(features_bizobj.IssueIsInHotlist(
        hotlist, fake.MakeTestIssue(1000, 9, '', 'New', 111)))
コード例 #7
0
    def testUserIsInHotlist(self):
        h = features_pb2.Hotlist()
        self.assertFalse(features_bizobj.UserIsInHotlist(h, {9}))
        self.assertFalse(features_bizobj.UserIsInHotlist(h, set()))

        h.owner_ids.extend([1, 2, 3])
        h.editor_ids.extend([4, 5, 6])
        h.follower_ids.extend([7, 8, 9])
        self.assertTrue(features_bizobj.UserIsInHotlist(h, {1}))
        self.assertTrue(features_bizobj.UserIsInHotlist(h, {4}))
        self.assertTrue(features_bizobj.UserIsInHotlist(h, {7}))
        self.assertFalse(features_bizobj.UserIsInHotlist(h, {10}))

        # Membership via group membership
        self.assertTrue(features_bizobj.UserIsInHotlist(h, {10, 4}))

        # Membership via several group memberships
        self.assertTrue(features_bizobj.UserIsInHotlist(h, {1, 4}))

        # Several irrelevant group memberships
        self.assertFalse(features_bizobj.UserIsInHotlist(h, {10, 11, 12}))
コード例 #8
0
 def testGetOwnerIds(self):
     hotlist = features_pb2.Hotlist(owner_ids=[111L])
     self.assertEqual(features_bizobj.GetOwnerIds(hotlist), [111L])