From f84398436e03674bd3e5d88d2680b36f40659685 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Sun, 27 Aug 2017 14:41:40 +0200 Subject: [PATCH] Most bugs squashed, beggening v0.1a --- sites/generated_website/Poetry/index_en.html | 70 ------------ sites/generated_website/Poetry/index_fr.html | 70 ------------ .../generated_website/Poetry/poetry1_en.html | 70 ------------ .../generated_website/Poetry/poetry1_fr.html | 70 ------------ sites/generated_website/article1_en.html | 69 ------------ sites/generated_website/article1_fr.html | 69 ------------ sites/generated_website/index_en.html | 69 ------------ sites/generated_website/index_fr.html | 69 ------------ test.py | 105 +++++++++++++++--- vkyweb.py | 9 -- 10 files changed, 89 insertions(+), 581 deletions(-) delete mode 100644 sites/generated_website/Poetry/index_en.html delete mode 100644 sites/generated_website/Poetry/index_fr.html delete mode 100644 sites/generated_website/Poetry/poetry1_en.html delete mode 100644 sites/generated_website/Poetry/poetry1_fr.html delete mode 100644 sites/generated_website/article1_en.html delete mode 100644 sites/generated_website/article1_fr.html delete mode 100644 sites/generated_website/index_en.html delete mode 100644 sites/generated_website/index_fr.html diff --git a/sites/generated_website/Poetry/index_en.html b/sites/generated_website/Poetry/index_en.html deleted file mode 100644 index e4be430..0000000 --- a/sites/generated_website/Poetry/index_en.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Mulloland - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/Poetry/index_fr.html b/sites/generated_website/Poetry/index_fr.html deleted file mode 100644 index 07bde70..0000000 --- a/sites/generated_website/Poetry/index_fr.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Mulehollande - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/Poetry/poetry1_en.html b/sites/generated_website/Poetry/poetry1_en.html deleted file mode 100644 index f02053d..0000000 --- a/sites/generated_website/Poetry/poetry1_en.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Mulloland - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/Poetry/poetry1_fr.html b/sites/generated_website/Poetry/poetry1_fr.html deleted file mode 100644 index 0e5e320..0000000 --- a/sites/generated_website/Poetry/poetry1_fr.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - Mulehollande - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/article1_en.html b/sites/generated_website/article1_en.html deleted file mode 100644 index ffcf1c1..0000000 --- a/sites/generated_website/article1_en.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Mulloland - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/article1_fr.html b/sites/generated_website/article1_fr.html deleted file mode 100644 index 8d9ffb1..0000000 --- a/sites/generated_website/article1_fr.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Mulehollande - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/index_en.html b/sites/generated_website/index_en.html deleted file mode 100644 index aa41fbb..0000000 --- a/sites/generated_website/index_en.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Mulloland - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/sites/generated_website/index_fr.html b/sites/generated_website/index_fr.html deleted file mode 100644 index 59bec5a..0000000 --- a/sites/generated_website/index_fr.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - Mulehollande - - - - - - - - - - -
- - - - -
- -
- -
- - - - - - - - - - - - \ No newline at end of file diff --git a/test.py b/test.py index 93d3e47..cc38134 100644 --- a/test.py +++ b/test.py @@ -1,21 +1,73 @@ # Copyleft (c) 2016 Cocobug All Rights Reserved. # -*- coding: utf_8 -*- -from minitest import minitest +import sys +try: + from blessings import Terminal +except: + print ("You need to have blessings installed to run the test") + sys.exit() +try: + from minitest import minitest +except: + print ("You need to have minitest installed to run the test") + print ("the latest version of minitest should have been included with the vkyweb package") + sys.exit() import types -from blessings import Terminal from generator import * - -#import vkyweb - term=Terminal() unit=minitest.testUnit simple=minitest.simpleTestUnit group=minitest.testGroup dual=models.dual +class testImports(simple): + def __init__(self,name): + super(testImports,self).__init__(name) + + def _test_all(self): + self.currentTest("import:base/packages") + import argparse,os,sys,shutil,os,sys,codecs,re,traceback + self.addSuccess() + + self.currentTest("import:markdown") + try: + import markdown + self.addSuccess() + except: + self.addFailure("cannot import module markdown",nonDestructive=True) + self.addFailure("markdown is now mandatory to parse files") + + self.currentTest("import:generator") + import generator + self.addSuccess() + + self.currentTest("import:generator:config") + from generator import config + self.addSuccess() + + self.currentTest("import:generator:file_parser") + from generator import file_parser + self.addSuccess() + + self.currentTest("import:generator:model") + from generator import model + self.addSuccess() + + self.currentTest("import:generator:tree_parser") + from generator import tree_parser + self.addSuccess() + + self.currentTest("import:generator:models") + from generator import models + self.addSuccess() + + self.currentTest("import:generator:models:dual") + from generator.models import dual + self.addSuccess() + class testParser(simple): """Testing the file parser""" def __init__(self,name): @@ -96,20 +148,23 @@ class testParser(simple): self.currentTest("parser_file") contentCheck={ - 'error':['![Alt text](/path/to/img.jpg)', "If you don't close properly something __a lot of content will be lost", '__in the generation', 'process', 'Like this'] - ,"*":['![Alt text](/path/to/img.jpg)', 'Like this'] - ,"en":['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', '![Alt text](/path/to/img.jpg)', 'Like this'] - ,"fr": ['Loreme ipsume dolore site amete, consecteture adipisicinge elite, sede doe eiusmode tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolore ine reprehenderite ine voluptate velite esse cillume dolore eu fugiatte nulla pariature. Excepteure sinte occaecate cupidatate none proidente, sunta ine culpa qui officia deserunte mollite anime ide est laborume.', '![Alt text](/path/to/img.jpg)', 'Like this'] - ,"hidden":['![Alt text](/path/to/img.jpg)', 'Hiden text, can be used in many ways. Note that hidden is not a reserved keyword and is just treated separately in the generation process.', 'Like this'] - ,"useless":['![Alt text](/path/to/img.jpg)', 'The useless keyword is not reserved either, and since it wont be treated in the generation process, it will just be lost', 'Like this'] + 'error':['![Alt text](./assets/img/logo.png)', "If you don't close properly something __a lot of content will be lost", '__in the generation', 'process', 'Like this'] + ,"*":['![Alt text](./assets/img/logo.png)', 'Like this'] + ,"en":['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', '![Alt text](./assets/img/logo.png)', 'Like this'] + ,"fr": ['Loreme ipsume dolore site amete, consecteture adipisicinge elite, sede doe eiusmode tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolore ine reprehenderite ine voluptate velite esse cillume dolore eu fugiatte nulla pariature. Excepteure sinte occaecate cupidatate none proidente, sunta ine culpa qui officia deserunte mollite anime ide est laborume.', '![Alt text](./assets/img/logo.png)', 'Like this'] + ,"hidden":['![Alt text](./assets/img/logo.png)', 'Hiden text, can be used in many ways. Note that hidden is not a reserved keyword and is just treated separately in the generation process.', 'Like this'] + ,"useless":['![Alt text](./assets/img/logo.png)', 'The useless keyword is not reserved either, and since it wont be treated in the generation process, it will just be lost', 'Like this'] } self.addSuccess() for lang in contentCheck.keys(): self.currentTest("parser_file:"+lang) - if contentCheck[lang]==[e for e in index.get_next_line(lang)]: + lines=[e for e in index.get_next_line(lang)] + if contentCheck[lang]==lines: self.addSuccess() else: - self.addFailure("Error text doesn't match") + self.addFailure("Error text doesn't match",nonDestructive=True) + self.addFailure(" expected: {}".format(contentCheck[lang]),nonDestructive=True) + self.addFailure(" got: {}".format(lines)) class testTree(simple): @@ -236,7 +291,11 @@ class testModel(simple): # # menu=model.makeContainer(dual,site,current_node,previous_node,lang) # data=model.makeData(dual,current_node,lang) - # + # makeHTMLName(text) + # makeiFrame + # makeLangSwitch + # makeData + # pathAssets # page=model.makePage(dual,site,lang,menu,data) #print(page) @@ -288,12 +347,25 @@ class testDual(simple): self.currentTest("dual:langselect") dual_select=dual.langselect([("en","index_en.html","english"),('fr',"index_fr.html","french")],"en") - nominalselect="""""" + nominalselect="""""" if dual_select==nominalselect: self.addSuccess() else: - self.addFailure("links malformed (expected {})".format(nominalselect)) + self.addFailure("links malformed (expected {})".format(nominalselect),nonDestructive=True) + self.addFailure(" (got {})".format(dual_select)) + self.currentTest("dual:iframe") + if (dual.iframe(["page1.html","page2.html"])!=""""""): + self.addFailure("iframes generation incorrect") + else: + self.addSuccess() + + import os + self.currentTest("dual:pathAssets") + if os.path.exists(dual.assets()): + self.addSuccess() + else: + self.addFailure() def testThisDictOnDis(self,name,testDict,testFunction,returnType=str,returnDict=None): res=testFunction(**testDict) if returnDict==None: @@ -329,6 +401,7 @@ testVky=group(name="vkyWeb_all",terminal=term,verbose=1,align=42) #testParser time testParser("file_parser").test() +testVky.addTest(testImports("imports")) testVky.addTest(testParser("file_parser")) testVky.addTest(testTree("tree_parser")) testVky.addTest(testModel("model")) diff --git a/vkyweb.py b/vkyweb.py index 89d35da..13e6a92 100644 --- a/vkyweb.py +++ b/vkyweb.py @@ -15,9 +15,6 @@ def saveData(path,data): def savePath(path): return os.path.join(save_path,path) -def saveMenus(): - pass - def HTMLNameCreator(lang,ext="html"): ext,lang=ext,lang def makeHTMLName(text): @@ -119,7 +116,6 @@ if not args.dry: shutil.copytree(model.pathAssets(choosen_model),os.path.join(save_path,"assets")) except OSError: pass -#website.print_webtree(lang="fr",prefix=" * ") # Walk & generate if args.verbose: @@ -135,8 +131,3 @@ for lang in args.l: #Generate every page in .lang.html (with both contents) previous_node=None#website.tree.get_node("index",lang) gen_all_nodes_menu(website.tree,lang,previous_node=None,depth="") gen_all_nodes_content(website.tree,lang) - - #for tree in website.tree.get_next_subtree(): - # previous_node=tree # For now, you can't get higher than index -#for every lang, do a mix of print_webtree and makeContainer - #container=model.makeContainer(s)