Пример #1
0
  def testProcessFormData_CantMove(self):
    """Test PFD when the user can't move issues."""
    mr = testing_helpers.MakeMonorailRequest(
        project=self.project,
        perms=permissions.COMMITTER_ACTIVE_PERMISSIONSET,
        user_info={'user_id': 111})
    mr.local_id_list = [99999]
    post_data = fake.PostData(move_to=['proj'])
    self.servlet.response = Response()
    self.servlet.ProcessFormData(mr, post_data)
    # 400 == bad request
    self.assertEqual(400, self.servlet.response.status)

    local_id_1 = self.services.issue.CreateIssue(
        self.cnxn, self.services, 789, 'issue summary', 'New', 111L,
        [], [], [], [], 111L, 'test issue')
    mr.perms = permissions.OWNER_ACTIVE_PERMISSIONSET
    mr.local_id_list = [local_id_1]
    mr.project_name = 'proj'
    self._MockMethods()
    self.servlet.ProcessFormData(mr, post_data)
    self.assertEqual(
        'The issues are already in project proj', mr.errors.move_to)

    post_data = fake.PostData(move_to=['notexist'])
    self.servlet.ProcessFormData(mr, post_data)
    self.assertEqual('No such project: notexist', mr.errors.move_to)
Пример #2
0
  def testProcessFormData_NormalEditIssues(self):
    issue4 = fake.MakeTestIssue(
        1, 4, 'issue_summary4', 'New', 222, project_name='project-name')
    self.services.issue.TestAddIssue(issue4)
    issue5 = fake.MakeTestIssue(
        1, 5, 'issue_summary5', 'New', 222, project_name='project-name')
    self.services.issue.TestAddIssue(issue5)

    post_data = fake.PostData(remove=['false'],
                              add_local_ids=['project-name:4, project-name:5'])
    url = self.servlet.ProcessFormData(self.mr, post_data)
    self.assertTrue('u/222/hotlists/hotlist' in url)
    self.assertEqual(len(self.test_hotlist.items), 5)
    self.assertEqual(
        self.test_hotlist.items[3].issue_id, issue4.issue_id)
    self.assertEqual(
        self.test_hotlist.items[4].issue_id, issue5.issue_id)

    post_data = fake.PostData(remove=['true'], remove_local_ids=[
        'project-name:4, project-name:1, project-name:2'])
    url = self.servlet.ProcessFormData(self.mr, post_data)
    self.assertTrue('u/222/hotlists/hotlist' in url)
    self.assertTrue(len(self.test_hotlist.items), 2)
    issue_ids = [issue.issue_id for issue in self.test_hotlist.items]
    self.assertTrue(issue5.issue_id in issue_ids)
    self.assertTrue(self.issue3.issue_id in issue_ids)
Пример #3
0
  def testParseListPreferences(self):
    # If no input, col_spec will be default column spec.
    # For other fiels empty strings should be returned.
    (col_spec, sort_spec, x_attr, y_attr, member_default_query,
     ) = issueadmin._ParseListPreferences({})
    self.assertEqual(tracker_constants.DEFAULT_COL_SPEC, col_spec)
    self.assertEqual('', sort_spec)
    self.assertEqual('', x_attr)
    self.assertEqual('', y_attr)
    self.assertEqual('', member_default_query)

    # Test how hyphens in input are treated.
    spec = 'label1-sub1  label2  label3-sub3'
    (col_spec, sort_spec, x_attr, y_attr, member_default_query,
     ) = issueadmin._ParseListPreferences(
        fake.PostData(default_col_spec=[spec],
                      default_sort_spec=[spec],
                      default_x_attr=[spec],
                      default_y_attr=[spec]),
        )

    # Hyphens (and anything following) should be stripped from each term.
    self.assertEqual('label1-sub1 label2 label3-sub3', col_spec)

    # The sort spec should be as given (except with whitespace condensed).
    self.assertEqual(' '.join(spec.split()), sort_spec)

    # Only the first term (up to the first hyphen) should be used for x- or
    # y-attr.
    self.assertEqual('label1-sub1', x_attr)
    self.assertEqual('label1-sub1', y_attr)

    # Test that multibyte strings are not mangled.
    spec = ('\xe7\xaa\xbf\xe8\x8b\xa5-\xe7\xb9\xb9 '
            '\xe5\x9c\xb0\xe3\x81\xa6-\xe5\xbd\x93-\xe3\x81\xbe\xe3\x81\x99')
    spec = spec.decode('utf-8')
    (col_spec, sort_spec, x_attr, y_attr, member_default_query,
     ) = issueadmin._ParseListPreferences(
        fake.PostData(default_col_spec=[spec],
                      default_sort_spec=[spec],
                      default_x_attr=[spec],
                      default_y_attr=[spec],
                      member_default_query=[spec]),
        )
    self.assertEqual(spec, col_spec)
    self.assertEqual(' '.join(spec.split()), sort_spec)
    self.assertEqual('\xe7\xaa\xbf\xe8\x8b\xa5-\xe7\xb9\xb9'.decode('utf-8'),
                     x_attr)
    self.assertEqual('\xe7\xaa\xbf\xe8\x8b\xa5-\xe7\xb9\xb9'.decode('utf-8'),
                     y_attr)
    self.assertEqual(spec, member_default_query)
Пример #4
0
    def testParsePersonData_NoDetails(self):
        mr = testing_helpers.MakeMonorailRequest(
            path='/p/proj/people/detail?u=111', project=self.project)
        post_data = fake.PostData(role=['owner'])
        u, r, ac, n, _, _ = self.servlet.ParsePersonData(mr, post_data)
        self.assertEquals(111, u)
        self.assertEquals('owner', r)
        self.assertEquals([], ac)
        self.assertEquals('', n)

        mr = testing_helpers.MakeMonorailRequest(
            path='/p/proj/people/detail?u=333', project=self.project)
        post_data = fake.PostData(role=['owner'])
        u, r, ac, n, _, _ = self.servlet.ParsePersonData(mr, post_data)
        self.assertEquals(333, u)
Пример #5
0
  def testProcessFormData_MoveTo(self):
    """Test PFD processes move_to values."""
    local_id_1 = self.services.issue.CreateIssue(
        self.cnxn, self.services, 789, 'issue to move', 'New', 111L,
        [], [], [], [], 111L, 'test issue')
    move_to_project = self.services.project.TestAddProject(
        name='proj2', project_id=790, owner_ids=[111])

    mr = testing_helpers.MakeMonorailRequest(
        project=self.project,
        perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
        user_info={'user_id': 111})
    mr.project_name = 'proj'
    mr.local_id_list = [local_id_1]

    self._MockMethods()
    post_data = fake.PostData(
        move_to=['proj2'], can=[1], q=[''],
        colspec=[''], sort=[''], groupby=[''], start=[0], num=[100])
    self.servlet.response = Response()
    self.servlet.ProcessFormData(mr, post_data)

    issue = self.services.issue.GetIssueByLocalID(
        self.cnxn, move_to_project.project_id, local_id_1)
    self.assertIsNotNone(issue)
Пример #6
0
 def testProcessFormData_AddBadIssueRef(self):
   self.servlet.PleaseCorrect = mock.Mock()
   post_data = fake.PostData(
       remove=['false'], add_local_ids=['no-such-project:999'])
   url = self.servlet.ProcessFormData(self.mr, post_data)
   self.assertIsNone(url)
   self.servlet.PleaseCorrect.assert_called_once()
Пример #7
0
    def testProcessEditField_Reject(self):
        post_data = fake.PostData(name=['CPU'],
                                  field_type=['INT_TYPE'],
                                  min_value=['4'],
                                  max_value=['1'],
                                  admin_names=[''])

        self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect')
        self.servlet.PleaseCorrect(self.mr,
                                   field_def=mox.IgnoreArg(),
                                   initial_applicable_type='',
                                   initial_choices='',
                                   initial_admins='',
                                   initial_approvers='')
        self.mox.ReplayAll()

        url = self.servlet._ProcessEditField(self.mr, post_data, self.config,
                                             self.fd)
        self.assertEqual('Minimum value must be less than maximum.',
                         self.mr.errors.min_value)
        self.assertIsNone(url)

        fd = tracker_bizobj.FindFieldDef('CPU', self.config)
        self.assertIsNone(fd.min_value)
        self.assertIsNone(fd.max_value)
Пример #8
0
 def testProcessRemoveMembers_SomeRemoved(self):
     self.services.usergroup.TestAddMembers(888, [111, 222, 333])
     post_data = fake.PostData(remove=['*****@*****.**', '*****@*****.**'])
     url = self.servlet.ProcessRemoveMembers(self.mr, post_data)
     self.assertIn('/g/[email protected]/?', url)
     members_after, _ = self.services.usergroup.LookupMembers('cnxn', [888])
     self.assertEqual(1, len(members_after[888]))
Пример #9
0
    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)
Пример #10
0
 def testProcessAddMembers_OwnerToEditor(self):
   hotlist = self.servlet.services.features.TestAddHotlist(
       'HotlistName', 'adding owner 111, buzbuz as editor', [111], [222])
   mr = testing_helpers.MakeMonorailRequest(
       path='/u/[email protected]/hotlists/HotlistName/people',
       hotlist=hotlist)
   mr.hotlist_id = hotlist.hotlist_id
   addmembers_input = '*****@*****.**'
   post_data = fake.PostData(
       addmembers = [addmembers_input],
       role = ['editor'])
   self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect')
   self.servlet.PleaseCorrect(
       mr, initial_add_members=addmembers_input, initially_expand_form=True)
   self.mox.ReplayAll()
   url = self.servlet.ProcessAddMembers(
       mr, post_data, '/u/111/hotlists/HotlistName')
   self.mox.VerifyAll()
   self.assertEqual(
       'Cannot have a hotlist without an owner; please leave at least one.',
       mr.errors.addmembers)
   self.assertIsNone(url)
   # Verify that no changes have actually occurred.
   self.assertEqual(hotlist.owner_ids, [111])
   self.assertEqual(hotlist.editor_ids, [222])
Пример #11
0
    def testProcessFormData_BadUserField(self):
        """Test PFD when a nonexistent user is added as a field value."""
        local_id_1, _ = self.services.issue.CreateIssue(
            self.cnxn, self.services, 789, 'issue summary', 'New', 111, [], [],
            [], [], 111, 'test issue')
        mr = testing_helpers.MakeMonorailRequest(
            project=self.project,
            perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
            user_info={'user_id': 111})
        mr.local_id_list = [local_id_1]

        fd = tracker_bizobj.MakeFieldDef(12345, 789, 'PM',
                                         tracker_pb2.FieldTypes.USER_TYPE,
                                         None, '', False, False, False, None,
                                         None, '', False, '', '',
                                         tracker_pb2.NotifyTriggers.NEVER,
                                         'no_action', 'doc', False)
        self.config.field_defs.append(fd)

        post_data = fake.PostData(custom_12345=['*****@*****.**'],
                                  owner=['*****@*****.**'],
                                  can=[1],
                                  q=[''],
                                  colspec=[''],
                                  sort=[''],
                                  groupby=[''],
                                  start=[0],
                                  num=[100])
        self._MockMethods()
        self.servlet.ProcessFormData(mr, post_data)
        self.assertEqual('User not found', mr.errors.custom_fields[0].message)
Пример #12
0
 def testProcessFormData_NoPermission(self):
   mr = testing_helpers.MakeMonorailRequest(
       perms=permissions.USER_PERMISSIONSET)
   post_data = fake.PostData(
     removebtn=[1])
   self.assertRaises(permissions.PermissionException,
                     self.servlet.ProcessFormData, mr, post_data)
Пример #13
0
    def testProcessEditComponent(self):
        post_data = fake.PostData(
            leaf_name=['BackEnd'],
            docstring=['This is where the magic happens'],
            deprecated=[True],
            admins=['*****@*****.**'],
            cc=['*****@*****.**'],
            labels=['Hot, Cold'])

        self.servlet._ProcessEditComponent(self.mr, post_data, self.config,
                                           self.cd)

        self.mox.VerifyAll()
        config = self.services.config.GetProjectConfig(self.mr.cnxn,
                                                       self.mr.project_id)
        cd = tracker_bizobj.FindComponentDef('BackEnd', config)
        self.assertEqual('BackEnd', cd.path)
        self.assertEqual('This is where the magic happens', cd.docstring)
        self.assertEqual(True, cd.deprecated)
        self.assertEqual([111L], cd.admin_ids)
        self.assertEqual([111L], cd.cc_ids)
        # Assert that creator and created were not updated.
        self.assertEqual(122L, cd.creator_id)
        self.assertEqual(100000, cd.created)
        # Assert that modifier and modified were updated.
        self.assertEqual(122L, cd.modifier_id)
        self.assertTrue(cd.modified > 10000000)
Пример #14
0
    def testProcessFormData_AcceptPhases(self):
        post_data = fake.PostData(name=['TestTemplate'],
                                  members_only=['on'],
                                  summary=['TLDR'],
                                  summary_must_be_edited=[''],
                                  content=['HEY WHY'],
                                  status=['Accepted'],
                                  owner=['*****@*****.**'],
                                  label=['label-One', 'label-Two'],
                                  custom_1=['NO'],
                                  custom_2=['MOOD'],
                                  components=['BackEnd'],
                                  component_required=['on'],
                                  owner_defaults_to_member=['on'],
                                  add_approvals=['on'],
                                  phase_0=['Canary'],
                                  phase_1=['Stable'],
                                  phase_2=[''],
                                  phase_3=[''],
                                  phase_4=[''],
                                  phase_5=[''],
                                  approval_3=['phase_0'],
                                  approval_4=['phase_1'])
        url = self.servlet.ProcessFormData(self.mr, post_data)

        self.assertTrue(
            '/templates/detail?saved=1&template=TestTemplate&' in url)

        self.services.template.UpdateIssueTemplateDef.assert_called_once_with(
            self.mr.cnxn,
            47925,
            12345,
            status='Accepted',
            component_required=True,
            phases=[
                tracker_pb2.Phase(name='Canary', rank=0, phase_id=0),
                tracker_pb2.Phase(name='Stable', rank=1, phase_id=1)
            ],
            approval_values=[
                tracker_pb2.ApprovalValue(approval_id=3, phase_id=0),
                tracker_pb2.ApprovalValue(approval_id=4, phase_id=1)
            ],
            name='TestTemplate',
            field_values=[
                tracker_pb2.FieldValue(field_id=1,
                                       str_value='NO',
                                       derived=False),
                tracker_pb2.FieldValue(field_id=2,
                                       str_value='MOOD',
                                       derived=False)
            ],
            labels=['label-One', 'label-Two'],
            owner_defaults_to_member=True,
            admin_ids=[],
            content='HEY WHY',
            component_ids=[1],
            summary_must_be_edited=False,
            summary='TLDR',
            members_only=True,
            owner_id=333)
Пример #15
0
  def testProcessFormData_RejectUnmodifiedTemplate(self):
    mr = testing_helpers.MakeMonorailRequest(
        path='/p/proj/issues/entry')
    mr.perms = permissions.USER_PERMISSIONSET
    mr.auth.user_view = framework_views.StuffUserView(100, 'user@invalid', True)
    post_data = fake.PostData(
        template_name=['rutabaga'],
        summary=['Nya nya I modified the summary'],
        comment=[self.template.content],
        status=['New'])

    self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect')
    self.servlet.PleaseCorrect(
        mr, component_required=None, fields=[], initial_blocked_on='',
        initial_blocking='', initial_cc='',
        initial_comment=self.template.content, initial_components='',
        initial_owner='', initial_status='New',
        initial_summary='Nya nya I modified the summary', initial_hotlists='',
        labels=[], template_name='rutabaga')
    self.mox.ReplayAll()

    url = self.servlet.ProcessFormData(mr, post_data)
    self.mox.VerifyAll()
    self.assertEqual('Template must be filled out.', mr.errors.comment)
    self.assertIsNone(url)
Пример #16
0
  def testProcessFormData_RejectPlacedholderSummary(self):
    mr = testing_helpers.MakeMonorailRequest(
        path='/p/proj/issues/entry')
    mr.auth.user_view = framework_views.StuffUserView(100, 'user@invalid', True)
    mr.perms = permissions.USER_PERMISSIONSET
    mr.template_name = 'rutabaga'
    post_data = fake.PostData(
        template_name=['rutabaga'],
        summary=[issueentry.PLACEHOLDER_SUMMARY],
        comment=['fake comment'],
        status=['New'])

    self.mox.StubOutWithMock(self.servlet, 'PleaseCorrect')
    self.servlet.PleaseCorrect(
        mr, component_required=None, fields=[], initial_blocked_on='',
        initial_blocking='', initial_cc='', initial_comment='fake comment',
        initial_components='', initial_owner='', initial_status='New',
        initial_summary='Enter one-line summary', initial_hotlists='',
        labels=[], template_name='rutabaga')
    self.mox.ReplayAll()

    url = self.servlet.ProcessFormData(mr, post_data)
    self.mox.VerifyAll()
    self.assertEqual('Summary is required', mr.errors.summary)
    self.assertIsNone(url)
Пример #17
0
 def testProcessSubtabForm_EmptyInput(self):
   post_data = fake.PostData(
       predefinedopen=[''], predefinedclosed=[''], statuses_offer_merge=[''])
   next_url = self.servlet.ProcessSubtabForm(post_data, self.mr)
   self.assertEqual(urls.ADMIN_STATUSES, next_url)
   self.assertEqual([], self.config.well_known_statuses)
   self.assertEqual([], self.config.statuses_offer_merge)
Пример #18
0
  def testProcessFormData_NormalBlockIssues(self):
    """Test PFD processes blocked_on and blocking values."""
    local_id_1 = self.services.issue.CreateIssue(
        self.cnxn, self.services, 789, 'issue summary', 'New', 111L,
        [], [], [], [], 111L, 'test issue')
    blocking_id = self.services.issue.CreateIssue(
        self.cnxn, self.services, 789, 'blocking', 'New', 111L,
        [], [], [], [], 111L, 'test issue')
    blocked_on_id = self.services.issue.CreateIssue(
        self.cnxn, self.services, 789, 'blocked on', 'New', 111L,
        [], [], [], [], 111L, 'test issue')
    mr = testing_helpers.MakeMonorailRequest(
        project=self.project,
        perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
        user_info={'user_id': 111})
    mr.project_name = 'proj'
    mr.local_id_list = [local_id_1]

    self._MockMethods()
    post_data = fake.PostData(
        op_blockedonenter=['append'], blocked_on=[str(blocked_on_id)],
        op_blockingenter=['append'], blocking=[str(blocking_id)],
        can=[1], q=[''],
        colspec=[''], sort=[''], groupby=[''], start=[0], num=[100])
    self.servlet.ProcessFormData(mr, post_data)

    self.assertIsNone(mr.errors.blocked_on)
    self.assertIsNone(mr.errors.blocking)
Пример #19
0
    def testProcessFormData(self):
        post_data = fake.PostData(name=['somefield'],
                                  field_type=['INT_TYPE'],
                                  min_value=['1'],
                                  max_value=['99'],
                                  notify_on=['any_comment'],
                                  importance=['required'],
                                  is_multivalued=['Yes'],
                                  docstring=['It is just some field'],
                                  applicable_type=['Defect'],
                                  date_action=['no_action'],
                                  admin_names=[''])
        url = self.servlet.ProcessFormData(self.mr, post_data)
        self.assertTrue('/adminLabels?saved=1&' in url)
        config = self.services.config.GetProjectConfig(self.mr.cnxn,
                                                       self.mr.project_id)

        fd = tracker_bizobj.FindFieldDef('somefield', config)
        self.assertEqual('somefield', fd.field_name)
        self.assertEqual(tracker_pb2.FieldTypes.INT_TYPE, fd.field_type)
        self.assertEqual(1, fd.min_value)
        self.assertEqual(99, fd.max_value)
        self.assertEqual(tracker_pb2.NotifyTriggers.ANY_COMMENT, fd.notify_on)
        self.assertTrue(fd.is_required)
        self.assertFalse(fd.is_niche)
        self.assertTrue(fd.is_multivalued)
        self.assertEqual('It is just some field', fd.docstring)
        self.assertEqual('Defect', fd.applicable_type)
        self.assertEqual('', fd.applicable_predicate)
        self.assertEqual([], fd.admin_ids)
Пример #20
0
    def testProcessFormData_CustomFields(self):
        """Test PFD processes edits to custom fields."""
        local_id_1, _ = self.services.issue.CreateIssue(
            self.cnxn, self.services, 789, 'issue summary', 'New', 111, [], [],
            [], [], 111, 'test issue')
        mr = testing_helpers.MakeMonorailRequest(
            project=self.project,
            perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
            user_info={'user_id': 111})
        mr.local_id_list = [local_id_1]

        fd = tracker_bizobj.MakeFieldDef(12345, 789, 'CPU',
                                         tracker_pb2.FieldTypes.INT_TYPE, None,
                                         '', False, False, False, None, None,
                                         '', False, '', '',
                                         tracker_pb2.NotifyTriggers.NEVER,
                                         'no_action', 'doc', False)
        self.config.field_defs.append(fd)

        post_data = fake.PostData(custom_12345=['111'],
                                  owner=['*****@*****.**'],
                                  can=[1],
                                  q=[''],
                                  colspec=[''],
                                  sort=[''],
                                  groupby=[''],
                                  start=[0],
                                  num=[100])
        self._MockMethods()
        self.servlet.ProcessFormData(mr, post_data)
        self.assertEqual((tracker_pb2.FieldID.CUSTOM, '111'),
                         self.GetFirstAmendment(789, local_id_1))
Пример #21
0
    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)
Пример #22
0
    def testProcessFormData_DuplicateStatus_MergeMissingIssue(self):
        """Test PFD processes null/cleared status values."""
        local_id_1, _ = self.services.issue.CreateIssue(
            self.cnxn, self.services, self.project.project_id, 'issue summary',
            'New', 111, [], [], [], [], 111, 'test issue')
        local_id_2, _ = self.services.issue.CreateIssue(
            self.cnxn, self.services, self.project.project_id,
            'issue summary2', 'New', 112, [], [], [], [], 112, 'test issue2')
        mr = testing_helpers.MakeMonorailRequest(
            project=self.project,
            perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
            user_info={'user_id': 111})
        mr.local_id_list = [local_id_1, local_id_2]
        mr.project_name = 'proj'

        post_data = fake.PostData(status=['Duplicate'],
                                  merge_into=['non existant id'],
                                  owner=['*****@*****.**'],
                                  can=[1],
                                  q=[''],
                                  colspec=[''],
                                  sort=[''],
                                  groupby=[''],
                                  start=[0],
                                  num=[100])
        self._MockMethods()
        self.servlet.ProcessFormData(mr, post_data)
        self.assertEquals('Please enter an issue ID', mr.errors.merge_into_id)
Пример #23
0
 def testProcessSubtabForm_Duplicates(self, mock_pc):
     post_data = fake.PostData(predefinedlabels=['Pri-0\nPri-4\npri-0'],
                               excl_prefixes=['pri'])
     next_url = self.servlet.ProcessSubtabForm(post_data, self.mr)
     self.assertIsNone(next_url)
     mock_pc.assert_called_once()
     self.assertEqual('Duplicate label: pri-0', self.mr.errors.label_defs)
Пример #24
0
    def testProcessFormData_BlockIssuesOnItself(self):
        """Test PFD processes invalid blocked_on and blocking values."""
        local_id_1, _ = self.services.issue.CreateIssue(
            self.cnxn, self.services, 789, 'issue summary', 'New', 111, [], [],
            [], [], 111, 'test issue')
        local_id_2, _ = self.services.issue.CreateIssue(
            self.cnxn, self.services, 789, 'issue summary', 'New', 111, [], [],
            [], [], 111, 'test issue')
        mr = testing_helpers.MakeMonorailRequest(
            project=self.project,
            perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
            user_info={'user_id': 111})
        mr.project_name = 'proj'
        mr.local_id_list = [local_id_1, local_id_2]

        self._MockMethods()
        post_data = fake.PostData(op_blockedonenter=['append'],
                                  blocked_on=[str(local_id_1)],
                                  op_blockingenter=['append'],
                                  blocking=[str(local_id_2)],
                                  can=[1],
                                  q=[''],
                                  colspec=[''],
                                  sort=[''],
                                  groupby=[''],
                                  start=[0],
                                  num=[100])
        self.servlet.ProcessFormData(mr, post_data)

        self.assertEqual('Cannot block an issue on itself.',
                         mr.errors.blocked_on)
        self.assertEqual('Cannot block an issue on itself.',
                         mr.errors.blocking)
Пример #25
0
 def testProcessFormData_Delete(self):
     post_data = fake.PostData(name=['CPU'], deletefield=['Submit'])
     url = self.servlet.ProcessFormData(self.mr, post_data)
     self.assertTrue('/adminLabels?deleted=1&' in url)
     fd = tracker_bizobj.FindFieldDef('CPU', self.config)
     self.assertEqual('CPU', fd.field_name)
     self.assertTrue(fd.is_deleted)
 def testProcessFormData_NotDeleted(self):
     self.mr.project_name = 'proj'
     post_data = fake.PostData()
     next_url = self.servlet.ProcessFormData(self.mr, post_data)
     self.assertEqual(
         'http://127.0.0.1/p/proj/adminAdvanced?saved=1&ts=%s' % NOW,
         next_url)
Пример #27
0
 def testProcessFormData_Normal(self):
     post_data = fake.PostData(visibility='0')
     url = self.servlet.ProcessFormData(self.mr, post_data)
     self.assertIn('/g/[email protected]/groupadmin', url)
     group_settings = self.services.usergroup.GetGroupSettings(None, 888)
     self.assertEqual(usergroup_pb2.MemberVisibility.OWNERS,
                      group_settings.who_can_view_members)
Пример #28
0
 def testProcessSubtabForm_EmptyInput(self):
   post_data = fake.PostData(
       predefinedlabels=[''], excl_prefixes=[''])
   next_url = self.servlet.ProcessSubtabForm(post_data, self.mr)
   self.assertEqual(urls.ADMIN_LABELS, next_url)
   self.assertEqual([], self.config.well_known_labels)
   self.assertEqual([], self.config.exclusive_label_prefixes)
Пример #29
0
  def testProcessFormData_DuplicateStatus_MergeSameIssue(self):
    """Test PFD processes null/cleared status values."""
    local_id_1 = self.services.issue.CreateIssue(
        self.cnxn, self.services, self.project.project_id, 'issue summary',
        'New', 111L, [], [], [], [], 111L, 'test issue')
    merge_into_local_id_2 = self.services.issue.CreateIssue(
        self.cnxn, self.services, self.project.project_id, 'issue summary2',
        'New', 112L, [], [], [], [], 112L, 'test issue2')

    mr = testing_helpers.MakeMonorailRequest(
        project=self.project,
        perms=permissions.OWNER_ACTIVE_PERMISSIONSET,
        user_info={'user_id': 111})
    mr.local_id_list = [local_id_1, merge_into_local_id_2]
    mr.project_name = 'proj'

    # Add required project_name to merge_into_issue.
    merge_into_issue = self.services.issue.GetIssueByLocalID(
        mr.cnxn, self.project.project_id, merge_into_local_id_2)
    merge_into_issue.project_name = 'proj'

    post_data = fake.PostData(status=['Duplicate'],
        merge_into=[str(merge_into_local_id_2)], owner=['*****@*****.**'],
        can=[1], q=[''], colspec=[''], sort=[''], groupby=[''], start=[0],
        num=[100])
    self._MockMethods()
    self.servlet.ProcessFormData(mr, post_data)
    self.assertEquals('Cannot merge issue into itself', mr.errors.merge_into_id)
Пример #30
0
 def testParseDefaultTempalteSelections_NotSpecified(self):
   self.config.templates.append(self.test_template)
   post_data = fake.PostData()
   for_devs, for_users = self.servlet._ParseDefaultTemplateSelections(
       post_data, self.config.templates)
   self.assertEqual(None, for_devs)
   self.assertEqual(None, for_users)