def cmd(botPath): conf = path_import('ringcentral_bot_framework.localConfig', botPath) framework = frameworkInit(conf, _.get(conf, 'extensions')) app = Flask('devtest') @app.route('/test', methods=['GET']) def index(): return 'RingCentral bot dev server running' @app.route('/favicon.ico', methods=['GET']) def favicon(): return '' @app.route('/<action>', methods=['GET', 'POST']) def act(action): event = framework.flaskRequestParser(request, action) response = framework.router(event) resp = response['body'] headers = {} if 'headers' in response: headers = response['headers'] return resp, response['statusCode'], headers port = 9898 host = 'localhost' try: port = os.environ['PORT'] host = os.environ['HOST'] except: pass app.run(host=host, port=port, debug=True, load_dotenv=True)
import sys, os sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..") import unittest from ringcentral_bot_framework import frameworkInit import default_conf as conf framework = frameworkInit(conf) DBNAME = 'dynamodb' action = framework.dbAction class TestDynamodbMethods(unittest.TestCase): def test_basic_dynamodb(self): print('running dynamodb test') self.assertEqual(DBNAME, 'dynamodb') x = action('bot', 'add', {'id': 'xss2', 'token': {'a': 'b', 'b': 4}}) self.assertEqual(x, 'add') x1 = action('bot', 'add', {'id': 'xss1', 'token': {'a': 'a', 'b': 1}}) self.assertEqual(x1, 'add') x2 = action('bot', 'get', {'id': 'xss1'}) self.assertEqual(x2['id'], 'xss1') x2 = action( 'bot', 'update', { 'id': 'xss1', 'update': { 'token': { 'n': 45 }, 'x': 'c', 'data': { 'dd': 'ff' }