Example #1
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
Example #2
0
    def get(self, serviceName=None):
        parser_dict = LogParser.parseGetParameters()
        if serviceName is None:
            serviceName = getDbName()

        return getLog(serviceName, parser_dict[NUMBER], parser_dict[OFFSET],
                      dateDeserialiser(parser_dict, DATE_FROM),
                      dateDeserialiser(parser_dict, DATE_TO))
Example #3
0
 def get(self):
     parser_dict = AdminLogParser.parseGetParameters()
     getLog(parser_dict[SERVICE],
            parser_dict[NUMBER],
            parser_dict[OFFSET],
            dateDeserialiser(
         parser_dict,
         DATE_FROM),
         dateDeserialiser(
         parser_dict,
         DATE_TO),
         parser_dict[SUBSTRING])
     return make_response(
         render_template(
             'log.html'))
Example #4
0
    def get(self, serviceName=None):
        parser_dict = LogParser.parseGetParameters()
        if serviceName is None:
            serviceName = getDbName()

        return getLog(
            serviceName,
            parser_dict[NUMBER],
            parser_dict[OFFSET],
            dateDeserialiser(
                parser_dict,
                DATE_FROM),
            dateDeserialiser(
                parser_dict,
                DATE_TO))
Example #5
0
    def testGetParser(self):
        with app.test_request_context('/?' + CORRECT_ARGS):
            args = LogParser.parseGetParameters()
            self.assertEquals(args[OFFSET], OFFSET_VALUE)
            self.assertEquals(args[NUMBER], NUMBER_VALUE)
            loadedDatetime_from = json.loads(
                args[DATE_FROM], object_hook=dateDeserialiser(
                    args, DATE_FROM))
            self.assertEquals(loadedDatetime_from, DATE_FROM_VALUE)
            loadedDatetime_to = json.loads(
                args[DATE_TO], object_hook=dateDeserialiser(
                    args, DATE_TO))
            self.assertEquals(loadedDatetime_to, DATE_TO_VALUE)

        with app.test_request_context('/?' + INCORRECT_ARGS):
            args = LogParser.parseGetParameters()
            self.assertIsNone(args.get(OFFSET))
            self.assertIsNone(args.get(NUMBER))
            self.assertIsNone(args.get(loadedDatetime_from))
            self.assertIsNone(args.get(loadedDatetime_to))
Example #6
0
    def testParserPointListGetResource(self):
        with app.test_request_context(
                '/instance/service/testservice/point/?' + CORRECT_ARGS):
            args = PointListResourceParser.parseGetParameters()
            self.assertEquals(args[OFFSET], OFFSET_VALUE)
            self.assertEquals(args[NUMBER], NUMBER_VALUE)
            loadedDatetime_from = json.loads(
                args[DATE_FROM], object_hook=dateDeserialiser(
                    args, args[DATE_FROM]))
            self.assertEquals(loadedDatetime_from, DATE_FROM_VALUE)
            loadedDatetime_to = json.loads(
                args[DATE_TO], object_hook=dateDeserialiser(
                    args, args[DATE_TO]))
            self.assertEquals(loadedDatetime_to, DATE_TO_VALUE)
            geometryValue = geo_json_type.GeoJsonType(
                unicode(args.get(GEOMETRY)))
            self.assertEquals(GEOMETRY_VALUE_JSON, geometryValue)

        with app.test_request_context(
                '/instance/service/testservice/point/?' + INCORRECT_ARGS):
            with self.assertRaises(BadRequest):
                args = PointListResourceParser.parseGetParameters()