~izidor/gtg/documentation

« back to all changes in this revision

Viewing changes to tests/tools/test_dates.py

  • Committer: Izidor Matušov
  • Date: 2014-03-09 15:11:59 UTC
  • Revision ID: izidor.matusov@gmail.com-20140309151159-t5ldo0a990em5989
Clean docstrings

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
# -----------------------------------------------------------------------------
19
19
 
20
 
'''
21
 
Tests for the various Date classes
22
 
'''
23
 
 
24
 
import unittest
 
20
from unittest import TestCase
25
21
from datetime import date, timedelta
26
22
 
27
23
from GTG import _
42
38
        return aday.replace(day=day, month=aday.month + 1)
43
39
 
44
40
 
45
 
class TestDates(unittest.TestCase):
46
 
    """ Tests for the various Date classes """
 
41
class TestDates(TestCase):
47
42
 
48
 
    def test_parse_dates(self):
49
 
        """ Parse common numeric date """
 
43
    def test_parses_common_formats(self):
50
44
        self.assertEqual(str(Date.parse("1985-03-29")), "1985-03-29")
51
45
        self.assertEqual(str(Date.parse("19850329")), "1985-03-29")
52
46
        self.assertEqual(str(Date.parse("1985/03/29")), "1985-03-29")
53
47
 
 
48
    def test_parses_todays_month_day_format(self):
54
49
        today = date.today()
55
50
        parse_string = "%02d%02d" % (today.month, today.day)
56
51
        self.assertEqual(Date.parse(parse_string), today)
57
52
 
 
53
    def test_parses_today_as_today(self):
 
54
        today = date.today()
 
55
        self.assertEqual(Date(today), today)
 
56
 
58
57
    def test_parse_fuzzy_dates(self):
59
58
        """ Parse fuzzy dates like now, soon, later, someday """
60
59
        self.assertEqual(Date.parse("now"), Date.now())
129
128
                aday = aday.replace(day=i)
130
129
 
131
130
            self.assertEqual(Date.parse(str(i)), aday)
132
 
 
133
 
    def test_prevent_regression(self):
134
 
        """ A day represented in GTG Date must be still the same """
135
 
        aday = date.today()
136
 
        self.assertEqual(Date(aday), aday)