Exemple #1
0
def _MakeConfig():
  config = tracker_pb2.ProjectIssueConfig()
  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 _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 testStatusView(self):
    view = framework_views.StatusView('', None)
    self.assertEquals('', view.name)

    view = framework_views.StatusView('Accepted', None)
    self.assertEquals('Accepted', view.name)
    self.assertEquals('', view.docstring)
    self.assertEquals('yes', view.means_open)

    view = framework_views.StatusView(LONG_STR, None)
    self.assertEquals(LONG_STR, view.name)
    self.assertEquals('', view.docstring)
    self.assertEquals('yes', view.means_open)

    config = tracker_pb2.ProjectIssueConfig()
    config.well_known_statuses.append(tracker_pb2.StatusDef(
        status='SlamDunk', status_docstring='Code fixed and taught a lesson',
        means_open=False))

    view = framework_views.StatusView('SlamDunk', config)
    self.assertEquals('Code fixed and taught a lesson', view.docstring)
    self.assertFalse(view.means_open)

    view = framework_views.StatusView('SlammedBack', config)
    self.assertEquals('', view.docstring)
def SetConfigStatuses(project_config, well_known_statuses):
    """Internal method to set the well-known statuses of ProjectIssueConfig."""
    project_config.well_known_statuses = []
    for status, docstring, means_open, deprecated in well_known_statuses:
        canonical_status = framework_bizobj.CanonicalizeLabel(status)
        project_config.well_known_statuses.append(
            tracker_pb2.StatusDef(status_docstring=docstring,
                                  status=canonical_status,
                                  means_open=means_open,
                                  deprecated=deprecated))
Exemple #5
0
  def testSimpleIssueView(self):
    config = tracker_pb2.ProjectIssueConfig()
    view1 = self.CheckSimpleIssueView(config)
    self.assertEqual('', view1.status.docstring)

    config.well_known_statuses.append(tracker_pb2.StatusDef(
        status='New', status_docstring='Issue has not had review yet'))
    view1 = self.CheckSimpleIssueView(config)
    self.assertEqual('Issue has not had review yet',
                     view1.status.docstring)
    self.assertIsNone(view1.restrictions.has_restrictions)
    self.assertEqual('', view1.restrictions.view)
    self.assertEqual('', view1.restrictions.add_comment)
    self.assertEqual('', view1.restrictions.edit)
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
Exemple #7
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)
def MakeStatus(prefix):
  return tracker_pb2.StatusDef(
      status='%s-New' % prefix,
      means_open=True,
      status_docstring='%s-status' % prefix
  )