def testReservationDenied(self):
        data = reservationRequestWithConflicts()
        requestHandler = RequestHandler()
        response = requestHandler.postReservations(data)

        self.assertEqual(409, response.status)
        self.assertEqual('Conflict', response.reason)
Esempio n. 2
0
    def testDeconflictReservation(self):
        processedTime = datetimeAsIso8601(dt.now())

        reservationRequest = reservationRequestWithConflicts()

        availabilityList = antennaAvailability()
        for antenna in reservationRequest['contactPlan']['antennas']:
            antennaId = antenna['id']
            for contact in antenna['contacts']:
                for antenna in availabilityList['antennas']:
                    if antenna['antennaId'] == antennaId:
                        denied = False
                        for window in antenna['outOfServiceWindows']:
                            overlap = doWindowsOverlap(contact['startTime'],
                                                       contact['stopTime'],
                                                       window['startTime'],
                                                       window['stopTime'])
                            denied = denied or overlap

                        contact['status'] = ('DENIED_OUT_OF_SERVICE'
                                             if denied else 'RESERVED')
                        contact['processedTime'] = processedTime

        expectedStatusList = {
            'SkySat-A-rev1006-Fairbanks-1': 'DENIED_OUT_OF_SERVICE',
            'SkySat-B-rev2209-Fairbanks-1': 'RESERVED',
            'SkySat-A-rev1006-Fairbanks-2': 'RESERVED',
            'SkySat-B-rev2209-Fairbanks-2': 'DENIED_OUT_OF_SERVICE',
        }
        for antenna in reservationRequest['contactPlan']['antennas']:
            for contact in antenna['contacts']:
                # print  "'%s\' :  '%s'" % (contact['id'], contact['status'])
                self.assertEqual(contact['status'],
                                 expectedStatusList[contact['id']])
        pass
Esempio n. 3
0
    def testReservationDenied(self):
        data = reservationRequestWithConflicts()
        requestHandler = RequestHandler()
        response = requestHandler.postReservations(data)

        self.assertEqual(409, response.status)
        self.assertEqual('Conflict', response.reason)
    def testDeconflictReservation(self):
        processedTime = datetimeAsIso8601(dt.now())

        reservationRequest = reservationRequestWithConflicts()

        availabilityList = antennaAvailability()
        for antenna in reservationRequest['contactPlan']['antennas']:
            antennaId =  antenna['id']
            for contact in antenna['contacts']:
                for antenna in availabilityList['antennas']:
                    if antenna['antennaId'] == antennaId :
                        denied = False
                        for window in antenna['outOfServiceWindows']:
                            overlap = doWindowsOverlap(contact['startTime'], contact['stopTime'], window['startTime'], window['stopTime'])
                            denied = denied or overlap

                        contact['status'] = ('DENIED_OUT_OF_SERVICE' if denied else 'RESERVED')
                        contact['processedTime'] = processedTime

        expectedStatusList = {
            'SkySat-A-rev1006-Fairbanks-1' :  'DENIED_OUT_OF_SERVICE',
            'SkySat-B-rev2209-Fairbanks-1' :  'RESERVED',
            'SkySat-A-rev1006-Fairbanks-2' :  'RESERVED',
            'SkySat-B-rev2209-Fairbanks-2' :  'DENIED_OUT_OF_SERVICE',
        }
        for antenna in reservationRequest['contactPlan']['antennas']:
            for contact in antenna['contacts']:
                # print  "'%s\' :  '%s'" % (contact['id'], contact['status'])
                self.assertEqual(contact['status'], expectedStatusList[contact['id']])
        pass