-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from JasperVanDenBosch/skip-gracefully
skipping pages if template or content is missing
- Loading branch information
Showing
14 changed files
with
203 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
workflow_call: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
|
||
tests: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Python Version | ||
run: python --version | ||
- name: Update Pip | ||
run: python -m pip install --upgrade pip | ||
- name: Install dependencies | ||
run: pip install -r requirements.txt | ||
- name: Install Syrinx | ||
run: pip install . | ||
- name: Install test dependencies | ||
run: pip install -r tests/requirements.txt | ||
- name: Unit tests | ||
run: pytest |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
jinja2 | ||
markdown | ||
pandas | ||
pytest | ||
lxml | ||
parameterized | ||
lxml |
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,7 @@ | ||
|
||
class ContentError(Exception): | ||
pass | ||
|
||
|
||
class ThemeError(Exception): | ||
pass |
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,21 @@ | ||
from unittest import TestCase | ||
from unittest.mock import Mock, patch | ||
|
||
class BuildNodeTests(TestCase): | ||
|
||
@patch('syrinx.build.isfile') | ||
@patch('syrinx.build.open') | ||
def test_follows_buildPage(self, open, isfile): | ||
from syrinx.build import build_node | ||
node = Mock() | ||
root = Mock() | ||
env = Mock() | ||
isfile.return_value = True | ||
node.name = 'foo' | ||
node.branches = [] | ||
node.buildPage = False | ||
build_node(node, root, '', '', env) | ||
self.assertFalse(env.get_template().render.called) | ||
node.buildPage = True | ||
build_node(node, root, '', '', env) | ||
self.assertTrue(env.get_template().render.called) |
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,44 @@ | ||
from unittest import TestCase | ||
from unittest.mock import patch | ||
|
||
|
||
class ReadTests(TestCase): | ||
|
||
@patch('syrinx.read.walk') | ||
@patch('syrinx.read.read_file') | ||
def test_read_BuildPage_branch_with_index(self, read_file, walk): | ||
"""If index.md present on branch then set "BuildPage" to true | ||
""" | ||
read_file.return_value = dict(), '' | ||
walk.return_value = [ | ||
('/pth/content', None, ['index.md']), | ||
('/pth/content/lorem', None, ['ipsum.md', 'index.md']), | ||
] | ||
from syrinx.read import read | ||
root = read('/pth') | ||
self.assertTrue(root.branches[0].buildPage) | ||
|
||
@patch('syrinx.read.walk') | ||
@patch('syrinx.read.read_file') | ||
def test_read_BuildPage_branch_without_index(self, read_file, walk): | ||
"""If index.md absent on branch then set "BuildPage" to false | ||
""" | ||
read_file.return_value = dict(), '' | ||
walk.return_value = [ | ||
('/pth/content', None, ['index.md']), | ||
('/pth/content/foo', None, ['bar.md']), | ||
] | ||
from syrinx.read import read | ||
root = read('/pth') | ||
self.assertFalse(root.branches[0].buildPage) | ||
|
||
@patch('syrinx.read.walk') | ||
def test_read_Fail_if_index_missing(self, walk): | ||
"""The root index.md is not optional, | ||
raise an exception if it's missing. | ||
""" | ||
walk.return_value = [('/pth/content', None, ['other.md'])] | ||
from syrinx.read import read | ||
from syrinx.exceptions import ContentError | ||
with self.assertRaisesRegex(ContentError, 'root index file missing'): | ||
read('/pth') |
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,2 @@ | ||
pytest | ||
parameterized |