Exemplo n.º 1
0
 def test_run(self, mock_gevent, mock_perfomance, mock_controller,
              mock_fill, mock_fill_input_queue):
     bridge = EdgeDataBridge(self.config)
     self.assertEqual(len(bridge.filter_workers_pool), 0)
     with patch('__builtin__.True', AlmostAlwaysTrue(4)):
         bridge.run()
     self.assertEqual(mock_fill.call_count, 1)
     self.assertEqual(mock_controller.call_count, 1)
     self.assertEqual(mock_gevent.call_count, 1)
     self.assertEqual(mock_fill_input_queue.call_count, 1)
Exemplo n.º 2
0
    def test_run(self):
        log_string = io.BytesIO()
        stream_handler = logging.StreamHandler(log_string)
        logger.addHandler(stream_handler)

        bridge = EdgeDataBridge(self.config)
        mock_tender = {'data': test_tender_data}
        bridge.client.get_tender = MagicMock(return_value=mock_tender)
        tid = uuid.uuid4().hex
        t_date_modified = datetime.datetime.utcnow().isoformat()
        mock_tender['data']['dateModified'] = t_date_modified
        bridge.save_tender_in_db(tid, t_date_modified)
        bridge.get_teders_list = MagicMock(
            return_value=[[tid, datetime.datetime.utcnow().isoformat()]])
        bridge.run()
        x = log_string.getvalue().split('\n')
        self.assertEqual(x[2], 'Start Edge Bridge')
        self.assertEqual(x[3], 'Start data sync...')
        del_tender = bridge.db.get(tid)
        bridge.db.delete(del_tender)

        logger.removeHandler(stream_handler)
        log_string.close()