mirror of https://github.com/zulip/zulip.git
refactor: Rename remaining bugdown words to markdown in test_markdown.py.
Rename rest of function names, classes and comments containing bugdoown to markdown in test_markdown.py. Also change the refactored classes and functions occurences in other files. This commit is part of series of commits aimed at renaming bugdown to markdown.
This commit is contained in:
parent
df701ba779
commit
4224ac1b61
|
@ -79,7 +79,7 @@ testcases in `markdown_test_cases.json` that you want to ignore. This
|
|||
is a workaround due to lack of comments support in JSON. Revert your
|
||||
"ignore" changes before committing. After this, you can run the frontend
|
||||
tests with `tools/test-js-with-node markdown` and backend tests with
|
||||
`tools/test-backend zerver.tests.test_markdown.BugdownTest.test_bugdown_fixtures`.
|
||||
`tools/test-backend zerver.tests.test_markdown.MarkdownTest.test_markdown_fixtures`.
|
||||
|
||||
## Changing Zulip's markdown processor
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ typically involve running subsets of the tests with commands like these:
|
|||
|
||||
```
|
||||
./tools/lint zerver/lib/actions.py # Lint the file you just changed
|
||||
./tools/test-backend zerver.tests.test_markdown.BugdownTest.test_inline_youtube
|
||||
./tools/test-backend BugdownTest # Run `test-backend --help` for more options
|
||||
./tools/test-backend zerver.tests.test_markdown.MarkdownTest.test_inline_youtube
|
||||
./tools/test-backend MarkdownTest # Run `test-backend --help` for more options
|
||||
./tools/test-js-with-casper 09-navigation.js
|
||||
./tools/test-js-with-node utils.js
|
||||
```
|
||||
|
|
|
@ -70,7 +70,7 @@ not_yet_fully_covered = {path for target in [
|
|||
'zerver/lib/send_email.py',
|
||||
'zerver/lib/url_preview/preview.py',
|
||||
'zerver/worker/queue_processors.py',
|
||||
# Bugdown sub-libs should have full coverage too; a lot are really close
|
||||
# Markdown sub-libs should have full coverage too; a lot are really close
|
||||
'zerver/lib/markdown/api_arguments_table_generator.py',
|
||||
'zerver/lib/markdown/fenced_code.py',
|
||||
'zerver/lib/markdown/help_relative_links.py',
|
||||
|
@ -199,10 +199,10 @@ def main() -> None:
|
|||
test-backend zerver.tests.test_markdown # run all tests in a test module
|
||||
test-backend zerver/tests/test_markdown.py # run all tests in a test module
|
||||
test-backend test_markdown # run all tests in a test module
|
||||
test-backend zerver.tests.test_markdown.BugdownTest # run all tests in a test class
|
||||
test-backend BugdownTest # run all tests in a test class
|
||||
test-backend zerver.tests.test_markdown.BugdownTest.test_inline_youtube # run a single test
|
||||
test-backend BugdownTest.test_inline_youtube # run a single test"""
|
||||
test-backend zerver.tests.test_markdown.MarkdownTest # run all tests in a test class
|
||||
test-backend MarkdownTest # run all tests in a test class
|
||||
test-backend zerver.tests.test_markdown.MarkdownTest.test_inline_youtube # run a single test
|
||||
test-backend MarkdownTest.test_inline_youtube # run a single test"""
|
||||
|
||||
parser = argparse.ArgumentParser(description=usage,
|
||||
formatter_class=argparse.RawTextHelpFormatter)
|
||||
|
|
|
@ -192,7 +192,7 @@ def markdown_convert(content: str) -> str:
|
|||
message_realm=get_realm('zulip'),
|
||||
)
|
||||
|
||||
class BugdownMiscTest(ZulipTestCase):
|
||||
class MarkdownMiscTest(ZulipTestCase):
|
||||
def test_diffs_work_as_expected(self) -> None:
|
||||
str1 = "<p>The quick brown fox jumps over the lazy dog. Animal stories are fun, yeah</p>"
|
||||
str2 = "<p>The fast fox jumps over the lazy dogs and cats. Animal stories are fun</p>"
|
||||
|
@ -357,7 +357,7 @@ Outside. Should convert:<>
|
|||
original, expected = self.split_message(msg)
|
||||
self.assertEqual(preprocessor.run(original), expected)
|
||||
|
||||
class BugdownTest(ZulipTestCase):
|
||||
class MarkdownTest(ZulipTestCase):
|
||||
def setUp(self) -> None:
|
||||
super().setUp()
|
||||
clear_state_for_testing()
|
||||
|
@ -370,7 +370,7 @@ class BugdownTest(ZulipTestCase):
|
|||
else:
|
||||
super().assertEqual(first, second)
|
||||
|
||||
def load_bugdown_tests(self) -> Tuple[Dict[str, Any], List[List[str]]]:
|
||||
def load_markdown_tests(self) -> Tuple[Dict[str, Any], List[List[str]]]:
|
||||
test_fixtures = {}
|
||||
with open(os.path.join(os.path.dirname(__file__), 'fixtures/markdown_test_cases.json')) as f:
|
||||
data = ujson.load(f)
|
||||
|
@ -379,17 +379,17 @@ class BugdownTest(ZulipTestCase):
|
|||
|
||||
return test_fixtures, data['linkify_tests']
|
||||
|
||||
def test_bugdown_no_ignores(self) -> None:
|
||||
def test_markdown_no_ignores(self) -> None:
|
||||
# We do not want any ignored tests to be committed and merged.
|
||||
format_tests, linkify_tests = self.load_bugdown_tests()
|
||||
format_tests, linkify_tests = self.load_markdown_tests()
|
||||
for name, test in format_tests.items():
|
||||
message = f'Test "{name}" shouldn\'t be ignored.'
|
||||
is_ignored = test.get('ignore', False)
|
||||
self.assertFalse(is_ignored, message)
|
||||
|
||||
@slow("Aggregate of runs dozens of individual markdown tests")
|
||||
def test_bugdown_fixtures(self) -> None:
|
||||
format_tests, linkify_tests = self.load_bugdown_tests()
|
||||
def test_markdown_fixtures(self) -> None:
|
||||
format_tests, linkify_tests = self.load_markdown_tests()
|
||||
valid_keys = {"name", "input", "expected_output",
|
||||
"backend_only_rendering",
|
||||
"marked_expected_output", "text_content",
|
||||
|
@ -423,7 +423,7 @@ class BugdownTest(ZulipTestCase):
|
|||
href = 'http://' + url
|
||||
return payload % (f"<a href=\"{href}\">{url}</a>",)
|
||||
|
||||
print("Running Bugdown Linkify tests")
|
||||
print("Running Markdown Linkify tests")
|
||||
with mock.patch('zerver.lib.url_preview.preview.link_embed_data_from_cache', return_value=None):
|
||||
for inline_url, reference, url in linkify_tests:
|
||||
try:
|
||||
|
@ -887,7 +887,7 @@ class BugdownTest(ZulipTestCase):
|
|||
|
||||
realm = get_realm('zulip')
|
||||
|
||||
# Needs to mock an actual message because that's how bugdown obtains the realm
|
||||
# Needs to mock an actual message because that's how markdown obtains the realm
|
||||
msg = Message(sender=self.example_user('hamlet'))
|
||||
converted = convert(":green_tick:", message_realm=realm, message=msg)
|
||||
realm_emoji = RealmEmoji.objects.filter(realm=realm,
|
||||
|
@ -1011,7 +1011,7 @@ class BugdownTest(ZulipTestCase):
|
|||
assert_conversion('Hello #123World', False)
|
||||
assert_conversion('Hello#123 World', False)
|
||||
assert_conversion('Hello#123World', False)
|
||||
# Ideally, these should be converted, but bugdown doesn't
|
||||
# Ideally, these should be converted, but markdown doesn't
|
||||
# handle word boundary detection in languages that don't use
|
||||
# whitespace for that correctly yet.
|
||||
assert_conversion('チケットは#123です', False)
|
||||
|
@ -2079,7 +2079,7 @@ class BugdownTest(ZulipTestCase):
|
|||
converted = markdown_convert(dedent(msg))
|
||||
self.assertEqual(converted, dedent(expected_output))
|
||||
|
||||
class BugdownApiTests(ZulipTestCase):
|
||||
class MarkdownApiTests(ZulipTestCase):
|
||||
def test_render_message_api(self) -> None:
|
||||
content = 'That is a **bold** statement'
|
||||
result = self.api_post(
|
||||
|
@ -2105,8 +2105,8 @@ class BugdownApiTests(ZulipTestCase):
|
|||
self.assertEqual(result.json()['rendered'],
|
||||
f'<p>This mentions <a class="stream" data-stream-id="{stream_id}" href="/#narrow/stream/{stream_id}-Denmark">#Denmark</a> and <span class="user-mention" data-user-id="{user_id}">@King Hamlet</span>.</p>')
|
||||
|
||||
class BugdownErrorTests(ZulipTestCase):
|
||||
def test_bugdown_error_handling(self) -> None:
|
||||
class MarkdownErrorTests(ZulipTestCase):
|
||||
def test_markdown_error_handling(self) -> None:
|
||||
with self.simulated_markdown_failure():
|
||||
with self.assertRaises(MarkdownRenderingException):
|
||||
markdown_convert('')
|
||||
|
@ -2175,7 +2175,7 @@ class BugdownErrorTests(ZulipTestCase):
|
|||
result = processor.run(markdown_input)
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
class BugdownAvatarTestCase(ZulipTestCase):
|
||||
class MarkdownAvatarTestCase(ZulipTestCase):
|
||||
def test_possible_avatar_emails(self) -> None:
|
||||
content = '''
|
||||
hello !avatar(foo@example.com) my email is ignore@ignore.com
|
||||
|
|
Loading…
Reference in New Issue