-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed null test and completed added opt_in and opt_out
- changed name from opt-in and opt-out
- Loading branch information
Laurent Franceschetti
committed
Sep 29, 2024
1 parent
b76efef
commit 9186fe6
Showing
19 changed files
with
160 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
This __init__.py file is indispensable for pytest to | ||
recognize its packages. | ||
""" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
test/opt-in/docs/render_this_one.md → test/opt_in/docs/render_this_one.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/opt-in/docs/rendered/exception.md → test/opt_in/docs/rendered/exception.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
render_macros: false # opt-in | ||
render_macros: false # opt-out | ||
--- | ||
# Opt-out by page header (priority) | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
Testing the project | ||
(C) Laurent Franceschetti 2024 | ||
""" | ||
import pytest | ||
|
||
from test.fixture import DocProject | ||
|
||
CURRENT_PROJECT = 'opt_in' | ||
|
||
|
||
|
||
|
||
def test_opt_in(): | ||
PROJECT = DocProject(CURRENT_PROJECT) | ||
PROJECT.build() | ||
# did not fail | ||
assert not PROJECT.build_result.returncode | ||
|
||
|
||
|
||
# --------------------------- | ||
# which pages are rendered? | ||
# --------------------------- | ||
# test the config: | ||
macros = PROJECT.macros_plugin | ||
assert macros.render_by_default == False | ||
|
||
page = PROJECT.get_page('render_this_one') | ||
assert page.is_rendered | ||
assert page.find(page.metadata.signal), f"Did not find signal '{page.metadata.signal}'" | ||
|
||
print([page.filename for page in PROJECT.pages]) | ||
page2 = PROJECT.get_page('rendered/noname') | ||
assert page2.filename == 'rendered/noname.md', f"is: {page2.filename}" | ||
assert page2.find("0: Hello world") | ||
assert page2.is_rendered | ||
|
||
|
||
assert not PROJECT.get_page('not_rendered/noname').is_rendered | ||
|
||
# exception in the metadata: | ||
exception_page = PROJECT.get_page('rendered/exception') | ||
assert exception_page.metadata.render_macros == False | ||
assert not exception_page.is_rendered | ||
assert exception_page.find('macros_info') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
This __init__.py file is indispensable for pytest to | ||
recognize its packages. | ||
""" |
File renamed without changes.
4 changes: 3 additions & 1 deletion
4
test/opt-out/docs/page_with_macros.md → test/opt_out/docs/rendered.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
--- | ||
render_macros: true # opt-in | ||
title: Rendered title | ||
signal: Hello World | ||
--- | ||
# {{ title }} | ||
|
||
{{ title }} | ||
|
||
{{ macros_info() }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Testing the project | ||
(C) Laurent Franceschetti 2024 | ||
""" | ||
import pytest | ||
|
||
from test.fixture import DocProject | ||
|
||
CURRENT_PROJECT = 'opt_out' | ||
|
||
|
||
|
||
|
||
def test_opt_in(): | ||
PROJECT = DocProject(CURRENT_PROJECT) | ||
PROJECT.build() | ||
# did not fail | ||
assert not PROJECT.build_result.returncode | ||
|
||
|
||
|
||
# --------------------------- | ||
# which pages are rendered? | ||
# --------------------------- | ||
# test the config (this is the default anyway) | ||
macros = PROJECT.macros_plugin | ||
assert macros.render_by_default == True | ||
|
||
# opt-out: | ||
page = PROJECT.get_page('index') | ||
assert page.metadata.render_macros == False | ||
assert not page.is_rendered | ||
assert "macros_info" in page.markdown | ||
|
||
|
||
# Normal: | ||
page = PROJECT.get_page('rendered') | ||
assert "render_macros" not in page.metadata | ||
assert page.is_rendered | ||
assert page.metadata.signal in page.markdown | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters