Beispiel #1
0
    def test_date_guesses(self):

        # Case
        match = {
            "token": "1123",
            "separator": "",
            "has_full_year": False,
            "year": 1923,
            "month": 1,
            "day": 1
        }
        msg = "guesses for {} is days * months * distance_from_ref_year", format(match["token"])
        self.assertEqual(scoring.date_guesses(match), 12 * 31 * math.fabs(scoring.REFERENCE_YEAR - match["year"]), msg)

        # Case
        match = {
            "token": "1/1/2010",
            "separator": "/",
            "has_full_year": True,
            "year": 2010,
            "month": 1,
            "day": 1
        }
        msg = "recent years assume MIN_YEAR_SPACE."
        msg += " extra guesses is added for separators and a 4-digit year."
        self.assertEqual(scoring.date_guesses(match), 12 * 31 * scoring.MIN_YEAR_SPACE * 4 * 2, msg)
Beispiel #2
0
    def test_date_guesses(self):

        # Case
        match = {
            "token": "1123",
            "separator": "",
            "has_full_year": False,
            "year": 1923,
            "month": 1,
            "day": 1
        }
        msg = "guesses for {} is days * months * distance_from_ref_year", format(match["token"])
        self.assertEqual(scoring.date_guesses(match), 12 * 31 * math.fabs(scoring.REFERENCE_YEAR - match["year"]), msg)

        # Case
        match = {
            "token": "1/1/2010",
            "separator": "/",
            "has_full_year": True,
            "year": 2010,
            "month": 1,
            "day": 1
        }
        msg = "recent years assume MIN_YEAR_SPACE."
        msg += " extra guesses is added for separators and a 4-digit year."
        self.assertEqual(scoring.date_guesses(match), 12 * 31 * scoring.MIN_YEAR_SPACE * 4 * 2, msg)
Beispiel #3
0
    def test_calc_guesses(self):

        # Case
        match = {"guesses": 1}
        msg = "estimate_guesses returns cached guesses when available"
        self.assertEqual(scoring.estimate_guesses(match, ''), 1, msg)

        match = {
            "pattern": 'date',
            "token": '1977',
            "year": 1977,
            "month": 7,
            "day": 14
        }
        msg = "estimate_guesses delegates based on pattern"
        self.assertEqual(scoring.estimate_guesses(match, "1977"), scoring.date_guesses(match))
Beispiel #4
0
    def test_calc_guesses(self):

        # Case
        match = {"guesses": 1}
        msg = "estimate_guesses returns cached guesses when available"
        self.assertEqual(scoring.estimate_guesses(match, ''), 1, msg)

        match = {
            "pattern": 'date',
            "token": '1977',
            "year": 1977,
            "month": 7,
            "day": 14
        }
        msg = "estimate_guesses delegates based on pattern"
        self.assertEqual(scoring.estimate_guesses(match, "1977"), scoring.date_guesses(match))