From a88774fc5b856d68b99776e0b369f90fccc3978f Mon Sep 17 00:00:00 2001 From: Tyler Dinsmoor Date: Wed, 31 May 2023 00:11:29 -0700 Subject: [PATCH] skeleton tests --- app.py | 10 ++++++++-- tools/sanity_check.py | 45 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index fd4dcfc..c9d06be 100644 --- a/app.py +++ b/app.py @@ -26,6 +26,11 @@ try: except PermissionError as e: logging.critical(f"PERMISSIONS FAILURE: {e}") sanity: bool = False +except Exception as e: + logging.critical(e) + sanity: bool = False +finally: + logging.info(f"Sanity: {sanity}") app = Flask(__name__, template_folder='html') @@ -511,11 +516,12 @@ def bible_reader(): # Maybe preliminary theming support @app.get("/plan") def reading_plan(): - return send_file("html/reading_plan.html") # needs 2 sets of data, books and time frame. # should default to the entire Bible in 1 year. # should start today() and end today()+1year - # Should return a calender with date and verse range. + # Should return reading_plan template. + return render_template("reading_plan.html") + @app.get("/status") def status(): import resource diff --git a/tools/sanity_check.py b/tools/sanity_check.py index 9d4ab6e..7ceaca7 100644 --- a/tools/sanity_check.py +++ b/tools/sanity_check.py @@ -6,8 +6,51 @@ from os import stat, getuid def check_sanity(): + check_database_permissions() + check_random() + check_verse_of_the_day() + check_find() + check_define() + check_search() + check_show() + check_seq() + check_shortcode() + +def check_database_permissions(): dependancies = ['data/seq.db', "data/shortcodes.db"] current_uid = getuid() for dependancy in dependancies: if stat(dependancy).st_uid != current_uid: - raise PermissionError(dependancy) \ No newline at end of file + raise PermissionError(dependancy) + +def check_random(): + #TODO: Ensure random returns a verse + pass + +def check_verse_of_the_day(): + #TODO: Ensure VOTD returns a verse, the same, at least twice + pass + +def check_find(): + #TODO: Ensure that a varaity of queries don't cause an error (need to define a few) + pass + +def check_define(): + #TODO: Ensure a few words that are in the dictionary (and those that are not) and those misspelled, give correct responses + pass + +def check_search(): + #TODO: Ensure that blanket searches with different syntaxes resolve correctly + pass + +def check_show(): + #TODO: Ensure that many types of verse syntaxes correctly resolve. + pass + +def check_seq(): + #TODO: Begin a new sequence and check that it does not give us an error + pass + +def check_shortcode(): + #TODO: make a new shortcode for a search and then try to resolve it. + pass \ No newline at end of file