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
5c906ad1
Commit
5c906ad1
authored
10 years ago
by
Andy Boughton
Browse files
Options
Downloads
Patches
Plain Diff
Clean up YAML header unit tests: update to reflect the newest templates
parent
35092276
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
+13
-10
13 additions, 10 deletions
tools/test_check.py
with
13 additions
and
10 deletions
tools/test_check.py
+
13
−
10
View file @
5c906ad1
...
...
@@ -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
()
...
...
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