@@ -0,0 +1,1559 @@
+import datetime%0Afrom unittest import mock%0Aimport os%0A%0Aimport lxml.html%0A%0Afrom lib import fetch_fddb as fddb%0A%0Adef test_page_for_date():%0A    session = mock.Mock()%0A    body_text = 'Test for (1980, 1, 1)'%0A    content = '%3Chtml%3E%3Cbody%3E%7B%7D%3C/body%3E%3C/html%3E'.format(body_text)%0A    session.get.return_value.content = content%0A    page = fddb.page_for_date(datetime.datetime(1980, 1, 1), session)%0A    session.get.assert_called_with(%0A        'http://fddb.info/db/i18n/myday20/?lang=de&q=315615600&p=315529200')%0A    assert page.xpath('//body//text()')%5B0%5D == body_text%0A%0Adef test_url_for_day():%0A    assert (%0A        fddb.url_for_day(datetime.datetime(1980, 1, 1))%0A        == 'http://fddb.info/db/i18n/myday20/?lang=de&q=315615600&p=315529200')%0A%0A%0Adef test_scrape_day():%0A    content = ''%0A    with open(os.path.join(os.path.dirname(os.path.abspath(__file__)),%0A                           'Detailansicht - 2017-06-02 - Fddb.html'),%0A              'rb') as f:%0A        content = f.read()%0A    page = lxml.html.document_fromstring(content)%0A    date = datetime.datetime(2017, 6, 2)%0A    ret = fddb.scrape_day(page, date)%0A    assert ret%5B'date'%5D == date%0A    assert ret%5B'kcal'%5D == 1747%0A    food0 = ret%5B'foods'%5D%5B0%5D%0A    assert food0%5B'time'%5D == datetime.datetime(2017, 6, 2, 23, 30)%0A    assert food0%5B'food'%5D%5B'link'%5D == 'http://fddb.info/db/de/lebensmittel/brauerei_beck_becks_bier_pils/index.html'%0A    assert food0%5B'food'%5D%5B'text'%5D == 'kleine Flasche Beck%5C's Bier, Pils'%0A    assert food0%5B'kcal'%5D == 125%0A    assert food0%5B'fat'%5D == 0%0A    assert food0%5B'carbs'%5D == 7.3%0A    assert food0%5B'protein'%5D == 1.2%0A

test busines logic