Skip to content

Commit

Permalink
MarkdownBear: Add test to check message for error
Browse files Browse the repository at this point in the history
A better test for MarkdownBear to check the exact message
of the result for a maximum line length error.

Closes #1235
  • Loading branch information
namanyadav12 committed Jan 10, 2017
1 parent 9d9c018 commit f1a0a25
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -16,7 +16,7 @@
"jshint": "~2",
"postcss-cli": "~2",
"remark-cli": "~2",
"remark-lint": ">=5.1.0",
"remark-lint": "~5.1.0",
"tslint": "~3",
"typescript": ">=1.7.3",
"ramllint": "~1.2.2",
Expand Down
28 changes: 27 additions & 1 deletion tests/markdown/MarkdownBearTest.py
@@ -1,5 +1,13 @@
import unittest
from queue import Queue

from bears.markdown.MarkdownBear import MarkdownBear
from coalib.testing.LocalBearTestHelper import verify_local_bear
from coalib.testing.BearTestHelper import generate_skip_decorator
from coalib.testing.LocalBearTestHelper import verify_local_bear, execute_bear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting
from coala_utils.ContextManagers import prepare_file

test_file1 = """1. abc
1. def
Expand Down Expand Up @@ -29,3 +37,21 @@
valid_files=(test_file2,),
invalid_files=(test_file3,),
settings={'max_line_length': 10})


@generate_skip_decorator(MarkdownBear)
class MarkdownBearMaxLineLengthMessageTest(unittest.TestCase):

def setUp(self):
self.section = Section('name')
self.uut = MarkdownBear(self.section, Queue())

def test_invalid_message(self):
content = test_file3.splitlines()
self.section.append(Setting('max_line_length', '10'))
with prepare_file(content, None) as (file, fname):
with execute_bear(self.uut, fname, file) as results:
self.assertEqual(results[0].message,
'Line must be at most 10 characters'
' maximum-line-length remark-lint')
self.assertEqual(results[0].severity, RESULT_SEVERITY.NORMAL)

0 comments on commit f1a0a25

Please sign in to comment.