コード例 #1
0
    def testPattern(self):
        schema = {
            "type": "object",
            "properties": {
                "line1": {
                    "type": "string",
                    "pattern": "^1"
                }
            }
        }
        validateWithChecker(
            {
                "line1":
                "1 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0  9996"
            }, schema)

        try:
            validateWithChecker(
                {
                    "line1":
                    "2 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0  9996"
                }, schema)
        except ValidationError as e:
            print "testPattern: %s" % e.message
            pass
コード例 #2
0
    def testFixedLengthString(self):
        schema = {
            "type": "object",
            "properties": {
                "line1": {
                    "type": "string",
                    "minLength": 69,
                    "maxLength": 69
                }
            }
        }

        validateWithChecker(
            {
                "line1":
                "1 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0  9996"
            }, schema)

        try:
            validateWithChecker(
                {
                    "line1":
                    "1 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0"
                }, schema)  # shortened
        except ValidationError as e:
            print "testValidateWithinRange %s" % e.message
            pass
コード例 #3
0
 def testValidateDateTime(self):
     schema = {
         "type": "object",
         "properties": {
             "price": {
                 "type": "number"
             },
             "name": {
                 "type": "string"
             },
             "expirationDate": {
                 "type": "string",
                 "format": "date-time"
             }
         }
     }
     try:
         validateWithChecker(
             {
                 "name": "Eggs",
                 "price": 34.99,
                 "expirationDate": "xxx"
             }, schema)
     except ValidationError as e:
         print e.message
         pass
コード例 #4
0
    def testPostReservations(self):
        data = reservationRequest()
        requestHandler = RequestHandler()
        response = requestHandler.postReservations(data)

        self.assertEqual(201, response.status)
        self.assertEqual('Created', response.reason)

        responseSchema = loadReservationResponseSchema()
        validateWithChecker(response.body, responseSchema)
コード例 #5
0
    def testPostReservations(self):
        data = reservationRequest()
        requestHandler = RequestHandler()
        response = requestHandler.postReservations(data)

        self.assertEqual(201, response.status)
        self.assertEqual('Created', response.reason)

        responseSchema = loadReservationResponseSchema()
        validateWithChecker(response.body, responseSchema)
コード例 #6
0
 def testValidateDateFormat(self):
     schema = loadSchemaFor("ReservationRequest")
     request = reservationRequest()
     request['availabilityReportDate'] = "xyz"
     try:
         validateWithChecker(request, schema)
         self.fail()
     except ValidationError as e:
         print e.message
         pass
コード例 #7
0
 def testValidateDateFormat(self):
     schema = loadSchemaFor("ReservationRequest")
     request = reservationRequest()
     request['availabilityReportDate'] = "xyz"
     try:
         validateWithChecker(request, schema)
         self.fail()
     except ValidationError as e:
         print e.message
         pass
コード例 #8
0
    def testGetAntennaAvailability(self):
        requestHandler = RequestHandler()

        startDate = '2015-10-16T10:00:00Z'
        endDate = '2015-10-17T10:00:00Z'

        response = requestHandler.getAntennaAvailability(startDate, endDate)

        self.assertEqual(200, response.status)
        self.assertEqual('OK', response.reason)

        responseSchema = loadAntennaAvailabilitySchema()
        validateWithChecker(response.body, responseSchema)
コード例 #9
0
    def testGetAntennaAvailability(self):
        requestHandler = RequestHandler()

        startDate =  '2015-10-16T10:00:00Z'
        endDate =  '2015-10-17T10:00:00Z'

        response = requestHandler.getAntennaAvailability(startDate, endDate)

        self.assertEqual(200, response.status)
        self.assertEqual('OK', response.reason)

        responseSchema = loadAntennaAvailabilitySchema()
        validateWithChecker(response.body, responseSchema)
コード例 #10
0
    def testValidateWithinRange(self):
        schema = {
            "type": "object",
            "properties": {
                "azimuth": {
                    "type": "number",
                    "format": "float",
                    "minimum": 0.0,
                    "maximum": 360,
                    "exclusiveMaximum": True
                }
            }
        }
        validateWithChecker({"azimuth": 0.1}, schema)
        validateWithChecker({"azimuth": 359.9999}, schema)

        try:
            validateWithChecker({"azimuth": 360}, schema)
        except ValidationError as e:
            print e.message
            pass

        try:
            validateWithChecker({"azimuth": -0.1}, schema)
        except ValidationError as e:
            print "testValidateWithinRange: %s" % e.message
            pass
コード例 #11
0
    def testValidateBelowMaximum(self):
        schema = {
            "type": "object",
            "properties": {
                "latitude": {
                    "type": "number",
                    "format": "float",
                    "minimum": -180,
                    "maximum": 180,
                    "exclusiveMinimum": True,
                    "exclusiveMaximum": True
                }
            }
        }
        validateWithChecker({"latitude": -179.999}, schema)
        validateWithChecker({"latitude": 179.9999}, schema)

        try:
            validateWithChecker({"latitude": 180}, schema)
        except ValidationError as e:
            print e.message
            pass

        try:
            validateWithChecker({"latitude": -180}, schema)
        except ValidationError as e:
            print "testValidateBelowMaximum: %s" % e.message
            pass
コード例 #12
0
    def testMinLengthString(self):
        schema = {
            "type": "object",
            "properties": {
                "name": {"type": "string", "minLength": 1}
            }
        }
        validateWithChecker({"name": "SkySat-1"}, schema)

        try:
            validateWithChecker({"name": ""}, schema)
        except ValidationError as e:
            print "testMinLenghtString %s" % e.message
            pass
コード例 #13
0
 def testValidateDateTime(self):
     schema = {
         "type": "object",
         "properties": {
             "price": {"type": "number"},
             "name": {"type": "string"},
             "expirationDate": {"type": "string", "format": "date-time"}
         }
     }
     try:
         validateWithChecker({"name": "Eggs", "price": 34.99, "expirationDate": "xxx"}, schema)
     except ValidationError as e:
         print e.message
         pass
コード例 #14
0
    def testFixedLengthString(self):
        schema = {
            "type": "object",
            "properties": {
                "line1": {"type": "string", "minLength": 69, "maxLength": 69}
            }
        }

        validateWithChecker({"line1": "1 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0  9996"}, schema)

        try:
            validateWithChecker({"line1": "1 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0"}, schema)  # shortened
        except ValidationError as e:
            print "testValidateWithinRange %s" %e.message
            pass
コード例 #15
0
    def testPattern(self):
        schema = {
            "type": "object",
            "properties": {
                "line1": {"type": "string",
                          "pattern": "^1"
                          }
            }
        }
        validateWithChecker({"line1": "1 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0  9996"}, schema)

        try:
            validateWithChecker({"line1": "2 39418U 13066C   15041.51375279  .00003665  00000-0  32287-3 0  9996"}, schema)
        except ValidationError as e:
            print  "testPattern: %s" % e.message
            pass
コード例 #16
0
    def testValidateContactResponse(self):
        schema = loadSchemaFor("Contact")
        requiredList = schema['definitions']['Contact']['required']
        requiredList.append("status")
        requiredList.append("processedTime")

        processedTime = datetimeAsIso8601(dt.now())
        data = {
            "id":"SkySat-A-rev1006-Fairbanks-1",
            "satelliteName":"SkySat-1",
            "startTime": "2014-10-10T07:28:20.000Z",
            "stopTime": "2014-10-10T07:29:20.000Z",
            "status" : "RESERVED",
            "processedTime" : processedTime
        }
        validateWithChecker(data, schema)
コード例 #17
0
    def testValidateContactResponse(self):
        schema = loadSchemaFor("Contact")
        requiredList = schema['definitions']['Contact']['required']
        requiredList.append("status")
        requiredList.append("processedTime")

        processedTime = datetimeAsIso8601(dt.now())
        data = {
            "id": "SkySat-A-rev1006-Fairbanks-1",
            "satelliteName": "SkySat-1",
            "startTime": "2014-10-10T07:28:20.000Z",
            "stopTime": "2014-10-10T07:29:20.000Z",
            "status": "RESERVED",
            "processedTime": processedTime
        }
        validateWithChecker(data, schema)
コード例 #18
0
    def testMinLengthString(self):
        schema = {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "minLength": 1
                }
            }
        }
        validateWithChecker({"name": "SkySat-1"}, schema)

        try:
            validateWithChecker({"name": ""}, schema)
        except ValidationError as e:
            print "testMinLenghtString %s" % e.message
            pass
コード例 #19
0
    def testReservationWorkflow(self):
# - Set Antenna Availabilty: this is testing step only
        from datetime import datetime as dt
        from TimeUtils import datetimeAsIso8601

        data = antennaAvailability()
        data['generationDate'] = datetimeAsIso8601(dt.now())
        requestHandler = RequestHandler()
        response = requestHandler.postAntennaAvailability(data)
        self.assertEqual(201, response.status)

        startDate =  '2015-10-16T10:00:00Z'
        endDate =  '2015-10-17T10:00:00Z'

        response = requestHandler.getAntennaAvailability(startDate, endDate)

        self.assertEqual(200, response.status)
        self.assertEqual('OK', response.reason)

# - Get Antenna Availabilty: this begins every reservation cycle
        startDate =  '2015-10-16T10:00:00Z'
        endDate =  '2015-10-17T10:00:00Z'

        response = requestHandler.getAntennaAvailability(startDate, endDate)
        # TODO capture generation date from availability report

        self.assertEqual(200, response.status)
        self.assertEqual('OK', response.reason)
        responseSchema = loadAntennaAvailabilitySchema()
        validateWithChecker(response.body, responseSchema)

# - Update (POST) reservations.
        data = reservationRequest()
        # TODO consider: do we inject the date form our antenna avail report at this point? Or let service do that
        # TODO update generation date in reservation request before posting
        requestHandler = RequestHandler()
        response = requestHandler.postReservations(data)

        self.assertEqual(201, response.status)
        self.assertEqual('Created', response.reason)
        # TODO assert expected generation date in response

        responseSchema = loadReservationResponseSchema()
        validateWithChecker(response.body, responseSchema)
コード例 #20
0
    def testReservationWorkflow(self):
        # - Set Antenna Availabilty: this is testing step only
        from datetime import datetime as dt
        from TimeUtils import datetimeAsIso8601

        data = antennaAvailability()
        data['generationDate'] = datetimeAsIso8601(dt.now())
        requestHandler = RequestHandler()
        response = requestHandler.postAntennaAvailability(data)
        self.assertEqual(201, response.status)

        startDate = '2015-10-16T10:00:00Z'
        endDate = '2015-10-17T10:00:00Z'

        response = requestHandler.getAntennaAvailability(startDate, endDate)

        self.assertEqual(200, response.status)
        self.assertEqual('OK', response.reason)

        # - Get Antenna Availabilty: this begins every reservation cycle
        startDate = '2015-10-16T10:00:00Z'
        endDate = '2015-10-17T10:00:00Z'

        response = requestHandler.getAntennaAvailability(startDate, endDate)
        # TODO capture generation date from availability report

        self.assertEqual(200, response.status)
        self.assertEqual('OK', response.reason)
        responseSchema = loadAntennaAvailabilitySchema()
        validateWithChecker(response.body, responseSchema)

        # - Update (POST) reservations.
        data = reservationRequest()
        # TODO consider: do we inject the date form our antenna avail report at this point? Or let service do that
        # TODO update generation date in reservation request before posting
        requestHandler = RequestHandler()
        response = requestHandler.postReservations(data)

        self.assertEqual(201, response.status)
        self.assertEqual('Created', response.reason)
        # TODO assert expected generation date in response

        responseSchema = loadReservationResponseSchema()
        validateWithChecker(response.body, responseSchema)
コード例 #21
0
    def testValidateMinArraySize(self):
        schema = {
            "type": "object",
            "properties": {
                "tags": {
                    "type": "array",
                    "items": {
                        "type": "number"
                    },
                    "minItems": 1
                }
            },
            "required": ["tags"]
        }

        validateWithChecker({"tags": [
            1,
        ]}, schema)
        validateWithChecker({"tags": [1, 2]}, schema)

        try:
            validateWithChecker({"tags": []}, schema)
        except ValidationError as e:
            print "testValidateMinArraySize: %s" % e.message
            pass
コード例 #22
0
    def testValidateWithinRange(self):
        schema = {
            "type": "object",
            "properties": {
                "azimuth": {"type": "number", "format": "float", "minimum": 0.0, "maximum": 360,
                            "exclusiveMaximum": True}
            }
        }
        validateWithChecker({"azimuth": 0.1}, schema)
        validateWithChecker({"azimuth": 359.9999}, schema)

        try:
            validateWithChecker({"azimuth": 360}, schema)
        except ValidationError as e:
            print e.message
            pass

        try:
            validateWithChecker({"azimuth": -0.1}, schema)
        except ValidationError as e:
            print "testValidateWithinRange: %s" % e.message
            pass
コード例 #23
0
    def testValidateBelowMaximum(self):
        schema = {
            "type": "object",
            "properties": {
                "latitude": {"type": "number", "format": "float", "minimum": -180, "maximum": 180,
                             "exclusiveMinimum": True, "exclusiveMaximum": True}
            }
        }
        validateWithChecker({"latitude": -179.999}, schema)
        validateWithChecker({"latitude": 179.9999}, schema)

        try:
            validateWithChecker({"latitude": 180}, schema)
        except ValidationError as e:
            print e.message
            pass

        try:
            validateWithChecker({"latitude": -180}, schema)
        except ValidationError as e:
            print "testValidateBelowMaximum: %s" % e.message
            pass
コード例 #24
0
    def testValidateMinArraySize(self):
        schema = {
            "type": "object",
            "properties": {
                "tags": {
                    "type": "array",
                    "items": {
                        "type": "number"
                    },
                    "minItems": 1
                }
            },
            "required" : ["tags"]

        }

        validateWithChecker({"tags": [1,]}, schema)
        validateWithChecker({"tags": [1,2]}, schema)

        try:
            validateWithChecker({"tags": []}, schema)
        except ValidationError as e:
            print  "testValidateMinArraySize: %s" % e.message
            pass
コード例 #25
0
 def testValidateReservationRequest(self):
     schema = loadSchemaFor("ReservationRequest")
     request = reservationRequest()
     validateWithChecker(request, schema)
コード例 #26
0
 def testValidateReservationResponse(self):
     response = reservationResponse()
     responseSchema = loadReservationResponseSchema()
     validateWithChecker(response, responseSchema)
コード例 #27
0
 def testValidateReservationResponse(self):
     response = reservationResponse()
     responseSchema = loadReservationResponseSchema()
     validateWithChecker(response, responseSchema)
コード例 #28
0
 def testValidateReservationRequest(self):
     schema = loadSchemaFor("ReservationRequest")
     request = reservationRequest()
     validateWithChecker(request, schema)