Пример #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
     })
 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)
 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