proper unit tests

This commit is contained in:
dechert
2021-06-16 16:55:11 +02:00
parent 16d67c49f4
commit 7986ab6bab
6 changed files with 50 additions and 38 deletions

View File

@@ -1,14 +1,13 @@
import calendar
import os
import shutil
# def file_exists(filename):
# if os.path.exists(filename):
# print('Note: Diary \'' + filename + '\' already exists. Will not be modified.')
# return True
# return False
NUMBER_OF_ANSWERS = 5
BASE_FODLER = "test_data"
class QuestionAndAnswers:
@@ -23,19 +22,22 @@ class QuestionAndAnswers:
def convert(csv_path, output_pdf=False):
write_markdown_file(csv_path)
if(output_pdf):
if (output_pdf):
to_pdf("slide-deck.md")
def write_markdown_file(csv_path):
# csv_path = "quiz-example.csv"
markdown_path = "slide-deck.md"
OUTPUT_FODLER = "output"
markdown_filename = "slide-deck.md"
markdown_path = os.path.join(OUTPUT_FODLER, markdown_filename)
# read CSV
list_of_q_and_as = []
with open(csv_path, 'r', encoding='UTF-8') as csv_file:
data = csv_file.readlines()
current_category = "bla"
current_category = ""
for line in data:
if line.startswith("Kategorie"):
name_of_category = line.split(",")[0]
@@ -108,8 +110,12 @@ def to_pdf(filename):
client = docker.from_env()
current_dir = os.getcwd()
print(current_dir)
OUTPUT_FODLER = "output"
output_folder_path = os.path.join(current_dir, OUTPUT_FODLER)
# https://docker-py.readthedocs.io/en/stable/containers.html
client.containers.run('marpteam/marp-cli', '{} --pdf'.format(filename), volumes=[current_dir + ':/home/marp/app/'],
client.containers.run('marpteam/marp-cli', '{} --pdf'.format(filename), volumes=[output_folder_path + ':/home/marp/app/'],
name="marp", detach=True, remove=True, init=True)
container = client.containers.get('marp')