def _revel_patch(contexture, data):
    patch = apply_data_patch(contexture.serialize(), data)
    return patch
Ejemplo n.º 2
0
 def set_status(self, status, extra=None):
     data = {'status': status}
     if status == 'active.tendering':
         data.update({
             "enquiryPeriod": {
                 "startDate": (now).isoformat(),
                 "endDate": (now + timedelta(days=1)).isoformat()
             },
             "tenderPeriod": {
                 "startDate": (now).isoformat(),
                 "endDate": (now + timedelta(days=5)).isoformat()
             }
         })
     elif status == 'active.auction':
         data.update({
             "enquiryPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now).isoformat()
             },
             "tenderPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now + timedelta(hours=1)).isoformat()
             },
             "auctionPeriod": {
                 "startDate": (now).isoformat()
             }
         })
         if self.initial_lots:
             data.update({
                 'lots': [{
                     "auctionPeriod": {
                         "startDate": (now).isoformat()
                     }
                 } for i in self.initial_lots]
             })
     elif status == 'active.qualification':
         data.update({
             "enquiryPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now - timedelta(days=13)).isoformat()
             },
             "tenderPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now - timedelta(days=1)).isoformat()
             },
             "auctionPeriod": {
                 "startDate": (now - timedelta(days=2)).isoformat(),
                 "endDate": (now).isoformat()
             },
             "awardPeriod": {
                 "startDate": (now).isoformat()
             }
         })
         if self.initial_lots:
             data.update({
                 'lots': [{
                     "auctionPeriod": {
                         "startDate": (now - timedelta(days=1)).isoformat(),
                         "endDate": (now).isoformat()
                     }
                 } for i in self.initial_lots]
             })
     elif status == 'active.awarded':
         data.update({
             "enquiryPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now - timedelta(days=13)).isoformat()
             },
             "tenderPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now - timedelta(days=11)).isoformat()
             },
             "auctionPeriod": {
                 "startDate": (now - timedelta(days=12)).isoformat(),
                 "endDate": (now - timedelta(days=10)).isoformat()
             },
             "awardPeriod": {
                 "startDate": (now - timedelta(days=10)).isoformat(),
                 "endDate": (now).isoformat()
             }
         })
         if self.initial_lots:
             data.update({
                 'lots': [{
                     "auctionPeriod": {
                         "startDate": (now - timedelta(days=1)).isoformat(),
                         "endDate": (now).isoformat()
                     }
                 } for i in self.initial_lots]
             })
     elif status == 'complete':
         data.update({
             "enquiryPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now - timedelta(days=13)).isoformat()
             },
             "tenderPeriod": {
                 "startDate": (now - timedelta(days=20)).isoformat(),
                 "endDate": (now - timedelta(days=13)).isoformat()
             },
             "auctionPeriod": {
                 "startDate": (now - timedelta(days=11)).isoformat(),
                 "endDate": (now - timedelta(days=10)).isoformat()
             },
             "awardPeriod": {
                 "startDate": (now - timedelta(days=10)).isoformat(),
                 "endDate": (now - timedelta(days=10)).isoformat()
             }
         })
         if self.initial_lots:
             data.update({
                 'lots': [{
                     "auctionPeriod": {
                         "startDate":
                         (now - timedelta(days=11)).isoformat(),
                         "endDate": (now - timedelta(days=10)).isoformat()
                     }
                 } for i in self.initial_lots]
             })
     if extra:
         data.update(extra)
     auction = self.db.get(self.auction_id)
     auction.update(apply_data_patch(auction, data))
     self.db.save(auction)
     authorization = self.app.authorization
     self.app.authorization = ('Basic', ('chronograph', ''))
     #response = self.app.patch_json('/auctions/{}'.format(self.auction_id), {'data': {'id': self.auction_id}})
     response = self.app.get('/auctions/{}'.format(self.auction_id))
     self.app.authorization = authorization
     self.assertEqual(response.status, '200 OK')
     self.assertEqual(response.content_type, 'application/json')
     return response
Ejemplo n.º 3
0
 def _db_save(self, context):
     auction = self._test.db.get(self.auction['id'])
     auction.update(apply_data_patch(auction, context))
     self._test.db.save(auction)
     return auction