コード例 #1
0
 def test_worker_award_with_cancelled_lot(self, gevent_sleep):
     gevent_sleep.side_effect = custom_sleep
     self.client.request.return_value = ResponseMock({'X-Request-ID': self.request_ids[0]},
                                                     munchify({'prev_page': {'offset': '123'},
                                                               'next_page': {'offset': '1234'},
                                                               'data': {'status': "active.pre-qualification",
                                                                        'id': self.tender_id,
                                                                        'procurementMethodType': 'aboveThresholdEU',
                                                                        'lots': [{'status': 'cancelled',
                                                                                  'id': '123456789'},
                                                                                 {'status': 'active',
                                                                                  'id': '12345678'}],
                                                                        'awards': [{'id': self.award_ids[0],
                                                                                    'bid_id': self.bid_ids[0],
                                                                                    'status': 'pending',
                                                                                    'suppliers': [{'identifier': {
                                                                                        'scheme': 'UA-EDR',
                                                                                        'id': CODES[0]}}],
                                                                                    'lotID': '123456789'},
                                                                                   {'id': self.award_ids[1],
                                                                                    'bid_id': self.bid_ids[1],
                                                                                    'status': 'pending',
                                                                                    'suppliers': [{'identifier': {
                                                                                        'scheme': 'UA-EDR',
                                                                                        'id': CODES[1]}}],
                                                                                    'lotID': '12345678'}]}}))
     data = Data(self.tender_id, self.award_ids[1], CODES[1], 'awards',
                 {'meta': {'sourceRequests': [self.request_ids[0]]}})
     for edrpou in [data]:
         self.check_data_objects(self.edrpou_codes_queue.get(), edrpou)
     self.assertItemsEqual(self.process_tracker.processing_items.keys(),
                           [item_key(self.tender_id, self.award_ids[1])])
コード例 #2
0
 def test_worker_award(self, gevent_sleep):
     gevent_sleep.side_effect = custom_sleep
     self.client.request.side_effect = [ResponseMock({'X-Request-ID': self.request_ids[0]},
                                                     munchify({'prev_page': {'offset': '123'},
                                                               'next_page': {'offset': '1234'},
                                                               'data': {'status': "active.pre-qualification",
                                                                        'id': self.tender_id,
                                                                        'procurementMethodType': 'aboveThresholdEU',
                                                                        'awards': [
                                                                            self.awards(0, 0, 'pending', CODES[0]),
                                                                            self.awards(1, 1, 'pending', CODES[1]),
                                                                            self.awards(2, 2, 'pending', CODES[2]),
                                                                            self.awards(3, 3, 'unsuccessful',
                                                                                        CODES[2]),
                                                                            {'id': self.bid_ids[4],
                                                                             'tenderers': [{'identifier': {
                                                                                 'scheme': 'UA-ED',
                                                                                 'id': CODES[2]}}]}]}}))]
     for i in range(3):
         data = Data(self.tender_id, self.award_ids[i], CODES[i], 'awards',
                     {'meta': {'sourceRequests': [self.request_ids[0]]}})
         self.check_data_objects(self.edrpou_codes_queue.get(), data)
     self.assertItemsEqual(self.process_tracker.processing_items.keys(),
                           [item_key(self.tender_id, self.award_ids[0]), item_key(self.tender_id, self.award_ids[1]),
                            item_key(self.tender_id, self.award_ids[2])])
コード例 #3
0
 def test_request_failed(self, gevent_sleep):
     gevent_sleep.side_effect = custom_sleep
     self.client.request.side_effect = [RequestFailed(http_code=401, msg=RequestFailed()),
                                        ResponseMock({'X-Request-ID': self.request_ids[0]},
                                                     munchify({'prev_page': {'offset': '123'},
                                                               'next_page': {'offset': '1234'},
                                                               'data': {'status': "active.pre-qualification",
                                                                        'id': self.tender_id,
                                                                        'procurementMethodType': 'aboveThresholdEU',
                                                                        'awards': [
                                                                            self.awards(0, 0, 'pending', '')]}}))]
     sleep(1)
     self.assertEqual(self.client.request.call_count, 2)
     self.assertEqual(self.edrpou_codes_queue.qsize(), 0)
     self.assertItemsEqual(self.process_tracker.processing_items, {})
コード例 #4
0
 def test_award_not_valid_identifier_id(self, gevent_sleep):
     gevent_sleep.side_effect = custom_sleep
     self.client.request.return_value = ResponseMock({'X-Request-ID': self.request_ids[0]},
                                                     munchify({'prev_page': {'offset': '123'},
                                                               'next_page': {'offset': '1234'},
                                                               'data': {'status': "active.pre-qualification",
                                                                        'id': self.tender_id,
                                                                        'procurementMethodType': 'aboveThresholdEU',
                                                                        'awards': [self.awards(0, 0, 'pending', ''),
                                                                                   self.awards(0, 0, 'pending',
                                                                                               u'абв'),
                                                                                   self.awards(0, 1, 'pending',
                                                                                               'абв'),
                                                                                   self.awards(1, 1, 'pending',
                                                                                               '*****@*****.**')]}}))
     sleep(1)
     self.assertEqual(self.edrpou_codes_queue.qsize(), 0)
     self.assertItemsEqual(self.process_tracker.processing_items, {})
コード例 #5
0
 def test_worker_dead(self, gevent_sleep):
     """ Test that worker will process tender after exception  """
     gevent_sleep.side_effect = custom_sleep
     self.filtered_tender_ids_queue.put(self.tender_id)
     self.client.request.side_effect = [
         ResponseMock({'X-Request-ID': self.request_ids[i]},
                      munchify({'prev_page': {'offset': '123'},
                                'next_page': {'offset': '1234'},
                                'data': {
                                    'status': "active.pre-qualification",
                                    'id': self.tender_id,
                                    'procurementMethodType': 'aboveThresholdEU',
                                    'awards': [self.awards(i, i, 'pending', CODES[0])]}})) for i in range(2)]
     for i in range(2):
         data = Data(self.tender_id, self.award_ids[i], CODES[0], 'awards',
                     {'meta': {'sourceRequests': [self.request_ids[i]]}})
         self.check_data_objects(self.edrpou_codes_queue.get(), data)
     self.worker.immortal_jobs['prepare_data'].kill(timeout=1)
     self.assertItemsEqual(self.process_tracker.processing_items.keys(),
                           [item_key(self.tender_id, self.award_ids[i]) for i in range(2)])
コード例 #6
0
 def test_worker_restart(self, gevent_sleep):
     """ Process tender after catch Unauthorized exception """
     gevent_sleep.side_effect = custom_sleep
     self.client.request.side_effect = [
         Unauthorized(http_code=403),
         Unauthorized(http_code=403),
         Unauthorized(http_code=403),
         ResponseMock({'X-Request-ID': self.request_ids[0]},
                      munchify({'prev_page': {'offset': '123'},
                                'next_page': {'offset': '1234'},
                                'data': {'status': "active.pre-qualification",
                                         'id': self.tender_id,
                                         'procurementMethodType': 'aboveThresholdEU',
                                         'awards': [self.awards(0, 0, 'pending', CODES[0]),
                                                    self.awards(1, 1, 'unsuccessful', CODES[2])]}}))]
     data = Data(self.tender_id, self.award_ids[0], CODES[0], 'awards',
                 {'meta': {'sourceRequests': [self.request_ids[0]]}})
     self.check_data_objects(self.edrpou_codes_queue.get(), data)
     self.assertItemsEqual(self.process_tracker.processing_items.keys(),
                           [item_key(self.tender_id, self.award_ids[0])])
コード例 #7
0
 def setUp(self):
     self.filtered_tender_ids_queue = Queue(10)
     self.edrpou_codes_queue = Queue(10)
     self.db = Db(config)
     self.process_tracker = ProcessTracker(self.db)
     self.tender_id = uuid.uuid4().hex
     self.filtered_tender_ids_queue.put(self.tender_id)
     self.sleep_change_value = APIRateController()
     self.client = MagicMock()
     self.sna = event.Event()
     self.sna.set()
     self.worker = FilterTenders.spawn(self.client, self.filtered_tender_ids_queue, self.edrpou_codes_queue,
                                       self.process_tracker, self.sna, self.sleep_change_value)
     self.bid_ids = [uuid.uuid4().hex for _ in range(5)]
     self.qualification_ids = [uuid.uuid4().hex for _ in range(5)]
     self.award_ids = [uuid.uuid4().hex for _ in range(5)]
     self.request_ids = [generate_request_id() for _ in range(2)]
     self.response = ResponseMock({'X-Request-ID': self.request_ids[0]},
                                  munchify({'prev_page': {'offset': '123'},
                                            'next_page': {'offset': '1234'},
                                            'data': {'status': "active.pre-qualification",
                                                     'id': self.tender_id,
                                                     'procurementMethodType': 'aboveThresholdEU',
                                                     'awards': [self.awards(0, 0, 'pending', CODES[0])]}}))