def test_init_args(): # initialize arguments config = Config("") config.confg_parser.add_section("test_section") config.confg_parser.set("test_section", "test_key", "test_value") tz = timezone("Asia/Tokyo") logger = getLogger("test_core_logger") print(logger.name) connection_provider = CustomConnectionProvider context_store = CustomContextStore user_store = CustomUserStore messagelog_store = CustomMessageLogStore data_stores = CustomDataStores default_dialog_service = MyDialog dialog_router = MyDialogRouter tagger = CustomTagger custom_router_arg = "router_value" # create bot bot = Minette( config=config, timezone=tz, logger=logger, connection_provider=connection_provider, context_store=context_store, user_store=user_store, messagelog_store=messagelog_store, default_dialog_service=default_dialog_service, dialog_router=dialog_router, custom_router_arg=custom_router_arg, tagger=tagger, prepare_table=True ) assert bot.config.get("test_key", section="test_section") == "test_value" assert bot.timezone == timezone("Asia/Tokyo") assert bot.logger.name == "test_core_logger" assert isinstance(bot.connection_provider, CustomConnectionProvider) assert isinstance(bot.context_store, CustomContextStore) assert isinstance(bot.user_store, CustomUserStore) assert isinstance(bot.messagelog_store, CustomMessageLogStore) assert bot.default_dialog_service is MyDialog assert isinstance(bot.dialog_router, MyDialogRouter) assert bot.dialog_router.custom_attr == "router_value" assert isinstance(bot.tagger, CustomTagger) # create bot with data_stores bot = Minette( config=config, timezone=tz, logger=logger, data_stores=data_stores, default_dialog_service=default_dialog_service, dialog_router=dialog_router, custom_router_arg=custom_router_arg, tagger=tagger, prepare_table=True ) assert bot.config.get("test_key", section="test_section") == "test_value" assert bot.timezone == timezone("Asia/Tokyo") assert bot.logger.name == "test_core_logger" assert isinstance(bot.connection_provider, CustomConnectionProvider) assert isinstance(bot.context_store, CustomContextStore) assert isinstance(bot.user_store, CustomUserStore) assert isinstance(bot.messagelog_store, CustomMessageLogStore) assert bot.default_dialog_service is MyDialog assert isinstance(bot.dialog_router, MyDialogRouter) assert bot.dialog_router.custom_attr == "router_value" assert isinstance(bot.tagger, CustomTagger)
StickerSendMessage, ImagemapSendMessage, TemplateSendMessage, FlexSendMessage, ButtonsTemplate, FlexContainer, ) from linebot.exceptions import LineBotApiError from minette.adapter.lineadapter import LineAdapter except Exception: # Skip if import dependencies not found pytestmark = pytest.mark.skip from minette import (DialogService, Message, Payload, Config) lineconfig = Config("config/test_config_adapter.ini") channel_secret = lineconfig.get("channel_secret", section="line_bot_api") channel_access_token = lineconfig.get("channel_access_token", section="line_bot_api") # Skip if channel_secret or channel_access_token is not provided if not channel_secret or not channel_access_token: pytestmark = pytest.mark.skip class MyDialog(DialogService): def compose_response(self, request, context, connection): return "res:" + request.text
URL ) from minette.adapter.clovaadapter import ClovaAdapter import request_samples as rs except Exception: # Skip if import dependencies not found pytestmark = pytest.mark.skip from minette import ( DialogService, Message, Config ) from minette.serializer import loads clovaconfig = Config("config/test_config_adapter.ini") application_id = clovaconfig.get("application_id", section="clova_cek") default_language = clovaconfig.get("default_language", section="clova_cek") # Skip if application_id is not provided if not application_id: pytestmark = pytest.mark.skip class MyDialog(DialogService): def compose_response(self, request, context, connection): if request.intent == "TurnOff": return ["Handled {}".format(request.type), "Finish turning off"] else: return "Handled {}".format(request.type)
from minette.datastore.sqlalchemystores import (SQLAlchemyStores, SQLAlchemyConnection, SQLAlchemyMessageLog, SQLAlchemyMessageLogStore) except Exception: pass from minette.utils import date_to_unixtime, date_to_str now = datetime.now() table_name = "messagelog" + str(date_to_unixtime(now)) user_id = "user_id" + str(date_to_unixtime(now)) print("messagelog_table: {}".format(table_name)) print("user_id: {}".format(user_id)) dbconfig = Config("config/test_config_datastores.ini") datastore_params = [ ( SQLiteStores, "test.db", ), ( SQLDBStores, dbconfig.get("sqldb_connection_str"), ), ( AzureTableStores, dbconfig.get("table_connection_str"), ), (
headers=self.headers, json=data) if ret.status_code != 200: raise ret.raise_for_status() def delete(self, liff_id): ret = requests.delete(self.endpoint_url + "/" + liff_id, headers=self.headers) if ret.status_code != 200: raise ret.raise_for_status() # LIFFの登録 if __name__ == "__main__": # 設定の取得 config = Config("../minette.ini") host = config.get(key="host") channel_access_token = config.get(section="line_bot_api", key="channel_access_token") # LIFFの実体のURL。必ずHTTPSが必要 liff_url = "https://{}/liff/example".format(host) # LIFFの表示サイズ。全画面:full / 80%くらい:tall / 半分くらい:compact view_type = "full" # 登録 lm = LiffManager(channel_access_token) liff_id = lm.add(liff_url=liff_url, view_type=view_type) print("""LIFFの登録に成功しました! ---- LIFFのURL: line://app/{0} ---- LIFF ID: {0}