Пример #1
0
 def setUp(self):
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_taskqueue_stub()
     self.taskqueue_stub = self.testbed.get_stub(
         testbed.TASKQUEUE_SERVICE_NAME)
     self.taskqueue_stub._root_path = os.path.dirname(
         os.path.dirname(os.path.dirname(__file__)))
     self.services = service_manager.Services(
         user=fake.UserService(),
         usergroup=fake.UserGroupService(),
         project=fake.ProjectService(),
         config=fake.ConfigService(),
         issue=fake.IssueService(),
         issue_star=fake.IssueStarService(),
         features=fake.FeaturesService())
     self.services.user.TestAddUser('*****@*****.**', 1)
     self.services.user.TestAddUser('*****@*****.**', 2)
     self.services.user.TestAddUser('*****@*****.**', 3)
     self.services.project.TestAddProject('test-project',
                                          owner_ids=[1, 3],
                                          project_id=12345)
     self.issue1 = MakeTestIssue(project_id=12345,
                                 local_id=1,
                                 owner_id=2,
                                 reporter_id=1)
     self.services.issue.TestAddIssue(self.issue1)
Пример #2
0
    def setUp(self):
        self.services = service_manager.Services(
            config=fake.ConfigService(),
            issue=fake.IssueService(),
            user=fake.UserService(),
            project=fake.ProjectService(),
        )

        self.project_name = 'proj'
        self.project_id = 987
        self.project = self.services.project.TestAddProject(
            self.project_name,
            project_id=self.project_id,
            process_inbound_email=True)

        self.issue_id = 11
        self.issue_local_id = 100
        self.issue = tracker_pb2.Issue()
        self.issue.issue_id = self.issue_id
        self.issue.project_id = self.project_id
        self.issue.local_id = self.issue_local_id
        self.services.issue.TestAddIssue(self.issue)

        self.comment_id = 123
        self.comment_timestamp = 120
        self.user_id = 2
        self.mr_after = 1234

        self.mox = mox.Mox()
Пример #3
0
 def setUp(self):
     self.users_by_id = {
         111L: framework_views.StuffUserView(111L, '*****@*****.**',
                                             True),
         222L: framework_views.StuffUserView(222L, '*****@*****.**',
                                             True),
         999L: framework_views.StuffUserView(999L, '*****@*****.**',
                                             True),
     }
     self.services = service_manager.Services(
         project=fake.ProjectService(),
         config=fake.ConfigService(),
         issue=fake.IssueService(),
         user=fake.UserService(),
         usergroup=fake.UserGroupService())
     self.owner = self.services.user.TestAddUser('*****@*****.**', 111L)
     self.member = self.services.user.TestAddUser('*****@*****.**',
                                                  222L)
     self.visitor = self.services.user.TestAddUser('*****@*****.**',
                                                   999L)
     self.project = self.services.project.TestAddProject(
         'proj', owner_ids=[111L], committer_ids=[222L])
     self.project.process_inbound_email = True
     self.issue = fake.MakeTestIssue(self.project.project_id, 1, 'summary',
                                     'New', 111L)
Пример #4
0
    def setUp(self):
        self.project_service = fake.ProjectService()
        self.issue_service = fake.IssueService()
        self.issue_star_service = fake.IssueStarService()
        self.config_service = fake.ConfigService()
        self.features_service = fake.FeaturesService()
        self.project_star_service = fake.ProjectStarService()
        self.services = service_manager.Services(
            project=self.project_service,
            issue=self.issue_service,
            issue_star=self.issue_star_service,
            config=self.config_service,
            features=self.features_service,
            project_star=self.project_star_service,
            template=Mock(spec=template_svc.TemplateService),
            user=fake.UserService(),
            usergroup=fake.UserGroupService())

        self.proj1_id = 1001
        self.proj1_issue_id = 111
        self.proj1 = self.project_service.TestAddProject(
            name='proj1', project_id=self.proj1_id)
        self.proj2_id = 1002
        self.proj2_issue_id = 112
        self.proj2 = self.project_service.TestAddProject(
            name='proj2', project_id=self.proj2_id)

        self.mox = mox.Mox()
        self.cnxn = self.mox.CreateMock(sql.MonorailConnection)
        self.project_service.project_tbl = self.mox.CreateMock(
            sql.SQLTableManager)
        self.issue_service.issue_tbl = self.mox.CreateMock(sql.SQLTableManager)
Пример #5
0
    def setUp(self):
        self.cnxn = 'fake cnxn'
        self.services = service_manager.Services(
            issue=fake.IssueService(),
            user=fake.UserService(),
            usergroup=fake.UserGroupService(),
            project=fake.ProjectService(),
            config=fake.ConfigService())

        self.member = self.services.user.TestAddUser('*****@*****.**', 111)
        self.outsider = self.services.user.TestAddUser('*****@*****.**',
                                                       222)
        self.project = self.services.project.TestAddProject(
            'proj',
            project_id=987,
            process_inbound_email=True,
            committer_ids=[self.member.user_id])
        self.issue = tracker_pb2.Issue()
        self.issue.issue_id = 98701
        self.issue.project_id = 987
        self.issue.local_id = 1
        self.issue.owner_id = 0
        self.issue.summary = 'summary'
        self.issue.status = 'Assigned'
        self.services.issue.TestAddIssue(self.issue)

        self.uia = commitlogcommands.UpdateIssueAction(self.issue.local_id)
Пример #6
0
  def testGetStarredIssues_CrossProject(self):
    services = service_manager.Services(
        config=fake.ConfigService(),
        issue=fake.IssueService(),
        issue_star=fake.IssueStarService())
    project = fake.Project(project_name='proj', project_id=789)
    mr = testing_helpers.MakeMonorailRequest(
        project=project, user_info={'user_id': 111L})
    mr.query = 'project=proj,otherproj'

    # User has not starred anything yet.
    self.assertEqual(set(), issuelist._GetStarredIssues(
        mr.cnxn, mr.auth.user_id, services))

    # User starred 2 issues in 1 project, and 1 in another project.
    # Other users have also starred stuff.
    cnxn = 'fake connection'
    config = services.config.GetProjectConfig(cnxn, project.project_id)
    services.issue_star.SetStar(
        cnxn, services, config, 100001, 111L, True)
    services.issue_star.SetStar(
        cnxn, services, config, 100002, 111L, True)
    services.issue_star.SetStar(
        cnxn, services, config, 100002, 999L, True)
    services.issue_star.SetStar(
        cnxn, services, config, 100099, 999L, True)
    services.issue_star.SetStar(
        cnxn, services, config, 200001, 111L, True)
    services.issue_star.SetStar(
        cnxn, services, config, 200001, 999L, True)
    services.issue_star.SetStar(
        cnxn, services, config, 200099, 999L, True)
    self.assertEqual(
        {100001, 100002, 200001},
        issuelist._GetStarredIssues(mr.cnxn, mr.auth.user_id, services))
Пример #7
0
    def VerifyShouldShowFlipper(self,
                                expected,
                                query,
                                sort_spec,
                                can,
                                create_issues=0):
        """Instantiate a _Flipper and check if makes a pipeline or not."""
        services = service_manager.Services(config=fake.ConfigService(),
                                            issue=fake.IssueService(),
                                            project=fake.ProjectService(),
                                            user=fake.UserService())
        project = services.project.TestAddProject('proj',
                                                  project_id=987,
                                                  committer_ids=[111])
        mr = testing_helpers.MakeMonorailRequest(project=project)
        mr.query = query
        mr.sort_spec = sort_spec
        mr.can = can
        mr.project_name = project.project_name
        mr.project = project

        for idx in range(create_issues):
            _local_id, _ = services.issue.CreateIssue(
                self.cnxn, services, project.project_id, 'summary_%d' % idx,
                'status', 111, [], [], [], [], 111, 'description_%d' % idx)

        self.assertEqual(expected,
                         issuedetailezt._ShouldShowFlipper(mr, services))
Пример #8
0
    def setUp(self):
        self.mox = mox.Mox()
        self.mock_index = self.mox.CreateMockAnything()
        self.mox.StubOutWithMock(search, 'Index')
        self.docs = None
        self.cnxn = 'fake connection'
        self.user_service = fake.UserService()
        self.user_service.TestAddUser('*****@*****.**', 111)
        self.issue_service = fake.IssueService()
        self.config_service = fake.ConfigService()

        self.issue = fake.MakeTestIssue(123, 1, 'test summary', 'New', 111)
        self.issue_service.TestAddIssue(self.issue)
        self.comment = tracker_pb2.IssueComment(
            project_id=789,
            issue_id=self.issue.issue_id,
            user_id=111,
            content='comment content',
            attachments=[
                tracker_pb2.Attachment(filename='hello.c'),
                tracker_pb2.Attachment(filename='hello.h')
            ])
        self.issue_service.TestAddComment(self.comment, 1)
        self.users_by_id = framework_views.MakeAllUserViews(
            self.cnxn, self.user_service, [111])
Пример #9
0
    def setUp(self):
        self.services = service_manager.Services(user=fake.UserService(),
                                                 issue=fake.IssueService(),
                                                 config=fake.ConfigService(),
                                                 project=fake.ProjectService())
        self.servlet = componentdetail.ComponentDetail('req',
                                                       'res',
                                                       services=self.services)
        self.project = self.services.project.TestAddProject('proj')
        self.mr = testing_helpers.MakeMonorailRequest(
            project=self.project, perms=permissions.OWNER_ACTIVE_PERMISSIONSET)
        self.mr.auth.email = '*****@*****.**'
        self.config = self.services.config.GetProjectConfig(
            'fake cnxn', self.project.project_id)
        self.services.config.StoreConfig('fake cnxn', self.config)
        self.cd = tracker_bizobj.MakeComponentDef(1, self.project.project_id,
                                                  'BackEnd', 'doc', False, [],
                                                  [111L], 100000, 122L,
                                                  10000000, 133L)
        self.config.component_defs = [self.cd]
        self.services.user.TestAddUser('*****@*****.**', 111L)
        self.services.user.TestAddUser('*****@*****.**', 122L)
        self.services.user.TestAddUser('*****@*****.**', 133L)
        self.mr.component_path = 'BackEnd'

        self.mox = mox.Mox()
Пример #10
0
 def setUp(self):
     self.mox = mox.Mox()
     self.cnxn = fake.MonorailConnection()
     self.services = service_manager.Services(
         config=fake.ConfigService(),
         issue=fake.IssueService(),
         user=fake.UserService(),
         user_star=fake.UserStarService(),
         usergroup=fake.UserGroupService(),
         project=fake.ProjectService(),
         project_star=fake.ProjectStarService(),
         features=fake.FeaturesService())
     self.project = self.services.project.TestAddProject('proj',
                                                         project_id=987)
     self.user = self.services.user.TestAddUser('*****@*****.**', 111)
     self.user_2 = self.services.user.TestAddUser('*****@*****.**', 222)
     self.group1_id = self.services.usergroup.CreateGroup(
         self.cnxn, self.services, '*****@*****.**', 'anyone')
     self.group2_id = self.services.usergroup.CreateGroup(
         self.cnxn, self.services, '*****@*****.**', 'anyone')
     self.services.usergroup.UpdateMembers(self.cnxn, self.group1_id, [111],
                                           'member')
     self.services.usergroup.UpdateMembers(self.cnxn, self.group2_id,
                                           [222, 111], 'owner')
     self.users_svcr = users_servicer.UsersServicer(self.services,
                                                    make_rate_limiter=False)
     self.prpc_context = context.ServicerContext()
     self.prpc_context.set_code(codes.StatusCode.OK)
Пример #11
0
  def setUp(self):
    services = service_manager.Services(
        project=fake.ProjectService(),
        config=fake.ConfigService(),
        issue=fake.IssueService(),
        user=fake.UserService(),
        usergroup=fake.UserGroupService())
    services.user.TestAddUser('*****@*****.**', 111L)
    services.user.TestAddUser('*****@*****.**', 222L)
    services.user.TestAddUser('*****@*****.**', 333L)
    services.user.TestAddUser('*****@*****.**', 666L)

    # User group 888 has members: user_555 and [email protected]
    services.user.TestAddUser('*****@*****.**', 888L)
    services.usergroup.TestAddGroupSettings(888L, '*****@*****.**')
    services.usergroup.TestAddMembers(888L, [555L, 1001L])

    # User group 999 has members: user_111 and user_444
    services.user.TestAddUser('*****@*****.**', 999L)
    services.usergroup.TestAddGroupSettings(999L, '*****@*****.**')
    services.usergroup.TestAddMembers(999L, [111L, 444L])

    self.project = services.project.TestAddProject('proj')
    self.project.owner_ids.extend([111L])
    self.project.committer_ids.extend([222L])
    self.project.contributor_ids.extend([333L])
    self.servlet = issueoptions.IssueOptionsJSON(
        'req', webapp2.Response(), services=services)

    self.services = services
Пример #12
0
    def setUp(self):
        self.services = service_manager.Services(
            project=fake.ProjectService(),
            config=fake.ConfigService(),
            usergroup=fake.UserGroupService(),
            issue=fake.IssueService(),
            issue_star=fake.IssueStarService(),
            cache_manager=fake.CacheManager(),
            features=fake.FeaturesService(),
            user=fake.UserService())
        self.servlet = issuelist.IssueList('req',
                                           'res',
                                           services=self.services)
        self.project = self.services.project.TestAddProject('proj')
        self.issue1 = fake.MakeTestIssue(1,
                                         1,
                                         'issue_summary',
                                         'New',
                                         111,
                                         project_name='proj')
        self.services.issue.TestAddIssue(self.issue1)
        self.mr = testing_helpers.MakeMonorailRequest(project=self.project)
        self.mr.project_name = self.project.project_name
        self.mr.auth.effective_ids = {111}
        self.mr.me_user_id = 111

        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_memcache_stub()
        self.testbed.init_datastore_v3_stub()
Пример #13
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_taskqueue_stub()
        self.taskqueue_stub = self.testbed.get_stub(
            testbed.TASKQUEUE_SERVICE_NAME)
        self.taskqueue_stub._root_path = os.path.dirname(
            os.path.dirname(os.path.dirname(__file__)))
        self.services = service_manager.Services(
            user=fake.UserService(),
            usergroup=fake.UserGroupService(),
            project=fake.ProjectService(),
            config=fake.ConfigService(),
            issue=fake.IssueService(),
            issue_star=fake.IssueStarService(),
            features=fake.FeaturesService())
        self.services.user.TestAddUser('*****@*****.**', 1)
        self.services.user.TestAddUser('*****@*****.**', 2)
        self.services.user.TestAddUser('*****@*****.**', 3)
        self.services.project.TestAddProject('test-project',
                                             owner_ids=[1, 3],
                                             project_id=12345)
        self.issue1 = MakeTestIssue(project_id=12345,
                                    local_id=1,
                                    owner_id=2,
                                    reporter_id=1)
        self.services.issue.TestAddIssue(self.issue1)

        self._old_gcs_open = cloudstorage.open
        cloudstorage.open = fake.gcs_open
        self.orig_sign_attachment_id = attachment_helpers.SignAttachmentID
        attachment_helpers.SignAttachmentID = (lambda aid: 'signed_%d' % aid)
Пример #14
0
 def setUp(self):
     self.services = service_manager.Services(user=fake.UserService(),
                                              issue=fake.IssueService())
     self.servlet = dateaction.DateActionCron('req',
                                              'res',
                                              services=self.services)
     self.mox = mox.Mox()
  def setUp(self):
    self.mox = mox.Mox()
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_memcache_stub()
    self.testbed.init_app_identity_stub()
    self.testbed.init_urlfetch_stub()
    self.attachment_data = ""

    self._old_gcs_open = cloudstorage.open
    cloudstorage.open = fake.gcs_open

    services = service_manager.Services(
        project=fake.ProjectService(),
        config=fake.ConfigService(),
        issue=fake.IssueService(),
        user=fake.UserService())
    self.project = services.project.TestAddProject('proj')
    self.servlet = issueattachment.AttachmentPage(
        'req', webapp2.Response(), services=services)
    self.issue = fake.MakeTestIssue(
        self.project.project_id, 1, 'summary', 'New', 111L)
    services.issue.TestAddIssue(self.issue)
    self.comment = tracker_pb2.IssueComment(
        id=123, issue_id=self.issue.issue_id,
        project_id=self.project.project_id, user_id=111L,
        content='this is a comment')
    services.issue.TestAddComment(self.comment, self.issue.local_id)
    self.attachment = tracker_pb2.Attachment(
        attachment_id=54321, filename='hello.txt', filesize=23432,
        mimetype='text/plain', gcs_object_id='/pid/attachments/hello.txt')
    services.issue.TestAddAttachment(
        self.attachment, self.comment.id, self.issue.issue_id)
Пример #16
0
 def setUp(self):
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_user_stub()
     self.testbed.init_memcache_stub()
     self.testbed.init_datastore_v3_stub()
     self.services = service_manager.Services(
         project=fake.ProjectService(),
         config=fake.ConfigService(),
         issue=fake.IssueService(),
         issue_star=fake.IssueStarService(),
         user=fake.UserService(),
         usergroup=fake.UserGroupService(),
         features=fake.FeaturesService(),
         spam=fake.SpamService())
     self.services.user.TestAddUser('*****@*****.**', 111)
     self.proj = self.services.project.TestAddProject('proj',
                                                      project_id=789)
     self.cnxn = 'fake cnxn'
     self.servlet = issuepeek.IssuePeek('req',
                                        'res',
                                        services=self.services)
     self.local_id_1, _ = self.services.issue.CreateIssue(
         self.cnxn, self.services, 789, 'summary', 'status', 111, [], [],
         [], [], 111, 'The screen is just dark when I press power on')
  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)
Пример #18
0
 def setUpServlet(self, servlet_factory):
     # pylint: disable=attribute-defined-outside-init
     self.services = service_manager.Services(
         project=fake.ProjectService(),
         config=fake.ConfigService(),
         user=fake.UserService(),
         issue=fake.IssueService(),
         template=Mock(spec=template_svc.TemplateService),
         features=fake.FeaturesService())
     self.servlet = servlet_factory('req', 'res', services=self.services)
     self.project = self.services.project.TestAddProject('proj',
                                                         project_id=789,
                                                         contrib_ids=[333])
     self.config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)
     self.services.config.StoreConfig(None, self.config)
     self.cnxn = fake.MonorailConnection()
     self.mr = testing_helpers.MakeMonorailRequest(path='/p/proj/admin',
                                                   project=self.project)
     self.mox = mox.Mox()
     self.test_template = tracker_bizobj.MakeIssueTemplate(
         'Test Template', 'sum', 'New', 111, 'content', [], [], [], [])
     self.test_template.template_id = 12345
     self.test_templates = testing_helpers.DefaultTemplates()
     self.test_templates.append(self.test_template)
     self.services.template.GetProjectTemplates\
         .return_value = self.test_templates
     self.services.template.GetTemplateSetForProject\
         .return_value = [(12345, 'Test template', 0)]
Пример #19
0
 def setUp(self):
   self.services = service_manager.Services(
       issue=fake.IssueService(),
       spam=fake.SpamService())
   self.res = webapp2.Response()
   self.servlet = banspammer.BanSpammerTask('req', self.res,
       services=self.services)
Пример #20
0
    def setUp(self):
        self.cnxn = 'fake cnxn'
        self.services = service_manager.Services(
            config=fake.ConfigService(),
            issue=fake.IssueService(),
            user=fake.UserService(),
            usergroup=fake.UserGroupService(),
            project=fake.ProjectService())
        self.project = self.services.project.TestAddProject(
            'proj',
            project_id=987,
            process_inbound_email=True,
            contrib_ids=[111])
        self.project_addr = '*****@*****.**'

        self.issue = tracker_pb2.Issue()
        self.issue.project_id = 987
        self.issue.local_id = 100
        self.services.issue.TestAddIssue(self.issue)

        self.msg = testing_helpers.MakeMessage(testing_helpers.HEADER_LINES,
                                               'awesome!')

        request, _ = testing_helpers.GetRequestObjects()
        self.inbound = inboundemail.InboundEmail(request, None, self.services)
        self.mox = mox.Mox()
Пример #21
0
  def setUp(self):
    self.services = service_manager.Services(
        features=fake.FeaturesService(),
        project=fake.ProjectService(),
        config=fake.ConfigService(),
        issue=fake.IssueService(),
        issue_star=fake.IssueStarService(),
        user=fake.UserService(),
        usergroup=fake.UserGroupService())
    self.servlet = issuebulkedit.IssueBulkEdit(
        'req', 'res', services=self.services)
    self.mr = testing_helpers.MakeMonorailRequest(
        perms=permissions.OWNER_ACTIVE_PERMISSIONSET)
    self.project = self.services.project.TestAddProject(
        name='proj', project_id=789, owner_ids=[111])
    self.cnxn = 'fake connection'
    self.config = self.services.config.GetProjectConfig(
        self.cnxn, self.project.project_id)
    self.services.config.StoreConfig(self.cnxn, self.config)
    self.owner = self.services.user.TestAddUser('*****@*****.**', 111)

    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_taskqueue_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_datastore_v3_stub()
    self.taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
    self.taskqueue_stub._root_path = os.path.dirname(
        os.path.dirname(os.path.dirname( __file__ )))

    self.mocked_methods = {}
Пример #22
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)
Пример #23
0
 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())
     self.services.user.TestAddUser('*****@*****.**', 111)
Пример #24
0
 def setUp(self):
     self.services = service_manager.Services(config=fake.ConfigService(),
                                              issue=fake.IssueService(),
                                              user=fake.UserService(),
                                              project=fake.ProjectService())
     self.servlet = issuetips.IssueSearchTips('req',
                                              'res',
                                              services=self.services)
Пример #25
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_app_identity_stub()

        services = service_manager.Services(project=fake.ProjectService(),
                                            config=fake.ConfigService(),
                                            issue=fake.IssueService(),
                                            user=fake.UserService())
        self.project = services.project.TestAddProject('proj')
        self.servlet = issueattachmenttext.AttachmentText('req',
                                                          'res',
                                                          services=services)

        self.issue = tracker_pb2.Issue()
        self.issue.local_id = 1
        self.issue.issue_id = 1
        self.issue.summary = 'sum'
        self.issue.project_name = 'proj'
        self.issue.project_id = self.project.project_id
        services.issue.TestAddIssue(self.issue)

        self.comment0 = tracker_pb2.IssueComment()
        self.comment0.content = 'this is the description'
        self.comment1 = tracker_pb2.IssueComment()
        self.comment1.content = 'this is a comment'

        self.attach0 = tracker_pb2.Attachment(
            attachment_id=4567,
            filename='b.txt',
            mimetype='text/plain',
            gcs_object_id='/pid/attachments/abcd')
        self.comment0.attachments.append(self.attach0)

        self.attach1 = tracker_pb2.Attachment(
            attachment_id=1234,
            filename='a.txt',
            mimetype='text/plain',
            gcs_object_id='/pid/attachments/abcdefg')
        self.comment0.attachments.append(self.attach1)

        self.bin_attach = tracker_pb2.Attachment(
            attachment_id=2468,
            mimetype='application/octets',
            gcs_object_id='/pid/attachments/\0\0\0\0\0\1\2\3')
        self.comment1.attachments.append(self.bin_attach)

        self.comment0.project_id = self.project.project_id
        services.issue.TestAddComment(self.comment0, self.issue.local_id)
        self.comment1.project_id = self.project.project_id
        services.issue.TestAddComment(self.comment1, self.issue.local_id)
        services.issue.TestAddAttachment(self.attach0, self.comment0.id,
                                         self.issue.issue_id)
        services.issue.TestAddAttachment(self.attach1, self.comment1.id,
                                         self.issue.issue_id)
        # TODO(jrobbins): add tests for binary content
        self._old_gcs_open = cloudstorage.open
        cloudstorage.open = fake.gcs_open
Пример #26
0
 def setUp(self):
   self.services = service_manager.Services(
       user=fake.UserService(),
       issue=fake.IssueService(),
       project=fake.ProjectService(),
       config=fake.ConfigService(),
       issue_star=fake.IssueStarService())
   self.services.user.TestAddUser('*****@*****.**', 111)
   self.person_1 = api_pb2_v1_helpers.convert_person(111, None, self.services)
Пример #27
0
 def setUp(self):
     self.services = service_manager.Services(config=fake.ConfigService(),
                                              issue=fake.IssueService(),
                                              user=fake.UserService(),
                                              project=fake.ProjectService())
     self.project = self.services.project.TestAddProject('proj',
                                                         project_id=987)
     self.servlet = issueadvsearch.IssueAdvancedSearch(
         'req', 'res', services=self.services)
Пример #28
0
 def setUp(self):
     self.cnxn = 'fake cnxn'
     self.services = service_manager.Services(config=fake.ConfigService(),
                                              issue=fake.IssueService(),
                                              user=fake.UserService(),
                                              project=fake.ProjectService())
     self.project = self.services.project.TestAddProject('proj',
                                                         project_id=987)
     self.mox = mox.Mox()
Пример #29
0
def MakeFakeServiceManager():
  return service_manager.Services(
      user=fake.UserService(),
      usergroup=fake.UserGroupService(),
      project=fake.ProjectService(),
      config=fake.ConfigService(),
      issue=fake.IssueService(),
      issue_star=fake.IssueStarService(),
      features=fake.FeaturesService(),
      cache_manager=fake.CacheManager())
Пример #30
0
  def setUp(self):
    self.testbed = testbed.Testbed()
    self.testbed.activate()
    self.testbed.init_taskqueue_stub()
    self.testbed.init_memcache_stub()
    self.testbed.init_datastore_v3_stub()
    # Load queue.yaml.
    self.taskqueue_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
    self.taskqueue_stub._root_path = os.path.dirname(
        os.path.dirname(os.path.dirname( __file__ )))

    self.services = service_manager.Services(
        config=fake.ConfigService(),
        issue=fake.IssueService(),
        user=fake.UserService(),
        usergroup=fake.UserGroupService(),
        project=fake.ProjectService(),
        template=Mock(spec=template_svc.TemplateService),
        features=fake.FeaturesService())
    self.project = self.services.project.TestAddProject('proj', project_id=987)
    request = webapp2.Request.blank('/p/proj/issues/entry')
    response = webapp2.Response()
    self.servlet = issueentry.IssueEntry(
        request, response, services=self.services)
    self.user = self.services.user.TestAddUser('to_pass_tests', 0)
    self.services.features.TestAddHotlist(
        name='dontcare', summary='', owner_ids=[0])
    self.template = testing_helpers.DefaultTemplates()[1]
    self.services.template.GetTemplateByName = Mock(return_value=self.template)
    self.services.template.GetTemplateSetForProject = Mock(
        return_value=[(1, 'name', False)])

    # Set-up for testing hotlist parsing.
    # Scenario:
    #   Users: U1, U2, and U3
    #   Hotlists:
    #     H1: owned by U1 (private)
    #     H2: owned by U2, can be edited by U1 (private)
    #     H2: owned by U3, can be edited by U1 and U2 (public)
    self.cnxn = fake.MonorailConnection()
    self.U1 = self.services.user.TestAddUser('U1', 111)
    self.U2 = self.services.user.TestAddUser('U2', 222)
    self.U3 = self.services.user.TestAddUser('U3', 333)

    self.H1 = self.services.features.TestAddHotlist(
        name='H1', summary='', owner_ids=[111], is_private=True)
    self.H2 = self.services.features.TestAddHotlist(
        name='H2', summary='', owner_ids=[222], editor_ids=[111],
        is_private=True)
    self.H2_U3 = self.services.features.TestAddHotlist(
        name='H2', summary='', owner_ids=[333], editor_ids=[111, 222],
        is_private=False)

    self.mox = mox.Mox()