Commit 8bf82864 authored by frekk's avatar frekk
Browse files

add testing for cokelog stuff

parent 8a064a04
from django.test import TestCase from django.test import TestCase
from django.conf import settings
from datetime import datetime
# Create your tests here. from .cokelog import CokeLog
class ParseCokeLog(TestCase):
def test_parse_cokelog(self):
fn = getattr(settings, 'COKELOG_PATH', None)
if fn is None:
return
cokelog = CokeLog()
self.assertFalse(cokelog.is_loaded())
cokelog.open()
self.assertTrue(cokelog.is_loaded())
self.assertIsInstance(cokelog.dispenses, dict)
for key, val in cokelog.dispenses.items():
self.assertIsInstance(val, (list, tuple))
for record in val:
self.assertIsInstance(record, dict)
self.assertTrue('by' in record)
self.assertTrue('item' in record)
self.assertIsInstance(record['date'], datetime)
n = len(cokelog.dispenses)
cokelog.reload()
self.assertTrue(n == len(cokelog.dispenses))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment