Ejemplo n.º 1
0
 def input_failure_3(self):
     d = DateParser(text='', start_year=2019, end_year=2019)
     expected_output = [
         _date(date='january 01 2019',
               token_span=(12, 27),
               token_index=(4, 4),
               format='%B %d %Y')
     ]
     self.assertEqual(d.date, expected_output, 'should be equal.')
Ejemplo n.º 2
0
    def test_date_parser(self):
        d1 = DateParser(text=texts.get('S1'), start_year=2019, end_year=2019)
        o1 = [
            _date(date='january 01 2019',
                  token_span=(12, 27),
                  token_index=(2, 4),
                  format='%B %d %Y')
        ]
        self.assertEqual(d1.date, o1, 'should be equal.')

        d2 = DateParser(text=texts.get('S2'), start_year=2019, end_year=2019)
        o2 = None
        self.assertEqual(d2.date, o2, 'should be equal.')

        d3 = DateParser(text=texts.get('S2'), start_year=2016, end_year=2019)
        o3 = [
            _date(date='january 04, 2017',
                  token_span=(19, 35),
                  token_index=(4, 6),
                  format='%B %d, %Y')
        ]
        self.assertEqual(d3.date, o3, 'should be equal.')

        d4 = DateParser(text=texts.get('S1'), start_year=2019, end_year=2019)
        d5 = DateParser(text=texts.get('S1'), start_year=2019, end_year=2019)
        self.assertEqual(d4, d5, 'should be equal.')

        d6 = DateParser(text=texts.get('S4'), start_year=2015, end_year=2019)
        o4 = [
            _date(date='december 12th, 2015',
                  token_span=(56, 75),
                  token_index=(10, 12),
                  format='%B %o, %Y'),
            _date(date='dec 31 2015',
                  token_span=(14, 25),
                  token_index=(2, 4),
                  format='%b %-d %Y'),
            _date(date='dec 31 2015',
                  token_span=(14, 25),
                  token_index=(2, 4),
                  format='%b %d %Y')
        ]
        self.assertEqual(d6.date, o4, 'should be equal.')