def test_get_tenders_list(self, mock_get_tenders):
     tid = uuid.uuid4().hex
     t_date_modified = datetime.datetime.utcnow().isoformat()
     mock_get_tenders.return_value = [{
         'id': tid,
         'dateModified': t_date_modified
     }]
     bridge = EdgeDataBridge(self.config)
     for tender_id, date_modified in bridge.get_teders_list():
         self.assertEqual(tender_id, tid)
         self.assertEqual(t_date_modified, date_modified)
    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()