Example #1
0
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)
Example #2
0
def test_should_parse_a_date():
	"""Date: Parse date components from a string"""
	line = "12. Oktober 2013"
	day,month,year = Date._parse(line)
	assert_equal(day, 12)
	assert_equal(month, "Oktober")
	assert_equal(year, 2013)
Example #3
0
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"))
Example #4
0
	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 }
Example #5
0
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)
Example #6
0
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)