示例#1
0
    def test_setup_logging_to_stderr(self):
        self.logger.addHandler(mox.IsA(logging.StreamHandler))
        self.logger.setLevel(logging.ERROR)
        self.logger.info('Starting Altai API service v%s', mox.IsA(str))

        self.mox.ReplayAll()
        self.app.config['LOG_LEVEL'] = 'ERROR'
        main.setup_logging(self.app)
示例#2
0
    def test_setup_logging_to_stderr(self):
        self.logger.addHandler(mox.IsA(logging.StreamHandler))
        self.logger.setLevel(logging.ERROR)
        self.logger.info('Starting Altai API service v%s', mox.IsA(str))

        self.mox.ReplayAll()
        self.app.config['LOG_LEVEL'] = 'ERROR'
        main.setup_logging(self.app)
示例#3
0
    def test_setup_logging_bad_level(self):
        self.logger.addHandler(mox.IsA(logging.StreamHandler))
        self.logger.setLevel(logging.INFO)
        self.logger.critical(mox.IsA(str), 'BAD LEVEL')
        self.logger.info('Starting Altai API service v%s', mox.IsA(str))

        self.mox.ReplayAll()
        self.app.config['LOG_LEVEL'] = 'BAD LEVEL'
        main.setup_logging(self.app)
示例#4
0
    def test_setup_logging_bad_level(self):
        self.logger.addHandler(mox.IsA(logging.StreamHandler))
        self.logger.setLevel(logging.INFO)
        self.logger.critical(mox.IsA(str), 'BAD LEVEL')
        self.logger.info('Starting Altai API service v%s', mox.IsA(str))

        self.mox.ReplayAll()
        self.app.config['LOG_LEVEL'] = 'BAD LEVEL'
        main.setup_logging(self.app)
示例#5
0
    def test_setup_logging_to_file(self):

        self.logger.addHandler(mox.IsA(logging.handlers.WatchedFileHandler))
        self.logger.setLevel(logging.DEBUG)
        self.logger.info('Starting Altai API service v%s', mox.IsA(str))

        self.mox.ReplayAll()
        self.app.config['LOG_FILE_NAME'] = '/dev/null'
        main.setup_logging(self.app)
示例#6
0
    def test_setup_logging_to_file(self):

        self.logger.addHandler(mox.IsA(
            logging.handlers.WatchedFileHandler))
        self.logger.setLevel(logging.DEBUG)
        self.logger.info('Starting Altai API service v%s', mox.IsA(str))

        self.mox.ReplayAll()
        self.app.config['LOG_FILE_NAME'] = '/dev/null'
        main.setup_logging(self.app)
示例#7
0
    def test_main_works(self):
        main.make_app().AndReturn(self.fake_app)
        jobs = [self.mox.CreateMock(PeriodicJob),
                 self.mox.CreateMock(PeriodicJob)]

        main.setup_logging(self.fake_app)
        main.check_connection(self.fake_app).AndReturn(True)
        main.instances_jobs.jobs_factory(self.fake_app).AndReturn(jobs)
        self.fake_app.run(use_reloader=False,
                          host='127.0.0.1', port=42)
        jobs[0].cancel().AndRaise(RuntimeError('ignore me'))
        jobs[1].cancel()
        self.mox.ReplayAll()
        main.main()
示例#8
0
    def test_main_works(self):
        main.make_app().AndReturn(self.fake_app)
        jobs = [
            self.mox.CreateMock(PeriodicJob),
            self.mox.CreateMock(PeriodicJob)
        ]

        main.setup_logging(self.fake_app)
        main.check_connection(self.fake_app).AndReturn(True)
        main.instances_jobs.jobs_factory(self.fake_app).AndReturn(jobs)
        self.fake_app.run(use_reloader=False, host='127.0.0.1', port=42)
        jobs[0].cancel().AndRaise(RuntimeError('ignore me'))
        jobs[1].cancel()
        self.mox.ReplayAll()
        main.main()
示例#9
0
 def test_main_check_failed(self):
     main.make_app().AndReturn(self.fake_app)
     main.setup_logging(self.fake_app)
     main.check_connection(self.fake_app).AndReturn(False)
     self.mox.ReplayAll()
     self.assertRaises(SystemExit, main.main)
示例#10
0
 def test_main_check_failed(self):
     main.make_app().AndReturn(self.fake_app)
     main.setup_logging(self.fake_app)
     main.check_connection(self.fake_app).AndReturn(False)
     self.mox.ReplayAll()
     self.assertRaises(SystemExit, main.main)