コード例 #1
0
ファイル: test_FindPoints.py プロジェクト: geo2tag/geo2tag
    def testGeometrySearch(self):
        TEST_GEOMETRY_P = {'type': 'Polygon', 'coordinates': [
            [[0.9, 0.9], [0.9, 1.1], [1.4, 1.1], [1.4, 0.9], [0.9, 0.9]]]}
        TEST_GEOMETRY_C = {'type': 'Point', 'coordinates': [1, 1]}
        TEST_RADIUS = 0.003

        VALID_RESULTS_NUMBER_1 = 3
        VALID_RESULTS_NUMBER_2 = 2

        result_1 = list(
            findPoints(
                TEST_SERVICE,
                TEST_CHANNELS,
                TEST_NUMBER,
                TEST_GEOMETRY_P))
        result_2 = list(
            findPoints(
                TEST_SERVICE,
                TEST_CHANNELS,
                TEST_NUMBER,
                TEST_GEOMETRY_C,
                None,
                None,
                None,
                None,
                None,
                None,
                TEST_RADIUS))

        self.assertEquals(VALID_RESULTS_NUMBER_1, len(result_1))
        self.assertEquals(VALID_RESULTS_NUMBER_2, len(result_2))
コード例 #2
0
    def get(self, serviceName):
        params_with_errs = PointListResourceParser.parseGetParameters()

        # Generating error string for 'bc_from' and 'bc_to' parameters if error
        # appeared
        if len(params_with_errs[POINT_LIST_PARSER_ERRS_KEY]) > 0:
            err_str = ""
            for i in params_with_errs[POINT_LIST_PARSER_ERRS_KEY]:
                err_str += '[' + i + '] '
            # GET request will return 'standard' error for bad parameters
            return {BC_DATES_FLAGS_ERR_KEY: err_str +
                    BC_DATES_FLAGS_ERR_VAL}, 400

        params = params_with_errs
        result = findPoints(
            serviceName,
            params[CHANNEL_IDS],
            params[NUMBER],
            params[GEOMETRY],
            params[ALTITUDE_FROM],
            params[ALTITUDE_TO],
            params[SUBSTRING],
            dateDeserialiser(
                params,
                DATE_FROM),
            dateDeserialiser(
                params,
                DATE_TO),
            params[OFFSET],
            params[RADIUS])
        return result
コード例 #3
0
ファイル: test_FindPoints.py プロジェクト: geo2tag/geo2tag
 def testDateSearch(self):
     TEST_DATE_FROM = dateutil.parser.parse("2015-09-10T23:32:17.814Z")
     TEST_DATE_FROM_1 = dateutil.parser.parse("2015-09-11T23:32:16.814Z")
     TEST_DATE_TO = dateutil.parser.parse("2015-09-11T23:32:17.814Z")
     TEST_DATE_TO_1 = dateutil.parser.parse("2015-09-11T23:32:16.814Z")
     VALID_RESULTS_NUMBER_1 = 4
     VALID_RESULTS_NUMBER_2 = 3
     VALID_RESULTS_NUMBER_3 = 1
     result_1 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_FROM,
             TEST_DATE_TO))
     result_2 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             None,
             TEST_DATE_TO_1))
     result_3 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_FROM_1))
     self.assertEquals(VALID_RESULTS_NUMBER_1, len(result_1))
     self.assertEquals(VALID_RESULTS_NUMBER_2, len(result_2))
     self.assertEquals(VALID_RESULTS_NUMBER_3, len(result_3))
コード例 #4
0
ファイル: test_FindPoints.py プロジェクト: testmana2/geo2tag
 def testDateSearch(self):
     TEST_DATE_FROM = dateutil.parser.parse("2015-09-10T23:32:17.814Z")
     TEST_DATE_FROM_1 = dateutil.parser.parse("2015-09-11T23:32:16.814Z")
     TEST_DATE_TO = dateutil.parser.parse("2015-09-11T23:32:17.814Z")
     TEST_DATE_TO_1 = dateutil.parser.parse("2015-09-11T23:32:16.814Z")
     VALID_RESULTS_NUMBER_1 = 4
     VALID_RESULTS_NUMBER_2 = 3
     VALID_RESULTS_NUMBER_3 = 1
     result_1 = list(
         findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER, None, None,
                    None, None, TEST_DATE_FROM, TEST_DATE_TO))
     result_2 = list(
         findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER, None, None,
                    None, None, None, TEST_DATE_TO_1))
     result_3 = list(
         findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER, None, None,
                    None, None, TEST_DATE_FROM_1))
     self.assertEquals(VALID_RESULTS_NUMBER_1, len(result_1))
     self.assertEquals(VALID_RESULTS_NUMBER_2, len(result_2))
     self.assertEquals(VALID_RESULTS_NUMBER_3, len(result_3))
コード例 #5
0
ファイル: test_FindPoints.py プロジェクト: testmana2/geo2tag
    def testGeometrySearch(self):
        TEST_GEOMETRY_P = {
            'type':
            'Polygon',
            'coordinates': [[[0.9, 0.9], [0.9, 1.1], [1.4, 1.1], [1.4, 0.9],
                             [0.9, 0.9]]]
        }
        TEST_GEOMETRY_C = {'type': 'Point', 'coordinates': [1, 1]}
        TEST_RADIUS = 0.003

        VALID_RESULTS_NUMBER_1 = 3
        VALID_RESULTS_NUMBER_2 = 2

        result_1 = list(
            findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER,
                       TEST_GEOMETRY_P))
        result_2 = list(
            findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER,
                       TEST_GEOMETRY_C, None, None, None, None, None, None,
                       TEST_RADIUS))

        self.assertEquals(VALID_RESULTS_NUMBER_1, len(result_1))
        self.assertEquals(VALID_RESULTS_NUMBER_2, len(result_2))
コード例 #6
0
ファイル: test_FindPoints.py プロジェクト: testmana2/geo2tag
    def testAltitudeSearch(self):
        TEST_ALT_FROM = 1
        TEST_ALT_FROM1 = 2

        TEST_ALT_TO = 2
        TEST_ALT_TO1 = 1

        VALID_RESULTS_NUMBER_1 = 4
        VALID_RESULTS_NUMBER_2 = 2
        VALID_RESULTS_NUMBER_3 = 2

        result_1 = list(
            findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER, None,
                       TEST_ALT_FROM, TEST_ALT_TO))
        result_2 = list(
            findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER, None,
                       TEST_ALT_FROM1))
        result_3 = list(
            findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER, None, None,
                       TEST_ALT_TO1))
        self.assertEquals(VALID_RESULTS_NUMBER_1, len(result_1))
        self.assertEquals(VALID_RESULTS_NUMBER_2, len(result_2))
        self.assertEquals(VALID_RESULTS_NUMBER_3, len(result_3))
コード例 #7
0
ファイル: test_FindPoints.py プロジェクト: geo2tag/geo2tag
    def testAltitudeSearch(self):
        TEST_ALT_FROM = 1
        TEST_ALT_FROM1 = 2

        TEST_ALT_TO = 2
        TEST_ALT_TO1 = 1

        VALID_RESULTS_NUMBER_1 = 4
        VALID_RESULTS_NUMBER_2 = 2
        VALID_RESULTS_NUMBER_3 = 2

        result_1 = list(
            findPoints(
                TEST_SERVICE,
                TEST_CHANNELS,
                TEST_NUMBER,
                None,
                TEST_ALT_FROM,
                TEST_ALT_TO))
        result_2 = list(
            findPoints(
                TEST_SERVICE,
                TEST_CHANNELS,
                TEST_NUMBER,
                None,
                TEST_ALT_FROM1))
        result_3 = list(
            findPoints(
                TEST_SERVICE,
                TEST_CHANNELS,
                TEST_NUMBER,
                None,
                None,
                TEST_ALT_TO1))
        self.assertEquals(VALID_RESULTS_NUMBER_1, len(result_1))
        self.assertEquals(VALID_RESULTS_NUMBER_2, len(result_2))
        self.assertEquals(VALID_RESULTS_NUMBER_3, len(result_3))
コード例 #8
0
ファイル: test_FindPoints.py プロジェクト: testmana2/geo2tag
 def testChannelSearch(self):
     VALID_RESULTS_NUMBER = 4
     result = list(findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER))
     self.assertEquals(VALID_RESULTS_NUMBER, len(result))
コード例 #9
0
ファイル: test_FindPoints.py プロジェクト: geo2tag/geo2tag
 def testChannelSearch(self):
     VALID_RESULTS_NUMBER = 4
     result = list(findPoints(TEST_SERVICE, TEST_CHANNELS, TEST_NUMBER))
     self.assertEquals(VALID_RESULTS_NUMBER, len(result))
コード例 #10
0
 def testKareliaObjectsImageUrl(self):
     result = list(findPoints(TEST_SERVICE, TEST_CHANNEL, TEST_NUMBER))
     for i in result:
         self.assertEquals(HTTP_KEYWORD_TO_TEST in i[JSON][IMAGE_URL], True)
コード例 #11
0
 def testApplydateCriterion2(self):
     TEST_DATE_FROM = dateutil.parser.parse("1000")
     TEST_DATE_TO = dateutil.parser.parse("1200")
     result_1 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_TO,
             TEST_DATE_FROM,
             None,
             None,
             True,
             False
         ))
     result_2 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_TO,
             TEST_DATE_FROM,
             None,
             None,
             True,
             True
         ))
     result_3 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_FROM,
             TEST_DATE_TO,
             None,
             None,
             False,
             False
         ))
     result_4 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             None,
             TEST_DATE_TO
         ))
     result_5 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_TO,
             None
         ))
     result_6 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             None,
             TEST_DATE_FROM,
             None,
             None,
             None,
             True
         ))
     result_7 = list(
         findPoints(
             TEST_SERVICE,
             TEST_CHANNELS,
             TEST_NUMBER,
             None,
             None,
             None,
             None,
             TEST_DATE_FROM,
             None,
             None,
             None,
             True
         ))
     self.assertEquals(len(result_1), 3)
     self.assertEquals(len(result_2), 1)
     self.assertEquals(len(result_3), 1)
     self.assertEquals(len(result_4), 4)
     self.assertEquals(len(result_5), 1)
     self.assertEquals(len(result_6), 1)
     self.assertEquals(len(result_7), 4)
コード例 #12
0
 def testKareliaObjectsImageUrl(self):
     result = list(findPoints(TEST_SERVICE, TEST_CHANNEL, TEST_NUMBER))
     for i in result:
         self.assertEquals(HTTP_KEYWORD_TO_TEST in i[JSON][IMAGE_URL], True)
コード例 #13
0
ファイル: test_GT_1740.py プロジェクト: bannerking/pbp
 def test_Dumps_Plugin_Geocoder_Points(self):
     res = findPoints(TEST_DB, channel_ids, 1000)
     self.assertEqual(res.count(), COUNT_RES)
     self.assertEqual(res[0][JSON][ADDRESS], NAME_CITY)