Example #1
0
    def setUp(self):
        super(TestUtils, self).setUp()
        setting = Setting()
        setting.initialize(os.path.join(current_dir, 'settings.cfg'))

        conn = Connection()
        conn.connect(setting.config)

        # initialize logger
        Logger.init(**setting.config.twisted.logging)

        # Redis 초기화
        self.redis = conn.redis
        self.redis.delete('current_post_id')
    def setUp(self):
        super(TestPostImpl, self).setUp()
        setting = Setting()
        setting.initialize(os.path.join(current_dir, 'settings.cfg'))

        conn = Connection()
        conn.connect(setting.config)

        # initialize logger
        Logger.init(**setting.config.twisted.logging)

        Post.drop_collection()

        # Redis 초기화
        self.redis = conn.redis
        self.redis.delete('current_post_id')

        self.fake = Factory.create()
    def __getattr__(self, item):
        Logger.info(item)
        item = re.split('_', item)
        module_name, mthd = item[0], '_'.join(item[1:])

        class_name = module_name.capitalize() + 'Controller'

        module = __import__('controllers.%s' % module_name)
        instance = getattr(getattr(module, module_name), class_name)()

        return getattr(instance, mthd)


if __name__ == '__main__':
    setting = Setting()
    setting.initialize(os.path.join(current_dir, 'settings.cfg'))

    conn = Connection()
    conn.connect(setting.config)

    # initialize logger
    Logger.init(**setting.config.twisted.logging)

    # setup server
    handler = TodayInternalApiServiceHandler()
    processor = TodayInternalApiService.Processor(handler)
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()
    server = reactor.listenTCP(setting.config.twisted.port,
                               TTwisted.ThriftServerFactory(processor, pfactory),
                               interface=setting.config.twisted.interface)