Ejemplo n.º 1
0
def _MakeConfig():
    config = tracker_pb2.ProjectIssueConfig()
    config.well_known_labels = [
        tracker_pb2.LabelDef(label='Priority-High',
                             label_docstring='Must be resolved'),
        tracker_pb2.LabelDef(label='Priority-Low',
                             label_docstring='Can be slipped'),
    ]
    config.well_known_statuses.append(
        tracker_pb2.StatusDef(status='New', means_open=True))
    config.well_known_statuses.append(
        tracker_pb2.StatusDef(status='Old', means_open=False))
    return config
  def testLabelView(self):
    view = framework_views.LabelView('', None)
    self.assertEquals('', view.name)

    view = framework_views.LabelView('Priority-High', None)
    self.assertEquals('Priority-High', view.name)
    self.assertIsNone(view.is_restrict)
    self.assertEquals('', view.docstring)
    self.assertEquals('Priority', view.prefix)
    self.assertEquals('High', view.value)

    view = framework_views.LabelView('%s-%s' % (LONG_STR, LONG_STR), None)
    self.assertEquals('%s-%s' % (LONG_STR, LONG_STR), view.name)
    self.assertEquals('', view.docstring)
    self.assertEquals(LONG_STR, view.prefix)
    self.assertEquals(LONG_STR, view.value)

    view = framework_views.LabelView(LONG_PART_STR, None)
    self.assertEquals(LONG_PART_STR, view.name)
    self.assertEquals('', view.docstring)
    self.assertEquals('OnePartThatWillNotFit', view.prefix)
    self.assertEquals('OneShort', view.value)

    config = tracker_pb2.ProjectIssueConfig()
    config.well_known_labels.append(tracker_pb2.LabelDef(
        label='Priority-High', label_docstring='Must ship in this milestone'))

    view = framework_views.LabelView('Priority-High', config)
    self.assertEquals('Must ship in this milestone', view.docstring)

    view = framework_views.LabelView('Priority-Foo', config)
    self.assertEquals('', view.docstring)

    view = framework_views.LabelView('Restrict-View-Commit', None)
    self.assertTrue(view.is_restrict)
Ejemplo n.º 3
0
def SetConfigLabels(project_config, well_known_labels):
    """Internal method to set the well-known labels of a ProjectIssueConfig."""
    project_config.well_known_labels = []
    for label, docstring, deprecated in well_known_labels:
        canonical_label = framework_bizobj.CanonicalizeLabel(label)
        project_config.well_known_labels.append(
            tracker_pb2.LabelDef(label=canonical_label,
                                 label_docstring=docstring,
                                 deprecated=deprecated))
Ejemplo n.º 4
0
    def testParseChoicesIntoWellKnownLabels_NotEnumField(self):
        choices_text = ''
        field_name = 'NotEnum'
        self.config.well_known_labels = [
            tracker_pb2.LabelDef(label='NotEnum-Should'),
            tracker_pb2.LabelDef(label='NotEnum-Not-Be-Masked')
        ]
        revised_labels = field_helpers._ParseChoicesIntoWellKnownLabels(
            choices_text, field_name, self.config, 'str_type')
        new_labels = [('NotEnum-Should', None, False),
                      ('NotEnum-Not-Be-Masked', None, False)]
        self.assertEqual(new_labels, revised_labels)

        # TODO(jojwang): test this separately
        # test None field_type_str, updating existing fielddef
        self.config.field_defs.append(
            tracker_pb2.FieldDef(field_id=13,
                                 field_name='NotEnum',
                                 field_type=tracker_pb2.FieldTypes.STR_TYPE))
        revised_labels = field_helpers._ParseChoicesIntoWellKnownLabels(
            choices_text, field_name, self.config, None)
        self.assertEqual(revised_labels, new_labels)
Ejemplo n.º 5
0
 def setUp(self):
     self.config = tracker_pb2.ProjectIssueConfig()
     self.estdays_fd = tracker_bizobj.MakeFieldDef(
         1, 789, 'EstDays', tracker_pb2.FieldTypes.INT_TYPE, None, None,
         False, False, False, 3, 99, None, False, None, None, None,
         'no_action', 'descriptive docstring', False, None, False)
     self.os_fd = tracker_bizobj.MakeFieldDef(
         2, 789, 'OS', tracker_pb2.FieldTypes.ENUM_TYPE, 'Enhancement',
         None, False, False, False, None, None, None, False, None, None,
         None, 'no_action', 'descriptive docstring', False, None, False)
     self.milestone_fd = tracker_bizobj.MakeFieldDef(
         3, 789, 'Launch-Milestone', tracker_pb2.FieldTypes.ENUM_TYPE,
         'Enhancement', None, False, False, False, None, None, None, False,
         None, None, None, 'no_action', 'descriptive docstring', False,
         None, False)
     self.config.field_defs = [
         self.estdays_fd, self.os_fd, self.milestone_fd
     ]
     self.config.well_known_labels = [
         tracker_pb2.LabelDef(label='Priority-High',
                              label_docstring='Must be resolved'),
         tracker_pb2.LabelDef(label='Priority-Low',
                              label_docstring='Can be slipped'),
     ]
Ejemplo n.º 6
0
    def setUp(self):
        self.config = tracker_bizobj.MakeDefaultProjectIssueConfig(789)
        self.config.well_known_labels.append(
            tracker_pb2.LabelDef(label='OldLabel',
                                 label_docstring='Do not use any longer',
                                 deprecated=True))

        self.services = service_manager.Services(
            usergroup=fake.UserGroupService(),
            config=fake.ConfigService(),
            user=fake.UserService())
        self.mr = testing_helpers.MakeMonorailRequest(project=fake.Project(),
                                                      services=self.services)
        self.mr.cnxn = fake.MonorailConnection()
        self.errors = template_helpers.EZTError()
Ejemplo n.º 7
0
def HarmonizeConfigs(config_list):
    """Combine several ProjectIssueConfigs into one for cross-project sorting.

  Args:
    config_list: a list of ProjectIssueConfig PBs with labels and statuses
        among other fields.

  Returns:
    A new ProjectIssueConfig with just the labels and status values filled
    in to be a logical union of the given configs.  Specifically, the order
    of the combined status and label lists should be maintained.
  """
    if not config_list:
        return MakeDefaultProjectIssueConfig(None)

    harmonized_status_names = _CombineOrderedLists(
        [[stat.status for stat in config.well_known_statuses]
         for config in config_list])
    harmonized_label_names = _CombineOrderedLists(
        [[lab.label for lab in config.well_known_labels]
         for config in config_list])
    harmonized_default_sort_spec = ' '.join(config.default_sort_spec
                                            for config in config_list)
    # This col_spec is probably not what the user wants to view because it is
    # too much information.  We join all the col_specs here so that we are sure
    # to lookup all users needed for sorting, even if it is more than needed.
    # xxx we need to look up users based on colspec rather than sortspec?
    harmonized_default_col_spec = ' '.join(config.default_col_spec
                                           for config in config_list)

    result_config = tracker_pb2.ProjectIssueConfig()
    # The combined config is only used during sorting, never stored.
    result_config.default_col_spec = harmonized_default_col_spec
    result_config.default_sort_spec = harmonized_default_sort_spec

    for status_name in harmonized_status_names:
        result_config.well_known_statuses.append(
            tracker_pb2.StatusDef(status=status_name, means_open=True))

    for label_name in harmonized_label_names:
        result_config.well_known_labels.append(
            tracker_pb2.LabelDef(label=label_name))

    for config in config_list:
        result_config.field_defs.extend(config.field_defs)
        result_config.component_defs.extend(config.component_defs)

    return result_config
Ejemplo n.º 8
0
    def testLabelDefsAsText(self):
        # Note: Day-Monday will not be part of the result because it is masked.
        self.config.field_defs.append(
            tracker_pb2.FieldDef(field_id=1,
                                 field_name='Day',
                                 field_type=tracker_pb2.FieldTypes.ENUM_TYPE))
        self.config.well_known_labels.append(
            tracker_pb2.LabelDef(label='Day-Monday'))
        labels_text = tracker_views.LabelDefsAsText(self.config)

        for wkl in tracker_constants.DEFAULT_WELL_KNOWN_LABELS:
            label, doc, _deprecated = wkl
            self.assertIn(label, labels_text)
            self.assertIn(doc, labels_text)
        self.assertEqual(len(tracker_constants.DEFAULT_WELL_KNOWN_LABELS),
                         len(labels_text.split('\n')))
Ejemplo n.º 9
0
    def setUp(self):
        self.services = service_manager.Services(project=fake.ProjectService(),
                                                 config=fake.ConfigService(),
                                                 user=fake.UserService())

        self.services.project.TestAddProject('proj', owner_ids=[111])
        self.services.user.TestAddUser('*****@*****.**', 222)

        cnxn = 'fake connection'
        config = self.services.config.GetProjectConfig(cnxn, 789)

        for status in ['New', 'ReadyForReview']:
            config.well_known_statuses.append(
                tracker_pb2.StatusDef(status=status))

        for label in ['Prioity-Low', 'Priority-High']:
            config.well_known_labels.append(tracker_pb2.LabelDef(label=label))

        config.exclusive_label_prefixes.extend(
            tracker_constants.DEFAULT_EXCL_LABEL_PREFIXES)

        self.services.config.StoreConfig(cnxn, config)
Ejemplo n.º 10
0
def MakeLabel(prefix):
  return tracker_pb2.LabelDef(
      label='%s-label' % prefix,
      label_docstring='%s-description' % prefix
  )