Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
a8525eb9
Commit
a8525eb9
authored
10 years ago
by
Andy Boughton
Browse files
Options
Downloads
Patches
Plain Diff
Minimize number of tests that fail on core branch.
parent
715ba9b1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/test_check.py
+43
-7
43 additions, 7 deletions
tools/test_check.py
with
43 additions
and
7 deletions
tools/test_check.py
+
43
−
7
View file @
a8525eb9
#! /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
(
"""

"""
)
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
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment