Files
kjv_api/tools/sanity_check.py
T
2023-05-31 00:11:29 -07:00

56 lines
1.6 KiB
Python

# Check if all the files needed by kjv-api (to write to) are also owned by the user running it.
# if this is not the same, writing to data/seq.db (and other undesirable behavior) is inevitable
# and will save a lot of headache in the future.
#Additionally, proper CHMOD value is 664 for the database
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)
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