diff --git a/src/main.py b/src/main.py index 5eab71c..25b52ed 100644 --- a/src/main.py +++ b/src/main.py @@ -53,6 +53,14 @@ for root, dirs, files in os.walk('quotes/'): csvreader = csv.DictReader(csvfile, delimiter=',', quotechar='`', skipinitialspace=True) quotes += list(csvreader) +for q in quotes: + # Check correct number of fields + assert (len(q) == 4), "Error: wrong number of fields in " + str(q) + # Check correct field names + assert ('quote' in q and 'author' in q and 'link' in q and 'linktitle' in q), "Error: missing field in " + str(q) + # Check that no field is empty + assert (q['quote'] and q['author'] and q['link'] and q['linktitle']), "Error: empty field in " + str(q) + print(f"Found {len(quotes)} total quotes") row = random.choice(quotes)