Commit 9f31eeb1 authored by Denis Salem's avatar Denis Salem
Browse files

WIP: themes compliance utests

parent f53d177e
......@@ -39,8 +39,8 @@ from venc2.patterns.processor import ProcessedString
# Initialisation of environment
start_timestamp = time.time()
datastore = DataStore()
code_highlight = CodeHighlight(datastore.blog_configuration["code_highlight_css_override"])
datastore = None
code_highlight = None
theme_assets_dependencies = []
......@@ -158,6 +158,10 @@ def process_non_contextual_patterns(pattern_processor, theme):
pattern_processor.process(theme.atom_footer)
def export_blog(argv=list()):
global datastore
datastore = DataStore()
global code_highlight
code_highlight = CodeHighlight(datastore.blog_configuration["code_highlight_css_override"])
theme, theme_folder = init_theme(argv)
patterns_map = PatternsMap(datastore, code_highlight, theme)
pattern_processor = setup_pattern_processor(patterns_map)
......
......@@ -94,7 +94,6 @@ def test_markup_language(args, test_name):
ps.process_markup_language(markup_language)
return ps.string.replace('\n', '')
tests = [
(
"Simple pattern detection.",
......@@ -253,7 +252,7 @@ tests = [
test_markup_language
),
(
"reStructuredText integration.",
"reStructuredText integration integration when pattern produce html.",
("Main title\n==========\n.:add::1::1:.", "reStructuredText", ["add"]),
"<div class=\"document\"><div class=\"section\" id=\"main-title\"><h1>Main title</h1>2</div></div>",
test_markup_language
......
#! /usr/bin/env python3
# Copyright 2016, 2018 Denis Salem
#
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import platform
print("Test run with Python", platform.python_version())
from patterns_processing import run_tests as patterns_processing
from themes import run_tests as themes
#! /usr/bin/env python3
# Copyright 2016, 2018 Denis Salem
#
# This file is part of VenC.
#
# VenC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# VenC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
from venc2.prompt import get_formatted_message
def run_tests(tests_name, tests):
......@@ -11,7 +28,11 @@ def run_tests(tests_name, tests):
print(get_formatted_message("\t"+test_name+" Pass", prompt=""))
except AssertionError as e:
print(get_formatted_message("\t"+test_name+" "+str(e), color="RED", prompt=""))
if str(e) == test_name:
print(get_formatted_message("\t"+test_name+" Failed", color="RED", prompt=""))
else:
print(get_formatted_message("\t"+test_name+" "+str(e), color="RED", prompt=""))
except Exception as venc_defined_exception:
try:
......
......@@ -17,5 +17,88 @@
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
os.chdir("themes/tested")
from venc2.commands.export import export_blog
from venc2.helpers import GenericMessage
from venc2.prompt import get_formatted_message
from test_engine import run_tests
def tree_list_dir(root_path, clear):
l = []
a = l.append
for t in os.walk(root_path):
for f in t[2]:
a( '/'.join((t[0]+'/'+f).split('/')[clear:]) )
return l
def test_theme(args, test_name):
refs, theme = args
null = open('/dev/null', 'w')
stdout = sys.stdout
sys.stdout = null
export_blog([theme])
sys.stdout = stdout
tested = tree_list_dir('blog', 1)
refs = tree_list_dir('../refs/'+(theme.capitalize()), 3)
extra = []
a = extra.append
for f in tested:
if not f in refs:
a(f)
missings = []
a = missings.append
for f in refs:
if not f in tested:
a(f)
len_missings = len(missings)
len_extra = len(extra)
for f in missings:
print(get_formatted_message("\t\tMissing: "+f, color="RED", prompt=""))
for f in extra:
print(get_formatted_message("\t\tExtra: "+f, color="RED", prompt=""))
if len_missings or len_extra:
return False
else:
return True
tests = [
(
"Gentle.",
("../refs/Gentle", "gentle"),
True,
test_theme
),
(
"Tessellation.",
("../refs/Tessellation", "tessellation"),
True,
test_theme
),
(
"Academik.",
("../refs/Academik", "academik"),
True,
test_theme
),
]
run_tests("Testings default themes compliance", tests)
os.chdir("../..")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment