diff --git a/tools/test_check.py b/tools/test_check.py index 158a0b762b001cb92cde4ef6dc9bcbf4ea368ba3..0451c8444d914aca6ab9fe2635575f49814dfd34 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()