Create separate directory for unit test

main
Bob Mottram 2023-12-31 15:26:20 +00:00
parent eb205f9222
commit b22cf1c1a7
2 changed files with 9 additions and 2 deletions

View File

@ -369,6 +369,8 @@ def store_book_events(base_dir: str,
print('DEBUG: no book event')
return False
reading_path = base_dir + '/accounts/reading'
if not os.path.isdir(base_dir + '/accounts'):
os.mkdir(base_dir + '/accounts')
if not os.path.isdir(reading_path):
os.mkdir(reading_path)
books_path = reading_path + '/books'

View File

@ -8237,9 +8237,11 @@ def _test_book_link(base_dir: str):
max_recent_books = 1000
max_cached_readers = 10
base_dir += '/.testbookevents'
if os.path.isdir(base_dir):
shutil.rmtree(base_dir, ignore_errors=False, onerror=None)
os.mkdir(base_dir)
reading_dir = base_dir + '/accounts/reading'
if os.path.isdir(reading_dir):
shutil.rmtree(reading_dir, ignore_errors=False, onerror=None)
content = 'Not a link'
result = get_book_link_from_content(content)
@ -8422,6 +8424,9 @@ def _test_book_link(base_dir: str):
assert books_cache['reader_list'][2] == actor
assert books_cache['readers'].get(actor)
if os.path.isdir(base_dir):
shutil.rmtree(base_dir, ignore_errors=False, onerror=None)
def run_all_tests():
base_dir = os.getcwd()