예제 #1
0
 def setUp(self):
   self.testbed = testbed.Testbed()
   self.testbed.activate()
   self.testbed.init_memcache_stub()
   self.testbed.init_datastore_v3_stub()
   self.services = service_manager.Services(
       issue_star=fake.IssueStarService(),
       config=fake.ConfigService(),
       user=fake.UserService(),
       issue=fake.IssueService(),
       project=fake.ProjectService(),
       cache_manager=fake.CacheManager(),
       features=fake.FeaturesService())
   self.servlet = hotlistissuescsv.HotlistIssuesCsv(
       'req', webapp2.Response(), services=self.services)
   self.user1 = self.services.user.TestAddUser('*****@*****.**', 111)
   self.user2 = self.services.user.TestAddUser('*****@*****.**', 222)
   self.services.project.TestAddProject('project-name', project_id=1)
   self.issue1 = fake.MakeTestIssue(
       1, 1, 'issue_summary', 'New', 111, project_name='project-name')
   self.services.issue.TestAddIssue(self.issue1)
   self.issues = [self.issue1]
   self.hotlist_item_fields = [
       (issue.issue_id, rank, 111, 1205079300, '') for
       rank, issue in enumerate(self.issues)]
   self.hotlist = self.services.features.TestAddHotlist(
       'MyHotlist', hotlist_id=123, owner_ids=[222], editor_ids=[111],
       hotlist_item_fields=self.hotlist_item_fields)
   self._MakeMR('/u/222/hotlists/MyHotlist')
   sorting.InitializeArtValues(self.services)
  def setUp(self):
    self.cnxn = 'fake cnxn'
    self.services = service_manager.Services(
        user=fake.UserService(),
        usergroup=fake.UserGroupService(),
        project=fake.ProjectService(),
        issue=fake.IssueService(),
        config=fake.ConfigService(),
        cache_manager=fake.CacheManager())
    self.profiler = profiler.Profiler()
    self.services.user.TestAddUser('*****@*****.**', 111L)
    self.project = self.services.project.TestAddProject('proj', project_id=789)
    self.mr = testing_helpers.MakeMonorailRequest(
      path='/p/proj/issues/list?q=Priority:High',
      project=self.project)
    self.mr.me_user_id = 999L  # This value is not used by backend search
    self.mr.shard_id = 2
    self.mr.invalidation_timestep = 12345

    self.mox = mox.Mox()
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_user_stub()
    self.testbed.init_memcache_stub()
    sorting.InitializeArtValues(self.services)
    def testSortIssues(self):
        services = service_manager.Services(cache_manager=fake.CacheManager())
        sorting.InitializeArtValues(services)

        mr = testing_helpers.MakeMonorailRequest(
            path='/p/proj/issues/list?q=foo')
        mr.sort_spec = 'priority'
        issue_1 = fake.MakeTestIssue(789,
                                     1,
                                     'one',
                                     'New',
                                     111L,
                                     labels=['Priority-High'])
        issue_2 = fake.MakeTestIssue(789,
                                     2,
                                     'two',
                                     'New',
                                     111L,
                                     labels=['Priority-Low'])
        issue_3 = fake.MakeTestIssue(789,
                                     3,
                                     'three',
                                     'New',
                                     111L,
                                     labels=['Priority-Medium'])
        issues = [issue_1, issue_2, issue_3]
        config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)

        sorted_issues = frontendsearchpipeline._SortIssues(
            mr, issues, config, {})

        self.assertEqual(
            [issue_1, issue_3, issue_2],  # Order is high, medium, low.
            sorted_issues)
예제 #4
0
    def setUp(self):
        self.services = service_manager.Services(
            issue=fake.IssueService(),
            features=fake.FeaturesService(),
            issue_star=fake.AbstractStarService(),
            config=fake.ConfigService(),
            project=fake.ProjectService(),
            user=fake.UserService(),
            cache_manager=fake.CacheManager())
        self.services.project.TestAddProject('ProjectName', project_id=1)

        self.services.user.TestAddUser('*****@*****.**', 111)
        self.services.user.TestAddUser('*****@*****.**', 222)
        issue1 = fake.MakeTestIssue(1,
                                    1,
                                    'issue_summary',
                                    'New',
                                    111,
                                    project_name='ProjectName')
        self.services.issue.TestAddIssue(issue1)
        issue2 = fake.MakeTestIssue(1,
                                    2,
                                    'issue_summary2',
                                    'New',
                                    111,
                                    project_name='ProjectName')
        self.services.issue.TestAddIssue(issue2)
        issue3 = fake.MakeTestIssue(1,
                                    3,
                                    'issue_summary3',
                                    'New',
                                    222,
                                    project_name='ProjectName')
        self.services.issue.TestAddIssue(issue3)
        issues = [issue1, issue2, issue3]
        hotlist_items = [(issue.issue_id, rank, 222, None, '')
                         for rank, issue in enumerate(issues)]

        self.hotlist_items_list = [
            features_pb2.MakeHotlistItem(issue_id,
                                         rank=rank,
                                         adder_id=adder_id,
                                         date_added=date,
                                         note=note)
            for (issue_id, rank, adder_id, date, note) in hotlist_items
        ]
        self.test_hotlist = self.services.features.TestAddHotlist(
            'hotlist',
            hotlist_id=123,
            owner_ids=[111],
            hotlist_item_fields=hotlist_items)
        sorting.InitializeArtValues(self.services)
        self.mr = None
예제 #5
0
  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_memcache_stub()
    self.testbed.init_datastore_v3_stub()
    self.services = service_manager.Services(
        issue_star=fake.IssueStarService(),
        config=fake.ConfigService(),
        user=fake.UserService(),
        issue=fake.IssueService(),
        project=fake.ProjectService(),
        features=fake.FeaturesService(),
        cache_manager=fake.CacheManager(),
        hotlist_star=fake.HotlistStarService())
    self.servlet = hotlistissues.HotlistIssues(
        'req', 'res', services=self.services)
    self.user1 = self.services.user.TestAddUser('*****@*****.**', 111)
    self.user2 = self.services.user.TestAddUser('*****@*****.**', 222, )
    self.services.project.TestAddProject('project-name', project_id=1)
    self.issue1 = fake.MakeTestIssue(
        1, 1, 'issue_summary', 'New', 111, project_name='project-name')
    self.services.issue.TestAddIssue(self.issue1)
    self.issue2 = fake.MakeTestIssue(
        1, 2, 'issue_summary2', 'New', 111, project_name='project-name')
    self.services.issue.TestAddIssue(self.issue2)
    self.issue3 = fake.MakeTestIssue(
        1, 3, 'issue_summary3', 'New', 222, project_name='project-name')
    self.services.issue.TestAddIssue(self.issue3)
    self.issues = [self.issue1, self.issue2, self.issue3]
    self.hotlist_item_fields = [
        (issue.issue_id, rank, 111, 1205079300, '') for
        rank, issue in enumerate(self.issues)]
    self.test_hotlist = self.services.features.TestAddHotlist(
        'hotlist', hotlist_id=123, owner_ids=[222], editor_ids=[111],
        hotlist_item_fields=self.hotlist_item_fields)
    self.hotlistissues = self.test_hotlist.items
    # Unless perms is specified,
    # MakeMonorailRequest will return an mr with admin permissions.
    self.mr = testing_helpers.MakeMonorailRequest(
        hotlist=self.test_hotlist, path='/u/222/hotlists/123',
        services=self.services, perms=permissions.EMPTY_PERMISSIONSET)
    self.mr.hotlist_id = self.test_hotlist.hotlist_id
    self.mr.auth.user_id = 111
    self.mr.auth.effective_ids = {111}
    self.mr.viewed_user_auth.user_id = 111
    sorting.InitializeArtValues(self.services)

    self.mox = mox.Mox()
    def setUp(self):
        self.cnxn = 'fake cnxn'
        self.config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)
        self.services = service_manager.Services(
            user=fake.UserService(),
            project=fake.ProjectService(),
            issue=fake.IssueService(),
            config=fake.ConfigService(),
            cache_manager=fake.CacheManager())
        self.profiler = profiler.Profiler()
        self.services.user.TestAddUser('*****@*****.**', 111L)
        self.project = self.services.project.TestAddProject('proj',
                                                            project_id=789)
        self.mr = testing_helpers.MakeMonorailRequest(
            path='/p/proj/issues/list', project=self.project)
        self.mr.me_user_id = 111L

        self.issue_1 = fake.MakeTestIssue(789,
                                          1,
                                          'one',
                                          'New',
                                          111L,
                                          labels=['Priority-High'])
        self.services.issue.TestAddIssue(self.issue_1)
        self.issue_2 = fake.MakeTestIssue(789,
                                          2,
                                          'two',
                                          'New',
                                          111L,
                                          labels=['Priority-Low'])
        self.services.issue.TestAddIssue(self.issue_2)
        self.issue_3 = fake.MakeTestIssue(789,
                                          3,
                                          'three',
                                          'New',
                                          111L,
                                          labels=['Priority-Medium'])
        self.services.issue.TestAddIssue(self.issue_3)
        self.mr.sort_spec = 'Priority'

        self.mox = mox.Mox()
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_user_stub()
        self.testbed.init_memcache_stub()
        sorting.InitializeArtValues(self.services)
                         for rank, issue in enumerate(issues)]

        self.hotlist_items_list = [
            features_pb2.MakeHotlistItem(issue_id,
                                         rank=rank,
                                         adder_id=adder_id,
                                         date_added=date,
                                         note=note)
            for (issue_id, rank, adder_id, date, note) in hotlist_items
        ]
        self.test_hotlist = self.services.features.TestAddHotlist(
            'hotlist',
            hotlist_id=123,
            owner_ids=[111L],
            hotlist_item_fields=hotlist_items)
        sorting.InitializeArtValues(self.services)
        self.mr = None

    def setUpCreateHotlistTableDataTestMR(self, **kwargs):
        self.mr = testing_helpers.MakeMonorailRequest(**kwargs)
        self.services.user.TestAddUser('*****@*****.**', 148L)
        self.mr.auth.effective_ids = {148L}
        self.mr.col_spec = 'ID Summary Modified'

    def testCreateHotlistTableData(self):
        self.setUpCreateHotlistTableDataTestMR(hotlist=self.test_hotlist)
        table_data, table_related_dict = hotlist_helpers.CreateHotlistTableData(
            self.mr, self.hotlist_items_list, profiler.Profiler(),
            self.services)
        self.assertEqual(len(table_data), 3)
        start_index = 100001