def test_legit_refs(self, lookup): shortlink = mock.Mock(url='/p/project/tool/artifact') shortlink.ref.artifact.deleted = False lookup.return_value = shortlink self.assertEqual(mde.TracRef1().sub('#100'), '[#100](/p/project/tool/artifact)') self.assertEqual(mde.TracRef1().sub('r123'), '[r123](/p/project/tool/artifact)')
def test_run(self, lookup): shortlink = mock.Mock(url='/p/project/tool/artifact') shortlink.ref.artifact.deleted = False lookup.return_value = shortlink p = mde.PatternReplacingProcessor(mde.TracRef1(), mde.TracRef2()) res = p.run(['#100', 'ticket:100']) self.assertEqual(res, [ '[#100](/p/project/tool/artifact)', '[ticket:100](/p/project/tool/artifact)'])
def test_word_boundaries(self): self.assertEqual(mde.TracRef1().sub('foo#100'), 'foo#100') self.assertEqual(mde.TracRef1().sub('r123bar'), 'r123bar')
def test_skip_if_brackets(self): self.assertEqual(mde.TracRef1().sub('[#100]'), '[#100]') self.assertEqual(mde.TracRef1().sub('[r123]'), '[r123]')
def test_no_such_artifact(self, lookup): lookup.return_value = None self.assertEqual(mde.TracRef1().sub('#100'), '#100')