Пример #1
0
def save_test_data(file_numbers=500, sleep_time=30):
    logging.basicConfig(
        format=
        '%(asctime)s - %(levelname)s [%(filename)s:%(lineno)s %(funcName)20s] %(message)s',
        level=logging.INFO,
        handlers=[logging.StreamHandler()])

    logger = logging.getLogger(__name__)

    if not Path('test_data').is_dir():
        Path('test_data').mkdir()

    cds = CdsDBDataProvider(logger)
    logger.info("Start")
    for i in range(file_numbers):
        codd_data_db = cds.load_all_cds_buses()
        now = datetime.datetime.now()
        with open(f'test_data/codd_data_db{now:%y_%m_%d_%H_%M_%S}.json',
                  'wb') as f:
            json.dump(codd_data_db,
                      codecs.getwriter('utf-8')(f),
                      ensure_ascii=False,
                      indent=1,
                      cls=CustomJsonEncoder)
        time.sleep(sleep_time)

    logger.info("Stop")
Пример #2
0
    def __init__(self, *args, **kwargs):
        super(CdsSpeedTestCase, self).__init__(*args, **kwargs)
        logging.basicConfig(format='%(asctime)s - %(levelname)s [%(filename)s:%(lineno)s %(funcName)20s] %(message)s',
                            level=logging.INFO,
                            handlers=[logging.StreamHandler()])

        logger = logging.getLogger("vrnbus")
        self.mock_provider = CdsDBDataProvider(logger)
        self.cds = CdsRequest(logger, self.mock_provider)
Пример #3
0
 def test_db(self):
     self.db_provider = CdsDBDataProvider(logger)
     cds = CdsRequest(logger, self.db_provider)
     self.call_common_methods(cds)
Пример #4
0
    format=
    '%(asctime)s.%(msecs)03d - %(levelname)s [%(filename)s:%(lineno)s %(funcName)10s] %(message)s',
    datefmt="%H:%M:%S",
    level=logging.INFO,
    handlers=[logging.StreamHandler(), file_handler])

logger = logging.getLogger("vrnbus")

logger.info([{k: os.environ[k]} for (k) in os.environ if 'PATH' not in k])

LOAD_TEST_DATA = False

try:
    import settings
    LOAD_TEST_DATA = settings.LOAD_TEST_DATA
except ImportError:
    settings = None

user_settings = {}

if __name__ == "__main__":
    tracker = EventTracker(logger)
    data_provider = CdsTestDataProvider(
        logger) if LOAD_TEST_DATA else CdsDBDataProvider(logger)
    cds = CdsRequest(logger, data_provider)
    data_processor = WebDataProcessor(cds, logger)
    bot = BusBot(cds, user_settings, logger, tracker)
    application = BusSite(data_processor, logger, tracker)
    application.listen(os.environ.get('PORT', 8080))
    tornado.ioloop.IOLoop.instance().start()
Пример #5
0
 def __init__(self, *args, **kwargs):
     super(CdsDataGatheringTestCase, self).__init__(*args, **kwargs)
     self.mock_provider = CdsTestDataProvider(logger)
     self.db_provider = CdsDBDataProvider(logger)