From 5c906ad12f1e719208da03d4c40201aee453a22b Mon Sep 17 00:00:00 2001 From: Andy Boughton <abought@gmail.com> Date: Sun, 4 Jan 2015 00:31:25 -0500 Subject: [PATCH] Clean up YAML header unit tests: update to reflect the newest templates --- tools/test_check.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/test_check.py b/tools/test_check.py index 158a0b7..0451c84 100644 --- a/tools/test_check.py +++ b/tools/test_check.py @@ -60,7 +60,6 @@ class TestIndexPage(BaseTemplateTest): layout: lesson title: Lesson Title -keywords: ["some", "key terms", "in a list"] Another section that isn't an HR """) @@ -71,7 +70,6 @@ Another section that isn't an HR """One of the required headers is missing""" validator = self._create_validator("""--- layout: lesson -keywords: ["some", "key terms", "in a list"] ---""") self.assertFalse(validator._validate_doc_headers()) @@ -80,16 +78,14 @@ keywords: ["some", "key terms", "in a list"] validator = self._create_validator("""--- layout: lesson title: Lesson Title -keywords: ["some", "key terms", "in a list"] otherline: Nothing ---""") self.assertFalse(validator._validate_doc_headers()) - def test_headers_fail_because_invalid_content(self): + def test_fail_when_headers_not_yaml_dict(self): + """Fail when the headers can't be parsed to a dict of YAML data""" validator = self._create_validator("""--- -layout: lesson -title: Lesson Title -keywords: this is not a list +This will parse as a string, not a dictionary ---""") self.assertFalse(validator._validate_doc_headers()) @@ -155,7 +151,6 @@ Paragraph of introductory material. validator = self._create_validator("""--- layout: lesson title: Lesson Title -keywords: ["some", "key terms", "in a list"] --- Paragraph of introductory material. @@ -182,7 +177,6 @@ Paragraph of introductory material. validator = self._create_validator("""--- layout: lesson title: Lesson Title -keywords: ["some", "key terms", "in a list"] --- Paragraph of introductory material. @@ -197,7 +191,6 @@ Paragraph of introductory material. validator = self._create_validator("""--- layout: lesson title: Lesson Title -keywords: ["some", "key terms", "in a list"] --- Paragraph of introductory material. @@ -292,6 +285,16 @@ class TestTopicPage(BaseTemplateTest): SAMPLE_FILE = os.path.join(MARKDOWN_DIR, "01-one.md") VALIDATOR = check.TopicPageValidator + def test_headers_fail_because_invalid_content(self): + """The value provided as YAML does not match the expected datatype""" + validator = self._create_validator("""--- +layout: lesson +title: Lesson Title +subtitle: A page +minutes: not a number +---""") + self.assertFalse(validator._validate_doc_headers()) + def test_sample_file_passes_validation(self): sample_validator = self.VALIDATOR(self.SAMPLE_FILE) res = sample_validator.validate() -- GitLab