コード例 #1
0
 def test_continuous_changes_feed(self):
     db = mock.MagicMock()
     auction_id = uuid4().hex
     lot_id = uuid4().hex
     db.changes.side_effect = [{
         'last_seq':
         1,
         'results': [{
             'doc': {
                 '_id': auction_id,
                 'merchandisingObject': lot_id
             }
         }]
     }, {
         'last_seq': 2,
         'results': []
     }]
     with mock.patch(
             'openregistry.convoy.utils.CONTINUOUS_CHANGES_FEED_FLAG',
             AlmostAlwaysTrue(2)):
         results = []
         for r in continuous_changes_feed(db, timeout=0.1):
             results.append(r)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0], {
         'merchandisingObject': lot_id,
         'id': auction_id
     })
コード例 #2
0
 def test_continuous_changes_feed(self):
     db = mock.MagicMock()
     auction_id = uuid4().hex
     lot_id = uuid4().hex
     db.changes.side_effect = [
         {'last_seq': 1, 'results': [
             {'doc': {
                      '_id': auction_id,
                      'id': auction_id,
                      'status': 'pending.verifcation',
                      'merchandisingObject': lot_id,
                      'procurementMethodType': 'rubble',
                      'contracts': [{'status': 'cancelled'}]}}
         ]},
         {'last_seq': 2, 'results': []}
     ]
     with mock.patch(
             'openregistry.convoy.utils.CONTINUOUS_CHANGES_FEED_FLAG',
             AlmostAlwaysTrue(2)):
         results = []
         for r in continuous_changes_feed(db, mock.MagicMock(), timeout=0.1):
             results.append(r)
     self.assertEqual(len(results), 1)
     self.assertEqual(results[0], {'merchandisingObject': lot_id,
                                   '_id': auction_id,
                                   'id': auction_id,
                                   'status': 'pending.verifcation',
                                   'procurementMethodType': 'rubble',
                                   'contracts': [{'status': 'cancelled'}]
                                   })
コード例 #3
0
 def run(self):
     self.transmitter = spawn(self.file_bridge)
     sleep(1)
     for auction_info in continuous_changes_feed(self.db):
         LOGGER.info('Received auction {}'.format(repr(auction_info)))
         if auction_info['status'] == 'pending.verification':
             self.prepare_auction(auction_info)
         else:
             self.report_results(auction_info)
コード例 #4
0
 def run(self):
     self.transmitter = spawn(self.file_bridge)
     sleep(1)
     LOGGER.info('Getting auctions')
     for auction in continuous_changes_feed(self.db, self.killer,
                                            self.timeout):
         self.process_auction(auction)
         if self.killer.kill_now:
             break