Nuked a todo and corrected a bunch of tests
This commit is contained in:
parent
2eea57e9fa
commit
62f3adb289
|
|
@ -1,19 +1,25 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
# Main program, use this to start parsing
|
# Main program, use this to start parsing
|
||||||
import rich
|
|
||||||
|
|
||||||
from bootstraparse.modules import sitecreator
|
from bootstraparse.modules import sitecreator
|
||||||
import argparse
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
parser = argparse.ArgumentParser(prog="bootstraparse", description='Parses a folder for all .bpr files and '
|
def parse(_args):
|
||||||
'magically recreates the same architecture '
|
parser = argparse.ArgumentParser(
|
||||||
'with html translated files.')
|
prog="bootstraparse",
|
||||||
|
description='Parses a folder for all .bpr files and magically recreates the same architecture '
|
||||||
|
'with html translated files.'
|
||||||
|
)
|
||||||
parser.add_argument('origin', help='the root folder of all files to parse.')
|
parser.add_argument('origin', help='the root folder of all files to parse.')
|
||||||
parser.add_argument('destination', help="path of the folder where to output all the magic.")
|
parser.add_argument('destination', help="path of the folder where to output all the magic.")
|
||||||
# parser.add_argument("-v", "verbosity")
|
# parser.add_argument("-v", "verbosity")
|
||||||
args = parser.parse_args()
|
return parser.parse_args(_args)
|
||||||
if sitecreator.create_website(args.origin, args.destination) == 0:
|
|
||||||
rich.print("Bootstraparse run successful!")
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__": # pragma: no cover
|
||||||
|
args = parse(sys.argv[1:])
|
||||||
|
if sitecreator.create_website(args.origin, args.destination) == 0:
|
||||||
|
print("Bootstraparse run successful!")
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ class ConfigLoader:
|
||||||
# def __init__(self, config_folder):
|
# def __init__(self, config_folder):
|
||||||
# super().__init__(config_folder)
|
# super().__init__(config_folder)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__': # pragma: no cover
|
||||||
conf = ConfigLoader("../configs/")
|
conf = ConfigLoader("../configs/")
|
||||||
conf.add_folder("../../../example_userfiles/config/")
|
conf.add_folder("../../../example_userfiles/config/")
|
||||||
rich.inspect(conf)
|
rich.inspect(conf)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@
|
||||||
# container = BaseContainer()
|
# container = BaseContainer()
|
||||||
# container[number] -> The number element in the content
|
# container[number] -> The number element in the content
|
||||||
# "class_insert" >> container[number] -> Get an element from one of the mapped methods
|
# "class_insert" >> container[number] -> Get an element from one of the mapped methods
|
||||||
import rich
|
|
||||||
|
|
||||||
from bootstraparse.modules import syntax, error_mngr, export
|
from bootstraparse.modules import syntax, error_mngr, export
|
||||||
from bootstraparse.modules.error_mngr import MismatchedContainerError, log_exception, log_message, LonelyOptionalError # noqa
|
from bootstraparse.modules.error_mngr import MismatchedContainerError, log_exception, log_message, LonelyOptionalError # noqa
|
||||||
|
|
@ -200,8 +199,10 @@ class EtCustomSpanContainer(BaseContainer):
|
||||||
|
|
||||||
|
|
||||||
class ReContextContainer(BaseContainer):
|
class ReContextContainer(BaseContainer):
|
||||||
|
children = ""
|
||||||
|
|
||||||
def get_content(self, exm, arbitrary_list=None):
|
def get_content(self, exm, arbitrary_list=None):
|
||||||
child_start, child_end = exm(export.ExportRequest(self.type, self.children))
|
child_start, child_end = exm(export.ExportRequest(self.type, self.children)) # noqa: F841
|
||||||
output = "\n"
|
output = "\n"
|
||||||
for element in self.content:
|
for element in self.content:
|
||||||
if isinstance(element, syntax.Linebreak):
|
if isinstance(element, syntax.Linebreak):
|
||||||
|
|
@ -357,6 +358,7 @@ class ContextManager:
|
||||||
"table:row": ["table:separator", "table:row"], # TODO: Implement tables
|
"table:row": ["table:separator", "table:row"], # TODO: Implement tables
|
||||||
"blockquotes": [] # TODO: Implement blockquotes
|
"blockquotes": [] # TODO: Implement blockquotes
|
||||||
}
|
}
|
||||||
|
self.contextualised = False
|
||||||
|
|
||||||
def encapsulate(self, start, end):
|
def encapsulate(self, start, end):
|
||||||
"""
|
"""
|
||||||
|
|
@ -433,6 +435,8 @@ class ContextManager:
|
||||||
Returns the pile entirely processed as a list of containers.
|
Returns the pile entirely processed as a list of containers.
|
||||||
"""
|
"""
|
||||||
# self.pile = self.parsed_list.copy()
|
# self.pile = self.parsed_list.copy()
|
||||||
|
if self.contextualised:
|
||||||
|
return self.pile
|
||||||
index = 0
|
index = 0
|
||||||
line_number = 1
|
line_number = 1
|
||||||
while index < len(self.parsed_list):
|
while index < len(self.parsed_list):
|
||||||
|
|
@ -477,6 +481,7 @@ class ContextManager:
|
||||||
error_mngr.log_exception(e, level="CRITICAL") # FUTURE: Be more specific.
|
error_mngr.log_exception(e, level="CRITICAL") # FUTURE: Be more specific.
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
self.contextualised = True
|
||||||
return self.finalize_pile()
|
return self.finalize_pile()
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,8 @@ class ExportManager:
|
||||||
Transforms ExportRequest tuples to ExportResponse tuples with the config-provided appropriate markup.
|
Transforms ExportRequest tuples to ExportResponse tuples with the config-provided appropriate markup.
|
||||||
"""
|
"""
|
||||||
def __init__(self, cnoifg, templates): # noqa
|
def __init__(self, cnoifg, templates): # noqa
|
||||||
# self.config = cnoifg TODO: actually import config
|
self.config = cnoifg
|
||||||
# self.templates = templates # noqa TODO: actually import templates
|
self.templates = templates
|
||||||
self.config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
|
||||||
self.templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
|
||||||
self.advanced_export = {
|
self.advanced_export = {
|
||||||
"header": self.header_transform,
|
"header": self.header_transform,
|
||||||
"display": self.display_transform,
|
"display": self.display_transform,
|
||||||
|
|
@ -247,7 +245,9 @@ if __name__ == '__main__': # pragma: no cover
|
||||||
"""[this is a link]('http://te.st')"""
|
"""[this is a link]('http://te.st')"""
|
||||||
)
|
)
|
||||||
test = parser.parse_line(io_string)
|
test = parser.parse_line(io_string)
|
||||||
exm = ExportManager(None, None)
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
|
exm = ExportManager(None, None, __config, __templates)
|
||||||
cxm = context_mngr.ContextManager(test)
|
cxm = context_mngr.ContextManager(test)
|
||||||
cxc = ContextConverter(cxm(), exm)
|
cxc = ContextConverter(cxm(), exm)
|
||||||
rich.inspect(cxc)
|
rich.inspect(cxc)
|
||||||
|
|
|
||||||
|
|
@ -366,11 +366,13 @@ class PreParser:
|
||||||
if __name__ == "__main__": # pragma: no cover
|
if __name__ == "__main__": # pragma: no cover
|
||||||
from bootstraparse.modules import config
|
from bootstraparse.modules import config
|
||||||
from bootstraparse.modules import pathresolver
|
from bootstraparse.modules import pathresolver
|
||||||
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
site_path = pathresolver.b_path("../../example_userfiles/test.bpr")
|
site_path = pathresolver.b_path("../../example_userfiles/test.bpr")
|
||||||
config_path = pathresolver.b_path("../../example_userfiles/config/")
|
config_path = pathresolver.b_path("../../example_userfiles/config/")
|
||||||
_env = environment.Environment()
|
_env = environment.Environment()
|
||||||
_env.config = config.ConfigLoader(config_path)
|
_env.config = config.ConfigLoader(config_path)
|
||||||
_env.export_mngr = export.ExportManager('', '')
|
_env.export_mngr = export.ExportManager(__config, __templates)
|
||||||
t_pp = PreParser(site_path, _env)
|
t_pp = PreParser(site_path, _env)
|
||||||
out = t_pp.do_replacements()
|
out = t_pp.do_replacements()
|
||||||
rich.print(t_pp.get_all_lines())
|
rich.print(t_pp.get_all_lines())
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
# Module for file and directories repartition
|
# Module for file and directories repartition
|
||||||
import os
|
import os
|
||||||
import rich
|
|
||||||
from bootstraparse.modules import pathresolver, preparser, error_mngr, environment, export
|
from bootstraparse.modules import pathresolver, preparser, error_mngr, environment, export
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -79,12 +78,13 @@ class SiteCrawler:
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from bootstraparse.modules import config
|
from bootstraparse.modules import config
|
||||||
from bootstraparse.modules import pathresolver
|
|
||||||
site_path = pathresolver.b_path("../../example_userfiles/test.bpr")
|
site_path = pathresolver.b_path("../../example_userfiles/test.bpr")
|
||||||
config_path = pathresolver.b_path("../../example_userfiles/configs/")
|
config_path = pathresolver.b_path("../../example_userfiles/configs/")
|
||||||
_env = environment.Environment()
|
_env = environment.Environment()
|
||||||
_env.config = config.ConfigLoader(config_path)
|
_env.config = config.ConfigLoader(config_path)
|
||||||
_env.export_mngr = export.ExportManager('', '')
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
|
_env.export_mngr = export.ExportManager('', '', __config, __templates)
|
||||||
xpath = pathresolver.b_path("../../example_userfiles")
|
xpath = pathresolver.b_path("../../example_userfiles")
|
||||||
dpath = pathresolver.b_path("../../example_output")
|
dpath = pathresolver.b_path("../../example_output")
|
||||||
sc = SiteCrawler(xpath, dpath, _env)
|
sc = SiteCrawler(xpath, dpath, _env)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
# Module sequencing the successive actions necessary for website building
|
# Module sequencing the successive actions necessary for website building
|
||||||
import os
|
import os
|
||||||
import rich
|
|
||||||
from bootstraparse.modules import pathresolver, sitecrawler, environment, config, export, parser, context_mngr
|
from bootstraparse.modules import pathresolver, sitecrawler, environment, config, export, parser, context_mngr
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -62,4 +61,3 @@ if __name__ == "__main__":
|
||||||
xpath = pathresolver.b_path("../../example_userfiles")
|
xpath = pathresolver.b_path("../../example_userfiles")
|
||||||
dpath = pathresolver.b_path("../../example_output")
|
dpath = pathresolver.b_path("../../example_output")
|
||||||
create_website(xpath, dpath)
|
create_website(xpath, dpath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,19 +160,19 @@ _token_list_with_expected_result = [
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.EtUlistContainer([
|
context_mngr.EtUlistContainer([
|
||||||
sy.EtUlistToken([sy.TextToken(["a"])]),
|
sy.EtUlistToken([context_mngr.TextContainer([sy.TextToken(["a"])])]),
|
||||||
sy.Linebreak([]),
|
sy.Linebreak([]),
|
||||||
sy.EtUlistToken([sy.TextToken(["b"])]),
|
sy.EtUlistToken([context_mngr.TextContainer([sy.TextToken(["b"])])]),
|
||||||
sy.Linebreak([]),
|
sy.Linebreak([]),
|
||||||
sy.EtUlistToken([sy.TextToken(["c"])]),
|
sy.EtUlistToken([context_mngr.TextContainer([sy.TextToken(["c"])])]),
|
||||||
sy.EtUlistToken([sy.TextToken(["d"])]),
|
sy.EtUlistToken([context_mngr.TextContainer([sy.TextToken(["d"])])]),
|
||||||
]),
|
]),
|
||||||
context_mngr.EtUlistContainer([
|
context_mngr.EtOlistContainer([
|
||||||
sy.EtOlistToken([sy.TextToken(["aa"])]),
|
sy.EtOlistToken([context_mngr.TextContainer([sy.TextToken(["aa"])])]),
|
||||||
sy.EtOlistToken([sy.TextToken(["bb"])]),
|
sy.EtOlistToken([context_mngr.TextContainer([sy.TextToken(["bb"])])]),
|
||||||
sy.EtOlistToken([sy.TextToken(["cc"])]),
|
sy.EtOlistToken([context_mngr.TextContainer([sy.TextToken(["cc"])])]),
|
||||||
sy.Linebreak([]),
|
sy.Linebreak([]),
|
||||||
sy.EtOlistToken([sy.TextToken(["dd"])]),
|
sy.EtOlistToken([context_mngr.TextContainer([sy.TextToken(["dd"])])]),
|
||||||
sy.Linebreak([]),
|
sy.Linebreak([]),
|
||||||
]),
|
]),
|
||||||
context_mngr.LinebreakContainer([sy.Linebreak([])]),
|
context_mngr.LinebreakContainer([sy.Linebreak([])]),
|
||||||
|
|
@ -416,10 +416,10 @@ _token_list_with_expected_result = [
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.EtOlistContainer([
|
context_mngr.EtOlistContainer([
|
||||||
sy.EtOlistToken([sy.TextToken(["a"])]),
|
sy.EtOlistToken([context_mngr.TextContainer([sy.TextToken(["a"])])]),
|
||||||
], _opts),
|
], _opts),
|
||||||
context_mngr.EtOlistContainer([
|
context_mngr.EtUlistContainer([
|
||||||
sy.EtUlistToken([sy.TextToken(["b"])]),
|
sy.EtUlistToken([context_mngr.TextContainer([sy.TextToken(["b"])])]),
|
||||||
], _opts),
|
], _opts),
|
||||||
],
|
],
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
|
|
@ -631,7 +631,10 @@ def test_context_call(init_list, expected, file_line):
|
||||||
print(f"Executing tests @{file_line}")
|
print(f"Executing tests @{file_line}")
|
||||||
ctx = context_mngr.ContextManager(init_list) # noqa : F841
|
ctx = context_mngr.ContextManager(init_list) # noqa : F841
|
||||||
if isinstance(expected[0], context_mngr.BaseContainer) or isinstance(expected[0], sy.SemanticType):
|
if isinstance(expected[0], context_mngr.BaseContainer) or isinstance(expected[0], sy.SemanticType):
|
||||||
assert ctx() == expected
|
for i, e in zip(ctx(), expected):
|
||||||
|
rich.inspect(i)
|
||||||
|
rich.inspect(e)
|
||||||
|
assert i == e
|
||||||
else:
|
else:
|
||||||
with pytest.raises(expected[0]):
|
with pytest.raises(expected[0]):
|
||||||
ctx()
|
ctx()
|
||||||
|
|
@ -644,7 +647,10 @@ def test_content_call_raises():
|
||||||
|
|
||||||
|
|
||||||
def test_export_error():
|
def test_export_error():
|
||||||
em = export.ExportManager(None, None)
|
from bootstraparse.modules import config, pathresolver
|
||||||
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
|
em = export.ExportManager(__config, __templates)
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
context_mngr.TextContainer([sy.TextToken(['e']), None]).export(em)
|
context_mngr.TextContainer([sy.TextToken(['e']), None]).export(em)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import pytest
|
||||||
from bootstraparse.modules import context_mngr, export
|
from bootstraparse.modules import context_mngr, export
|
||||||
from bootstraparse.modules import syntax as sy #sy.SemanticType, sy.TextToken, sy.Linebreak, sy.StructuralElementStartToken, sy.StructuralElementEndToken, sy.EtUlistToken, sy.EtOlistToken # noqa
|
from bootstraparse.modules import syntax as sy #sy.SemanticType, sy.TextToken, sy.Linebreak, sy.StructuralElementStartToken, sy.StructuralElementEndToken, sy.EtUlistToken, sy.EtOlistToken # noqa
|
||||||
from bootstraparse.modules.tools import __GLk
|
from bootstraparse.modules.tools import __GLk
|
||||||
|
from bootstraparse.modules import config, pathresolver
|
||||||
|
|
||||||
__XF = pytest.mark.xfail
|
__XF = pytest.mark.xfail
|
||||||
_opts = sy.OptionalToken([
|
_opts = sy.OptionalToken([
|
||||||
sy.OptionalVarToken([
|
sy.OptionalVarToken([
|
||||||
|
|
@ -15,7 +17,8 @@ _opts = sy.OptionalToken([
|
||||||
|
|
||||||
class FalseHyperlink(list):
|
class FalseHyperlink(list):
|
||||||
url = "http://test.com"
|
url = "http://test.com"
|
||||||
content = ["test"]
|
content = ["test9"]
|
||||||
|
text = "test9"
|
||||||
|
|
||||||
|
|
||||||
_list_classes_expected_value = [
|
_list_classes_expected_value = [
|
||||||
|
|
@ -81,9 +84,8 @@ _list_classes_expected_value = [
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
"<ul><li>test7</li></ul>",
|
"<ul>\n<li>test7</li></ul>",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
__XF,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.EtOlistContainer([
|
context_mngr.EtOlistContainer([
|
||||||
|
|
@ -93,16 +95,12 @@ _list_classes_expected_value = [
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
"<ol><li>test8</li></ol>",
|
"<ol>\n<li>test8</li></ol>",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
__XF,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.HyperLinkContainer([
|
context_mngr.HyperLinkContainer([
|
||||||
sy.HyperlinkToken(FalseHyperlink(['test9'])),
|
sy.HyperlinkToken(FalseHyperlink(['test9'])),
|
||||||
context_mngr.TextContainer([
|
|
||||||
sy.TextToken(['test9']),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
"<a href=\"http://test.com\">test9</a>",
|
"<a href=\"http://test.com\">test9</a>",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
|
|
@ -130,20 +128,14 @@ _list_classes_expected_value = [
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.DisplayContainer([
|
context_mngr.DisplayContainer([
|
||||||
sy.DisplayToken(["!"]),
|
sy.DisplayToken(["!", "test12"]),
|
||||||
context_mngr.TextContainer([
|
|
||||||
sy.TextToken(['test12']),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
"<p class=\"display-1\">test12</p>",
|
"<p class=\"display-1\">test12</p>",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.DisplayContainer([
|
context_mngr.DisplayContainer([
|
||||||
sy.DisplayToken(["!!"]),
|
sy.DisplayToken(["!!", "test13"]),
|
||||||
context_mngr.TextContainer([
|
|
||||||
sy.TextToken(['test13']),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
"<p class=\"display-2\">test13</p>",
|
"<p class=\"display-2\">test13</p>",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
|
|
@ -197,15 +189,14 @@ _list_classes_expected_value = [
|
||||||
_opts,
|
_opts,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
"<ol><li>test13</li></ol>",
|
"<ol>\n<li>test13</li></ol>",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
__XF,
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
context_mngr.LinebreakContainer([
|
context_mngr.LinebreakContainer([
|
||||||
sy.Linebreak([""]),
|
sy.Linebreak([""]),
|
||||||
]),
|
]),
|
||||||
"<br/>\n",
|
"\n",
|
||||||
__GLk(1),
|
__GLk(1),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
@ -219,6 +210,8 @@ _zipped_list_classes_expected_value = [
|
||||||
@pytest.mark.parametrize("container, export_v, line", _zipped_list_classes_expected_value)
|
@pytest.mark.parametrize("container, export_v, line", _zipped_list_classes_expected_value)
|
||||||
def test_container_export_value(container, export_v, line):
|
def test_container_export_value(container, export_v, line):
|
||||||
print(line)
|
print(line)
|
||||||
em = export.ExportManager(None, None)
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
|
em = export.ExportManager(__config, __templates)
|
||||||
assert isinstance(container, context_mngr.BaseContainer)
|
assert isinstance(container, context_mngr.BaseContainer)
|
||||||
assert container.export(em) == export_v
|
assert container.export(em) == export_v
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ from itertools import zip_longest
|
||||||
import bootstraparse.modules.export as export
|
import bootstraparse.modules.export as export
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bootstraparse.modules import context_mngr, syntax
|
from bootstraparse.modules import context_mngr, syntax, config, pathresolver
|
||||||
from bootstraparse.modules.tools import __GLk
|
from bootstraparse.modules.tools import __GLk
|
||||||
|
|
||||||
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
|
|
||||||
__XF = pytest.mark.xfail
|
__XF = pytest.mark.xfail
|
||||||
_all_templates = {
|
_all_templates = {
|
||||||
|
|
@ -53,7 +55,7 @@ def test_export():
|
||||||
"""
|
"""
|
||||||
Test the export module
|
Test the export module
|
||||||
"""
|
"""
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
assert type(em) is export.ExportManager
|
assert type(em) is export.ExportManager
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -90,7 +92,7 @@ def test_transform(export_type, export_subtype):
|
||||||
"""
|
"""
|
||||||
Test the transform method
|
Test the transform method
|
||||||
"""
|
"""
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
re = em.transform(export.ExportRequest(export_type, export_subtype, "", { # noqa E741
|
re = em.transform(export.ExportRequest(export_type, export_subtype, "", { # noqa E741
|
||||||
"header_level": "1",
|
"header_level": "1",
|
||||||
"display_level": "1",
|
"display_level": "1",
|
||||||
|
|
@ -110,12 +112,12 @@ def test_transform(export_type, export_subtype):
|
||||||
|
|
||||||
def test_get_template_error():
|
def test_get_template_error():
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
em(export.ExportRequest("nope", "header", "", {}))
|
em(export.ExportRequest("nope", "header", "", {}))
|
||||||
|
|
||||||
|
|
||||||
def test_with_optionnals():
|
def test_with_optionnals():
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
em(export.ExportRequest("structural_elements", "div", _opts)) # noqa E741
|
em(export.ExportRequest("structural_elements", "div", _opts)) # noqa E741
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -138,14 +140,14 @@ def test_return_values():
|
||||||
|
|
||||||
|
|
||||||
def test_bad_header():
|
def test_bad_header():
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
em(export.ExportRequest("structural_elements", "header", "", {}))
|
em(export.ExportRequest("structural_elements", "header", "", {}))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("export_type, export_subtype, line", zipped_templates)
|
@pytest.mark.parametrize("export_type, export_subtype, line", zipped_templates)
|
||||||
def test_get_templates(export_type, export_subtype, line):
|
def test_get_templates(export_type, export_subtype, line):
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
# assert type(em.get_templates()) is dict
|
# assert type(em.get_templates()) is dict
|
||||||
print(export_type, export_subtype)
|
print(export_type, export_subtype)
|
||||||
r = em(export.ExportRequest(export_type, export_subtype, "", {
|
r = em(export.ExportRequest(export_type, export_subtype, "", {
|
||||||
|
|
@ -167,7 +169,7 @@ def test_get_templates(export_type, export_subtype, line):
|
||||||
|
|
||||||
|
|
||||||
def test_context_cov():
|
def test_context_cov():
|
||||||
em = export.ExportManager("test", "test")
|
em = export.ExportManager(__config, __templates)
|
||||||
lst = [context_mngr.TextContainer([syntax.TextToken("test")])]
|
lst = [context_mngr.TextContainer([syntax.TextToken("test")])]
|
||||||
|
|
||||||
# base = context_mngr.ContextManager(lst)
|
# base = context_mngr.ContextManager(lst)
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,11 @@ from bootstraparse.modules import export
|
||||||
# Environment variables
|
# Environment variables
|
||||||
|
|
||||||
env = environment.Environment()
|
env = environment.Environment()
|
||||||
env.export_mngr = export.ExportManager('', '')
|
# env.export_mngr = export.ExportManager('', '')
|
||||||
env.config = config.ConfigLoader(pathresolver.b_path("../../example_userfiles/configs/"))
|
env.config = config.ConfigLoader(pathresolver.b_path("../../example_userfiles/configs/"))
|
||||||
env.export_mngr = export.ExportManager('', '')
|
__config = config.ConfigLoader(pathresolver.b_path("configs/"))
|
||||||
|
__templates = config.ConfigLoader(pathresolver.b_path("templates/"))
|
||||||
|
env.export_mngr = export.ExportManager(__config, __templates)
|
||||||
_BASE_PATH_PREPARSER = "../../"
|
_BASE_PATH_PREPARSER = "../../"
|
||||||
_TEMP_DIRECTORY = tempfile.TemporaryDirectory()
|
_TEMP_DIRECTORY = tempfile.TemporaryDirectory()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import bootstraparse.modules.sitecreator as sitecreator
|
import bootstraparse.modules.sitecreator as sitecreator
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(reason="TODO")
|
||||||
def test_create_site():
|
def test_create_site():
|
||||||
sitecreator.create_website()
|
sitecreator.create_website()
|
||||||
sitecreator.create_environment()
|
sitecreator.create_environment()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
# Test the base parser
|
# Test the base parser
|
||||||
|
|
||||||
from bootstraparse import __main__
|
from bootstraparse import __main__
|
||||||
|
|
||||||
|
|
||||||
def test_to_test():
|
def test_to_test():
|
||||||
assert bparse.to_test() is None
|
args = __main__.parse(["path1", "path2"])
|
||||||
|
assert args.origin == "path1"
|
||||||
|
assert args.destination == "path2"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue