def setUp(self): self.services = service_manager.Services(project=fake.ProjectService(), user=fake.UserService()) self.project = self.services.project.TestAddProject('project') self.services.user.TestAddUser('*****@*****.**', 111L) self.services.user.TestAddUser('*****@*****.**', 222L) self.services.user.TestAddUser('*****@*****.**', 555L)
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)]
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()
def GetRequestObjects(headers=None, path='/', params=None, payload=None, user_info=None, project=None, method='GET', perms=None, services=None, hotlist=None): """Make fake request and MonorailRequest objects for testing. Host param will override the 'Host' header, and has a default value of '127.0.0.1'. Args: headers: Dict of HTTP header strings. path: Path part of the URL in the request. params: Dict of query-string parameters. user_info: Dict of user attributes to set on a MonorailRequest object. For example, "user_id: 5" causes self.auth.user_id=5. project: optional Project object for the current request. method: 'GET' or 'POST'. perms: PermissionSet to use for this request. services: Connections to backends. hotlist: optional Hotlist object for the current request Returns: A tuple of (http Request, monorailrequest.MonorailRequest()). """ headers = headers or {} params = params or {} headers.setdefault('Host', DEFAULT_HOST) post_items = None if method == 'POST' and payload: post_items = payload elif method == 'POST' and params: post_items = params if not services: services = service_manager.Services(project=fake.ProjectService(), user=fake.UserService(), usergroup=fake.UserGroupService(), features=fake.FeaturesService()) services.project.TestAddProject('proj') services.features.TestAddHotlist('hotlist') request = webapp2.Request.blank(path, headers=headers, POST=post_items) mr = fake.MonorailRequest(user_info=user_info, project=project, perms=perms, params=params, hotlist=hotlist) mr.ParseRequest(request, services, profiler.Profiler(), do_user_lookups=False) mr.auth.user_pb = user_pb2.MakeUser(0) return request, mr
def testProcessFormData_DuplicateName(self): self.servlet.services.features.TestAddHotlist( 'FirstHotlist', summary='hotlist summary', description='description', owner_ids=[111], editor_ids=[]) mr = testing_helpers.MakeMonorailRequest( hotlist=self.hotlist, path='/u/111/hotlists/%s/details' % (self.hotlist.hotlist_id), services=service_manager.Services(user=self.user_service)) mr.auth.user_id = 111 post_data = fake.PostData(summary=['hotlist summary'], name=['FirstHotlist'], description=['description'], default_col_spec=['test default col spec']) self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect') self.servlet.PleaseCorrect( mr, initial_summary='hotlist summary', initial_description='description', initial_name='FirstHotlist', initial_default_col_spec='test default col spec') self.mox.ReplayAll() url = self.servlet.ProcessFormData(mr, post_data) self.mox.VerifyAll() self.assertEqual(hotlistdetails._MSG_HOTLIST_NAME_NOT_AVAIL, mr.errors.name) self.assertIsNone(url)
def setUp(self): self.services = service_manager.Services( user=fake.UserService(), usergroup=fake.UserGroupService()) self.user1 = self.services.user.TestAddUser('user1', 111) self.user1.obscure_email = True self.user1_view = framework_views.UserView(self.user1) self.user2 = self.services.user.TestAddUser('user2', 222) self.user2.obscure_email = False self.user2_view = framework_views.UserView(self.user2) self.user3 = self.services.user.TestAddUser('user3', 333) self.user3_view = framework_views.UserView(self.user3) self.user4 = self.services.user.TestAddUser('user4', 444, banned=True) self.user4_view = framework_views.UserView(self.user4) self.user_auth = authdata.AuthData.FromEmail(None, 'user3', self.services) self.user_auth.effective_ids = {3} self.user_auth.user_id = 3 self.users_by_id = { 1: self.user1_view, 2: self.user2_view, 3: self.user3_view, 4: self.user4_view } self.perms = permissions.EMPTY_PERMISSIONSET
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.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)
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
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.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.config = tracker_bizobj.MakeDefaultProjectIssueConfig(789) self.services = service_manager.Services(user=fake.UserService()) self.mr = testing_helpers.MakeMonorailRequest(project=fake.Project(), services=self.services) self.mr.cnxn = fake.MonorailConnection() self.errors = template_helpers.EZTError()
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()
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)
def testGatherHelpData_GridSwitchesToIDs(self): services = service_manager.Services() servlet = issuelist.IssueList('req', 'res', services=services) mr = testing_helpers.MakeMonorailRequest() page_data = {'results': [1, 2, 3]} # Don't show cue if in issue list mode (the default). help_data = servlet.GatherHelpData(mr, page_data) self.assertNotEqual('showing_ids_instead_of_tiles', help_data['cue']) mr.mode = 'grid' # Don't show cue if showing already IDs (the default). help_data = servlet.GatherHelpData(mr, page_data) self.assertNotEqual('showing_ids_instead_of_tiles', help_data['cue']) mr.cells = 'counts' # Don't show cue if showing counts. help_data = servlet.GatherHelpData(mr, page_data) self.assertNotEqual('showing_ids_instead_of_tiles', help_data['cue']) mr.cells = 'tiles' # Don't show cue if there were <= 1000 results help_data = servlet.GatherHelpData(mr, page_data) self.assertNotEqual('showing_ids_instead_of_tiles', help_data['cue']) # Show cue if there are more than 1000 results page_data = {'results': [1] * (settings.max_tiles_in_grid + 1)} help_data = servlet.GatherHelpData(mr, page_data) self.assertEqual('showing_ids_instead_of_tiles', help_data['cue'])
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()
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)
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)
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 = {}
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 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()
def setUp(self): self.services = service_manager.Services( project=fake.ProjectService(), user=fake.UserService(), project_star=fake.ProjectStarService()) self.projects_json_feed = userprojects.ProjectsJsonFeed( 'req', 'res', services=self.services)
def testProcessFormData_RejectTemplate(self): mr = testing_helpers.MakeMonorailRequest( hotlist=self.hotlist, path='/u/111/hotlists/%s/details' % self.hotlist.hotlist_id, services=service_manager.Services(user=self.user_service)) mr.auth.user_id = 111 post_data = fake.PostData(summary=[''], name=[''], description=['fake description'], default_col_spec=['test default col spec']) self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect') self.servlet.PleaseCorrect( mr, initial_summary='', initial_description='fake description', initial_name='', initial_default_col_spec='test default col spec') self.mox.ReplayAll() url = self.servlet.ProcessFormData(mr, post_data) self.mox.VerifyAll() self.assertEqual(hotlistdetails._MSG_NAME_MISSING, mr.errors.name) self.assertEqual(hotlistdetails._MSG_SUMMARY_MISSING, mr.errors.summary) self.assertIsNone(url)
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)
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))
def testConvertComment(self): """Test convert_comment.""" svcs = service_manager.Services() svcs.user = fake.UserService() svcs.user.TestAddUser('*****@*****.**', 1) mar = mock.Mock() mar.cnxn = None issue = fake.MakeTestIssue(project_id=12345, local_id=1, summary='sum', status='New', owner_id=1001) comment = tracker_pb2.IssueComment( user_id=1, content='test content', sequence=1, deleted_by=1, timestamp=1437700000, ) result = api_pb2_v1_helpers.convert_comment(issue, comment, mar, svcs, None) self.assertEquals('*****@*****.**', result.author.name) self.assertEquals(comment.content, result.content) self.assertEquals('*****@*****.**', result.deletedBy.name) self.assertEquals(1, result.id) # Ensure that the published timestamp falls in a timestamp range to account # for the test being run in different timezones. # Using "Fri, 23 Jul 2015 00:00:00" and "Fri, 25 Jul 2015 00:00:00". self.assertTrue( datetime.datetime(2015, 7, 23, 0, 0, 0) <= result.published <= datetime.datetime(2015, 7, 25, 0, 0, 0))
def setUp(self): self.cnxn = 'fake sql connection' self.services = service_manager.Services(project=fake.ProjectService(), user=fake.UserService()) self.services.user.TestAddUser('*****@*****.**', 111L) self.services.user.TestAddUser('*****@*****.**', 222L) self.services.user.TestAddUser('*****@*****.**', 333L)
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))
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)
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)