helpers: fix tests and tag replacers
This commit is contained in:
parent
d35897dfcc
commit
4b9bf78fc5
2 changed files with 12 additions and 11 deletions
|
|
@ -1069,7 +1069,8 @@ tags_patterns = OrderedDict(
|
|||
re.compile(
|
||||
r"\[license\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]"
|
||||
),
|
||||
r'<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>',
|
||||
# don't make it a raw string here...
|
||||
'<div class="metatag" tag="license"><a href="http:\/\/www.opensource.org/licenses/\\1">\\1</a></div>',
|
||||
),
|
||||
),
|
||||
(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ from rhodecode.tests import no_newline_id_generator
|
|||
|
||||
|
||||
@pytest.mark.parametrize('url, expected_url', [
|
||||
(r'https://rc.com', '<a href="https://rc.com">http://rc.com</a>'),
|
||||
(r'https://rc.com', '<a href="https://rc.com">https://rc.com</a>'),
|
||||
(r'https://rc.com/test', '<a href="https://rc.com/test">https://rc.com/test</a>'),
|
||||
(r'https://rc.com/!foo', '<a href="https://rc.com/!foo">https://rc.com/!foo</a>'),
|
||||
(r'https://rc.com/&foo', '<a href="https://rc.com/&foo">https://rc.com/&foo</a>'),
|
||||
|
|
@ -131,13 +131,13 @@ def test_extract_issues(backend, text_string, pattern, expected):
|
|||
|
||||
@pytest.mark.parametrize('text_string, pattern, link_format, expected_text', [
|
||||
('Fix #42', '(?:#)(?P<issue_id>\d+)', 'html',
|
||||
'Fix <a class="tooltip issue-tracker-link" href="http://r.io/{repo}/i/42" title="Test Pattern">#42</a>'),
|
||||
'Fix <a class="tooltip issue-tracker-link" href="https://r.io/{repo}/i/42" title="Test Pattern">#42</a>'),
|
||||
|
||||
('Fix #42', '(?:#)(?P<issue_id>\d+)', 'markdown',
|
||||
'Fix [#42](http://r.io/{repo}/i/42)'),
|
||||
'Fix [#42](https://r.io/{repo}/i/42)'),
|
||||
|
||||
('Fix #42', '(?:#)(?P<issue_id>\d+)', 'rst',
|
||||
'Fix `#42 <http://r.io/{repo}/i/42>`_'),
|
||||
'Fix `#42 <https://r.io/{repo}/i/42>`_'),
|
||||
|
||||
('Fix #42', '(?:#)?<issue_id>\d+)', 'html',
|
||||
'Fix #42'), # Broken regex
|
||||
|
|
@ -150,7 +150,7 @@ def test_process_patterns_repo(backend, text_string, pattern, expected_text, lin
|
|||
'123': {
|
||||
'uid': '123',
|
||||
'pat': pattern,
|
||||
'url': 'http://r.io/${repo}/i/${issue_id}',
|
||||
'url': 'https://r.io/${repo}/i/${issue_id}',
|
||||
'pref': '#',
|
||||
'desc': 'Test Pattern'
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ def test_process_patterns_repo(backend, text_string, pattern, expected_text, lin
|
|||
|
||||
@pytest.mark.parametrize('text_string, pattern, expected_text', [
|
||||
('Fix #42', '(?:#)(?P<issue_id>\d+)',
|
||||
'Fix <a class="tooltip issue-tracker-link" href="http://r.io/i/42" title="Test Pattern">#42</a>'),
|
||||
'Fix <a class="tooltip issue-tracker-link" href="https://r.io/i/42" title="Test Pattern">#42</a>'),
|
||||
('Fix #42', '(?:#)?<issue_id>\d+)',
|
||||
'Fix #42'), # Broken regex
|
||||
])
|
||||
|
|
@ -177,7 +177,7 @@ def test_process_patterns_no_repo(text_string, pattern, expected_text):
|
|||
'123': {
|
||||
'uid': '123',
|
||||
'pat': pattern,
|
||||
'url': 'http://r.io/i/${issue_id}',
|
||||
'url': 'https://r.io/i/${issue_id}',
|
||||
'pref': '#',
|
||||
'desc': 'Test Pattern'
|
||||
}
|
||||
|
|
@ -193,16 +193,16 @@ def test_process_patterns_no_repo(text_string, pattern, expected_text):
|
|||
|
||||
def test_process_patterns_non_existent_repo_name(backend):
|
||||
text_string = 'Fix #42'
|
||||
pattern = '(?:#)(?P<issue_id>\d+)'
|
||||
pattern = r'(?:#)(?P<issue_id>\d+)'
|
||||
expected_text = ('Fix <a class="tooltip issue-tracker-link" '
|
||||
'href="http://r.io/do-not-exist/i/42" title="Test Pattern">#42</a>')
|
||||
'href="https://r.io/do-not-exist/i/42" title="Test Pattern">#42</a>')
|
||||
|
||||
def get_settings_mock(self, cache=True):
|
||||
return {
|
||||
'123': {
|
||||
'uid': '123',
|
||||
'pat': pattern,
|
||||
'url': 'http://r.io/${repo}/i/${issue_id}',
|
||||
'url': 'https://r.io/${repo}/i/${issue_id}',
|
||||
'pref': '#',
|
||||
'desc': 'Test Pattern'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue