Commit 5c906ad1 authored by Andy Boughton's avatar Andy Boughton
Browse files

Clean up YAML header unit tests: update to reflect the newest templates

parent 35092276
Loading
Loading
Loading
Loading
+13 −10
Original line number Diff line number Diff line
@@ -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()