Skip to content
Snippets Groups Projects
Commit a8525eb9 authored by Andy Boughton's avatar Andy Boughton
Browse files

Minimize number of tests that fail on core branch.

parent 715ba9b1
Branches
Tags
No related merge requests found
#! /usr/bin/env python
"""
Unit and functional tests for markdown lesson template validator.
Some of these tests require looking for example files, which exist only on
the gh-pages branch. Some tests may therefore fail on branch "core".
"""
import imp
import logging
import os
......@@ -91,13 +99,33 @@ keywords: this is not a list
# TESTS INVOLVING SECTION TITLES/HEADINGS
def test_index_has_valid_section_headings(self):
"""The provided index page"""
sample_validator = self.VALIDATOR(self.SAMPLE_FILE)
res = sample_validator._validate_section_heading_order()
validator = self._create_validator("""## Topics
1. [Topic Title One](01-one.html)
2. [Topic Title Two](02-two.html)
## Other Resources
* [Motivation](motivation.html)
* [Reference Guide](reference.html)
* [Next Steps](discussion.html)
* [Instructor's Guide](instructors.html)""")
res = validator._validate_section_heading_order()
self.assertTrue(res)
def test_index_fail_when_section_heading_absent(self):
sample_validator = self.VALIDATOR(self.SAMPLE_FILE)
res = sample_validator.ast.has_section_heading("Fake heading")
validator = self._create_validator("""## Topics
1. [Topic Title One](01-one.html)
2. [Topic Title Two](02-two.html)
## Other Resources
* [Motivation](motivation.html)
* [Reference Guide](reference.html)
* [Next Steps](discussion.html)
* [Instructor's Guide](instructors.html)""")
res = validator.ast.has_section_heading("Fake heading")
self.assertFalse(res)
def test_fail_when_section_heading_is_wrong_level(self):
......@@ -185,12 +213,15 @@ Paragraph of introductory material.
# TESTS INVOLVING LINKS TO OTHER CONTENT
def test_file_links_validate(self):
"""Verify that all links in a sample file validate.
Involves checking for example files; may fail on "core" branch"""
sample_validator = self.VALIDATOR(self.SAMPLE_FILE)
res = sample_validator._validate_links()
self.assertTrue(res)
def test_html_link_to_extant_md_file_passes(self):
"""Verify that an HTML link with corresponding MD file will pass"""
"""Verify that an HTML link with corresponding MD file will pass
Involves checking for example files; may fail on "core" branch"""
validator = self._create_validator("""[Topic Title One](01-one.html)""")
self.assertTrue(validator._validate_links())
......@@ -199,6 +230,8 @@ Paragraph of introductory material.
For now this just tests that the regex handles #anchors.
It doesn't validate that the named anchor exists in the md file
Involves checking for example files; may fail on "core" branch
"""
validator = self._create_validator("""[Topic Title One](01-one.html#anchor)""")
self.assertTrue(validator._validate_links())
......@@ -230,7 +263,8 @@ SQLite uses the integers 0 and 1 for the former, and represents the latter as di
self.assertFalse(validator._validate_links())
def test_finds_image_asset(self):
"""Image asset is found"""
"""Image asset is found in the expected file location
Involves checking for example files; may fail on "core" branch"""
validator = self._create_validator(
"""![this is the image's title](fig/example.svg "this is the image's alt text")""")
self.assertTrue(validator._validate_links())
......@@ -242,7 +276,9 @@ SQLite uses the integers 0 and 1 for the former, and represents the latter as di
self.assertFalse(validator._validate_links())
def test_non_html_link_finds_csv(self):
"""Look for CSV file in appropriate folder"""
"""Look for CSV file in appropriate folder
Involves checking for example files; may fail on "core" branch
"""
validator = self._create_validator(
"""Use [this CSV](data/data.csv) for the exercise.""")
self.assertTrue(validator._validate_links())
......
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