def test_subject_and_debt_comment(self): """ Test that the subject's comment and the technical debt comment are combined. """ self.__subject.options['comment'] = 'Subject.' self.__subject.debt_target = domain.TechnicalDebtTarget(10, 'Debt.') self.assertEqual( 'De op dit moment geaccepteerde technische schuld is 10 foo. Debt. Subject.', self.__metric.comment())
def test_comment_technical_debt(self): """ Test that the metric gets the comment from the subject when the subject has a reduced technical debt target. """ self.__subject.debt_target = domain.TechnicalDebtTarget(10, 'Comment') self.assertEqual( 'De op dit moment geaccepteerde technische schuld is 10 foo. Comment', self.__metric.comment())
def test_debt_and_adapted_target_comment(self): """ Test that the metric comment mentions both debt and adapted target. """ # pylint: disable=attribute-defined-outside-init self.__subject.debt_target = domain.TechnicalDebtTarget(10, 'Debt.') self.__subject.low_target = lambda subject: 'Subject specific target' self.assertEqual("De norm is aangepast van Subclass responsibility foo (default) naar Subject specific " "target foo. De op dit moment geaccepteerde technische schuld is 10 foo. Debt.", self.__metric.comment())
def test_technical_debt(self, mock_ncloc): """ Test that technical debt can be specified via the project. """ project = domain.Project( metric_sources={metric_source.Sonar: self.__sonar, metric_source.History: MagicMock()}, metric_source_ids={self.__sonar: "dummy"}, metric_options={metric.TotalLOC: dict(target=100, low_target=110, debt_target=domain.TechnicalDebtTarget(150))}) product = domain.Product(short_name='PR', name='FakeSubject', metric_source_ids={self.__sonar: 'sonar id'}) project.add_product(product) total_loc = metric.TotalLOC(subject=project, project=project) mock_ncloc.return_value = 111 self.assertEqual('grey', total_loc.status())
def test_status_with_technical_debt(self): """ Test that the status is grey when the subject has accepted technical debt. """ self.__subject.technical_debt_target = lambda *args: domain.TechnicalDebtTarget( 51, 'Comment') self.assertEqual('grey', self._metric.status())
def test_comment_technical_debt_url(self): """ Test that the metric has no comment url when the subject has a reduced technical debt target because the reduced technical debt target is specified in the project definition. """ self.__subject.debt_target = domain.TechnicalDebtTarget(10, 'Comment') self.assertFalse(self.__metric.comment_urls())
""" Project definition for testing metric options. """ from hqlib import metric, domain # The project PROJECT = domain.Project('Integrationtest', name='metric options') # Products the project develops. APPLICATION = domain.Application( short_name='AP', name='Application FOO', metric_options={ metric.ARTStatementCoverage: dict(debt_target=domain.TechnicalDebtTarget( 42, explanation="How do we explain this?")), metric.ARTBranchCoverage: dict(target=35, low_target=30) }) PROJECT.add_product(APPLICATION) # Dashboard layout # Columns in the dashboard is specified as a list of tuples. Each tuple # contains a column header and the column span. DASHBOARD_COLUMNS = [('Products', 1), ('Algemeen', 1)] # Rows in the dashboard is a list of row tuples. Each row tuple consists of # tuples that describe a cell in the dashboard. Each cell is a tuple containing # the product or team and the color. Optionally the cell tuple can contain a # third value which is a tuple containing the column and row span for the cell.
def test_technical_debt(self): """ Test that the status is grey when the current value is accepted technical debt. """ # pylint: disable=attribute-defined-outside-init self.__subject.technical_debt_target = lambda metric: domain.TechnicalDebtTarget( 0, 'Comment') self.assertEqual('grey', self.__metric.status())