Skip to content
Snippets Groups Projects
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
Branches
Tags
No related merge requests found
...@@ -60,7 +60,6 @@ class TestIndexPage(BaseTemplateTest): ...@@ -60,7 +60,6 @@ class TestIndexPage(BaseTemplateTest):
layout: lesson layout: lesson
title: Lesson Title title: Lesson Title
keywords: ["some", "key terms", "in a list"]
Another section that isn't an HR Another section that isn't an HR
""") """)
...@@ -71,7 +70,6 @@ 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""" """One of the required headers is missing"""
validator = self._create_validator("""--- validator = self._create_validator("""---
layout: lesson layout: lesson
keywords: ["some", "key terms", "in a list"]
---""") ---""")
self.assertFalse(validator._validate_doc_headers()) self.assertFalse(validator._validate_doc_headers())
...@@ -80,16 +78,14 @@ keywords: ["some", "key terms", "in a list"] ...@@ -80,16 +78,14 @@ keywords: ["some", "key terms", "in a list"]
validator = self._create_validator("""--- validator = self._create_validator("""---
layout: lesson layout: lesson
title: Lesson Title title: Lesson Title
keywords: ["some", "key terms", "in a list"]
otherline: Nothing otherline: Nothing
---""") ---""")
self.assertFalse(validator._validate_doc_headers()) 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("""--- validator = self._create_validator("""---
layout: lesson This will parse as a string, not a dictionary
title: Lesson Title
keywords: this is not a list
---""") ---""")
self.assertFalse(validator._validate_doc_headers()) self.assertFalse(validator._validate_doc_headers())
...@@ -155,7 +151,6 @@ Paragraph of introductory material. ...@@ -155,7 +151,6 @@ Paragraph of introductory material.
validator = self._create_validator("""--- validator = self._create_validator("""---
layout: lesson layout: lesson
title: Lesson Title title: Lesson Title
keywords: ["some", "key terms", "in a list"]
--- ---
Paragraph of introductory material. Paragraph of introductory material.
...@@ -182,7 +177,6 @@ Paragraph of introductory material. ...@@ -182,7 +177,6 @@ Paragraph of introductory material.
validator = self._create_validator("""--- validator = self._create_validator("""---
layout: lesson layout: lesson
title: Lesson Title title: Lesson Title
keywords: ["some", "key terms", "in a list"]
--- ---
Paragraph of introductory material. Paragraph of introductory material.
...@@ -197,7 +191,6 @@ Paragraph of introductory material. ...@@ -197,7 +191,6 @@ Paragraph of introductory material.
validator = self._create_validator("""--- validator = self._create_validator("""---
layout: lesson layout: lesson
title: Lesson Title title: Lesson Title
keywords: ["some", "key terms", "in a list"]
--- ---
Paragraph of introductory material. Paragraph of introductory material.
...@@ -292,6 +285,16 @@ class TestTopicPage(BaseTemplateTest): ...@@ -292,6 +285,16 @@ class TestTopicPage(BaseTemplateTest):
SAMPLE_FILE = os.path.join(MARKDOWN_DIR, "01-one.md") SAMPLE_FILE = os.path.join(MARKDOWN_DIR, "01-one.md")
VALIDATOR = check.TopicPageValidator 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): def test_sample_file_passes_validation(self):
sample_validator = self.VALIDATOR(self.SAMPLE_FILE) sample_validator = self.VALIDATOR(self.SAMPLE_FILE)
res = sample_validator.validate() res = sample_validator.validate()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment