proper unit tests
This commit is contained in:
58
tests.py
58
tests.py
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
import shutil
|
||||
from time import sleep
|
||||
|
||||
import converter
|
||||
|
||||
@@ -10,49 +10,55 @@ class TestDiary(unittest.TestCase):
|
||||
|
||||
# BASE_FODLER = "test_data"
|
||||
|
||||
# def test_basic_csv_input(self):
|
||||
# # python command_line 2021-01
|
||||
# BASE_FODLER = "test_data"
|
||||
# converter.write_markdown_file('quiz-example.csv')
|
||||
# # assert file was created
|
||||
# assert(os.path.exists(os.path.join(BASE_FODLER, "slide-deck.md")))
|
||||
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"
|
||||
converter.write_markdown_file('quiz-example-with-category.csv')
|
||||
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(BASE_FODLER, "slide-deck.md")))
|
||||
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"
|
||||
converter.write_markdown_file('quiz-example-with-category-and-empty-rows.csv')
|
||||
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(BASE_FODLER, "slide-deck.md")))
|
||||
assert (os.path.exists(os.path.join(OUTPUT_FODLER, "slide-deck.md")))
|
||||
|
||||
def test_to_pdf(self):
|
||||
# python command_line 2021-01
|
||||
BASE_FODLER = "test_data"
|
||||
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(BASE_FODLER, "slide-deck.md")))
|
||||
assert (os.path.exists(os.path.join(OUTPUT_FODLER, "slide-deck.pdf")))
|
||||
|
||||
# def test_create_month_file_january(self):
|
||||
# # python command_line 2021-01
|
||||
# BASE_FODLER = "test_data"
|
||||
# diary.parse_input('2021-01', BASE_FODLER)
|
||||
# # assert file was created
|
||||
# assert(os.path.exists(os.path.join(BASE_FODLER, "01_2021.md")))
|
||||
def setUp(self):
|
||||
print("test started...")
|
||||
BASE_FODLER = "test_data"
|
||||
OUTPUT_FODLER = "output"
|
||||
|
||||
|
||||
# def setUp(self):
|
||||
# print("test started...")
|
||||
# BASE_FODLER = "test_data"
|
||||
# # bla = os.path.join(BASE_FODLER, "12_2020.md")
|
||||
# if not os.path.exists(BASE_FODLER):
|
||||
# os.makedirs(BASE_FODLER)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user