def test_should_create_a_date(): """Date: Creates a date""" line = "12. Oktober 2013" date = Date.from_str(line) assert_equal(date.day, 12) assert_equal(date.month, "Oktober") assert_equal(date.year, 2013)
def test_should_find_entries(): """Entries: The articles can be retrieved by their path""" entries = Entries() entries._entries = {"path": Entry("Title", "23. Februar 2013", "path")} entry = entries.find("path") assert_equal(entry.title, "Title") assert_equal(entry.date, Date.from_str("23. Februar 2013"))
def load(self, source): lines = source entries = [ self._parse(line) for line in lines if not self._is_comment(line) and not self._is_empty(line) ] return { path: Entry(title, Date.from_str(date), path) for title,date,path in entries }
def test_compare_dates_by_year(): """Date: Compare dates by year""" first = Date.from_str("13. Oktober 2018") second = Date.from_str("13. Oktober 2013") assert_equal(cmp(first, second), 1)
def test_compare_dates_by_month(): """Date: Compare dates by day""" first = Date.from_str("13. Oktober 2014") second = Date.from_str("13. Oktober 2013") assert_equal(cmp(first, second), 1)