2021-06-16 16:55:11 +02:00

72 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
import os
import unittest
from time import sleep
import converter
class TestDiary(unittest.TestCase):
# BASE_FODLER = "test_data"
def test_basic_csv_input(self):
# python command_line 2021-01
BASE_FODLER = "test_data"
OUTPUT_FODLER = "output"
file_path = os.path.join(BASE_FODLER, "quiz-example.csv")
converter.write_markdown_file(file_path)
# assert file was created
assert (os.path.exists(os.path.join(OUTPUT_FODLER, "slide-deck.md")))
def test_csv_input_with_categories(self):
# python command_line 2021-01
BASE_FODLER = "test_data"
OUTPUT_FODLER = "output"
file_path = os.path.join(BASE_FODLER, "quiz-example-with-category.csv")
# converter.write_markdown_file('test_data/quiz-example-with-category.csv')
converter.write_markdown_file(file_path)
# assert file was created
assert (os.path.exists(os.path.join(OUTPUT_FODLER, "slide-deck.md")))
def test_csv_input_with_categories_and_empty_rows(self):
# python command_line 2021-01
BASE_FODLER = "test_data"
OUTPUT_FODLER = "output"
file_path = os.path.join(BASE_FODLER, "quiz-example-with-category-and-empty-rows.csv")
converter.write_markdown_file(file_path)
# assert file was created
assert (os.path.exists(os.path.join(OUTPUT_FODLER, "slide-deck.md")))
def test_to_pdf(self):
# python command_line 2021-01
OUTPUT_FODLER = "output"
converter.to_pdf("slide-deck.md")
sleep(5) # wait for docker container to finish conversion
# assert file was created
assert (os.path.exists(os.path.join(OUTPUT_FODLER, "slide-deck.pdf")))
def setUp(self):
print("test started...")
BASE_FODLER = "test_data"
OUTPUT_FODLER = "output"
if not os.path.exists(BASE_FODLER):
os.makedirs(BASE_FODLER)
if not os.path.exists(OUTPUT_FODLER):
os.makedirs(OUTPUT_FODLER)
# def tearDown(self):
# # pass
# BASE_FODLER = "test_data"
# if os.path.exists(BASE_FODLER):
# shutil.rmtree(BASE_FODLER) # remove testing garbage folder
if __name__ == '__main__':
unittest.main()