예제 #1
0
    def test_matchblock_try_str_number_off_pass_1(self):
        matchblock = MatchBlock('Year 2K', try_str_number=False)
        string = 'Year 2K'
        str_number = ''

        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_number, str_number)
예제 #2
0
    def test_matchblock_convert_roman_off_pass_1(self):
        matchblock = MatchBlock('XXI Century', convert_roman=False)
        string = 'XXI Century'
        str_number = ''

        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_number, str_number)
예제 #3
0
    def test_matchblock_try_str_custom_on_pass_1(self):
        matchblock = MatchBlock('N America', try_str_custom=True)
        string = 'America'
        str_custom = 'north'

        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_custom, str_custom)
예제 #4
0
 def test_extract_dates(self):
     text = '25 May 1977 Rome Istanbul 25 May 2005 '
     result = MatchBlock.extract_dates(text)
     self.assertEqual(result, ('Rome Istanbul', [
         datetime.datetime(1977, 5, 25, 0, 0),
         datetime.datetime(2005, 5, 25, 0, 0)
     ]))
예제 #5
0
    def test_matchblock_try_str_custom_off_pass_1(self):
        matchblock = MatchBlock('N America', try_str_custom=False)
        string = 'N America'
        str_custom = ''

        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_custom, str_custom)
예제 #6
0
 def test_compare_strings_fail_2(self):
     string1 = 'Wall'
     string2 = ''
     tolerance = 0
     result = MatchBlock.compare_strings(string1,
                                         string2,
                                         tolerance=tolerance)
     self.assertIs(result, False)
예제 #7
0
 def test_compare_strings_pass_3(self):
     string1 = 'Wall'
     string2 = 'Fall'
     tolerance = 25.5
     result = MatchBlock.compare_strings(string1,
                                         string2,
                                         tolerance=tolerance)
     self.assertIs(result, True)
예제 #8
0
 def test_compare_dates_pass_2(self):
     d1, d2 = 'Feb 12 2010', 'Feb 13 2010'
     tol = 3
     tested = MatchBlock.compare_dates(d1,
                                       d2,
                                       tolerance=tol,
                                       pattern='%b %d %Y')
     self.assertEqual(tested, True)
예제 #9
0
    def test_matchblock_try_coordinates_off_pass_1(self):
        matchblock = MatchBlock('41.49008, -71.312796', try_coordinates=False)
        coordinates = None
        string = ''
        str_number = '41 49008 71 312796'

        self.assertEqual(matchblock.coordinates, coordinates)
        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_number, str_number)
예제 #10
0
    def test_matchblock_try_date_off_pass_1(self):
        matchblock = MatchBlock('31-Dec-2015 New Year', try_date=False)
        date = []
        string = 'Dec New Year'
        str_number = '31 2015'

        self.assertEqual(matchblock.date, date)
        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_number, str_number)
예제 #11
0
    def test_matchblock_try_coordinates_on_pass_1(self):
        matchblock = MatchBlock('41.49008, -71.312796', try_coordinates=True)
        coordinates = (41.49008, -71.312796)
        string = ''
        str_number = ''

        self.assertEqual(matchblock.coordinates, coordinates)
        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_number, str_number)
예제 #12
0
 def test_compare_coordinates_fail_1(self):
     lat1 = 41.49008
     lng1 = -71.312796
     lat2 = 41.499498
     lng2 = -81.695391
     tolerance = 100
     result = MatchBlock.compare_coordinates((lat1, lng1), (lat2, lng2),
                                             tolerance=tolerance)
     self.assertIs(result, False)
예제 #13
0
    def test_matchblock_try_date_on_pass_1(self):
        matchblock = MatchBlock('31-Dec-2015 New Year', try_date=True)
        date = [datetime.datetime(2015, 12, 31, 0, 0)]
        string = 'New Year'
        str_number = ''

        self.assertEqual(matchblock.date, date)
        self.assertEqual(matchblock.string, string)
        self.assertEqual(matchblock.str_number, str_number)
예제 #14
0
 def test_compare_coordinates_fail_2(self):
     lat1 = 52.520008
     lng1 = 13.404954
     lat2 = 42.520000
     lng2 = 23.400000
     tolerance = 600
     result = MatchBlock.compare_coordinates((lat1, lng1), (lat2, lng2),
                                             tolerance=tolerance)
     self.assertIs(result, False)
예제 #15
0
 def test_compare_coordinates_fail_4(self):
     lat1 = 52.0
     lng1 = 13.0
     lat2 = 42.0
     lng2 = 23.0
     tolerance = 100
     result = MatchBlock.compare_coordinates((lat1, lng1), (lat2, lng2),
                                             tolerance=tolerance)
     self.assertIs(result, False)
예제 #16
0
 def test_compare_coordinates_pass_2(self):
     lat1 = 52.520008
     lng1 = 13.404954
     lat2 = 53.551086
     lng2 = 9.993682
     tolerance = 200
     unit = 'mi'
     result = MatchBlock.compare_coordinates((lat1, lng1), (lat2, lng2),
                                             tolerance=tolerance,
                                             unit=unit)
     self.assertIs(result, True)
예제 #17
0
 def test_compare_dates_fail_3(self):
     d1 = [
         datetime.date.today(),
         datetime.date.today() - datetime.timedelta(1)
     ]
     d2 = [
         datetime.date.today(),
         datetime.date.today() - datetime.timedelta(3)
     ]
     tol = 0
     tested = MatchBlock.compare_dates(d1, d2, tolerance=tol)
     self.assertIs(tested, False)
예제 #18
0
 def test_compare_dates_pass_5(self):
     d1 = [
         datetime.date.today(),
         datetime.date.today() - datetime.timedelta(3)
     ]
     d2 = [
         datetime.date.today() + datetime.timedelta(1),
         datetime.date.today() - datetime.timedelta(2)
     ]
     tol = 1
     tested = MatchBlock.compare_dates(d1, d2, tolerance=tol)
     self.assertIs(tested, True)
예제 #19
0
    def test_matchblock_fail_1(self):
        matchblock_1 = MatchBlock('Madrid S')
        matchblock_2 = MatchBlock('Madrid N')

        self.assertIs(matchblock_1 == matchblock_2, False)
예제 #20
0
 def test_dict_sub_pass_12(self):
     string = "there's a feeling I get when I look to the W"
     result = MatchBlock.dict_sub(string)
     self.assertEqual("there's a feeling I get when I look to the west",
                      result)
예제 #21
0
 def test_strip_zeros_pass_5(self):
     string = 'A-060H-017'
     result = MatchBlock.strip_zeros(string)
     self.assertEqual('A-60H-17', result)
예제 #22
0
 def test_strip_zeros_pass_3(self):
     string = 'A-001-102/004'
     result = MatchBlock.strip_zeros(string)
     self.assertEqual('A-1-102/4', result)
예제 #23
0
    def test_matchblock_pass_9(self):
        matchblock_1 = MatchBlock('Madrid 10')
        matchblock_2 = MatchBlock('Madrid X')

        self.assertIs(matchblock_1 == matchblock_2, True)
예제 #24
0
    def test_matchblock_pass_8(self):
        matchblock_1 = MatchBlock('IATA 10')
        matchblock_2 = MatchBlock('International Air Transport Association 10')

        self.assertIs(matchblock_1 == matchblock_2, True)
예제 #25
0
 def test_strip_zeros_pass_2(self):
     string = 'London T001'
     result = MatchBlock.strip_zeros(string)
     self.assertEqual('London T1', result)
예제 #26
0
 def test_dict_sub_pass_11(self):
     string = 'J-W1-NX186'
     result = MatchBlock.dict_sub(string)
     self.assertEqual('J-W1-NX186', result)
예제 #27
0
 def test_strip_zeros_pass_4(self):
     string = '005I-009-059'
     result = MatchBlock.strip_zeros(string)
     self.assertEqual('5I-9-59', result)
예제 #28
0
    def test_matchblock_fail_2(self):
        matchblock_1 = MatchBlock('Madrid 1')
        matchblock_2 = MatchBlock('Madrid')

        self.assertIs(len(matchblock_1) == len(matchblock_2), False)
예제 #29
0
 def test_strip_zeros_pass_6(self):
     string = '0-060H-0Z'
     result = MatchBlock.strip_zeros(string)
     self.assertEqual('0-60H-0Z', result)
예제 #30
0
    def test_matchblock_fail_3(self):
        matchblock_1 = MatchBlock('Madrid 1')
        matchblock_2 = 1

        self.assertRaises(TypeError, matchblock_1.__eq__, matchblock_2)