Ejemplo n.º 1
0
    async def setup(self):
        print("Hello World! I'm agent {}".format(str(self.jid)))
        train_template = tools.create_template("inform", "train")
        self.add_behaviour(self.TrainBehaviour(), train_template)

        list_template = tools.create_template("inform", "list")
        self.add_behaviour(self.ListBehaviour(), list_template)

        decision_template = tools.create_template("inform", "decision")
        self.add_behaviour(self.DecisionBehaviour(), decision_template)
Ejemplo n.º 2
0
 def test_edit_template_with_minor_version_update(self):
     # сначала создадим новый шаблон
     tools.create_template(self.template_data)
     # потом отредактируем его же
     new_template_data = copy.deepcopy(self.template_data)
     new_template_data.update(description='new description')
     tools.edit_template(new_template_data)
     # проверяем что отредактировалось правильно
     # и что новый шаблон помечен как активный, а старый как неактивный
     active_template = MessageTemplates.objects.get(name=self.template_name, active=1)
     inactive_template = MessageTemplates.objects.get(name=self.template_name, active=2)
     self.assertEqual(active_template.description, new_template_data.get('description'))
     self.assertEqual(inactive_template.description, self.template_data.get('description'))
     self.assertEqual(active_template.version, '1.1')
     self.assertEqual(inactive_template.version, '1.0')
Ejemplo n.º 3
0
    async def setup(self):
        print("Hello World! I'm agent {}".format(str(self.jid)))
        self.web.start(port=10000, templates_path="static/templates")
        self.web.add_post("/train", self.train_controller, None)
        self.web.add_post("/decision", self.decision_controller, None)
        self.web.add_get("/list", self.list_controller, None)
        # self.web.add_post("/retrieve/train", self.train_controller, None)
        # self.web.add_post("/retrieve/decision", self.retrieve_decision_controller, None)
        # self.web.add_get("/retrieve/list", self.retrieve_list_controller, None)
        self.web.add_get("", self.main_controller, "main.html")

        decision_template = tools.create_template("inform", "decision")
        self.add_behaviour(self.ResponseDecisionBehaviour(self.operations), decision_template)
        list_template = tools.create_template("inform", "list")
        self.add_behaviour(self.ResponseListBehaviour(self.operations), list_template)

        await self.spawn_agents()
Ejemplo n.º 4
0
    def test_create_template(self):
        """
        тест на создание шаблона
        """
        # создаём шаблон
        tools.create_template(self.template_data)
        # проверяем что шаблон создался нормально
        template = MessageTemplates.objects.get(name=self.template_name)
        self.assertEqual(template.name, self.template_name)
        self.assertEqual(template.active, 1)
        self.assertEqual(template.version, '1.0')
        self.assertEqual(template.description, self.template_data.get('description'))
        self.assertEqual(template.message_category.name, self.template_data.get('type'))
        self.assertEqual(template.category, self.template_data.get('category'))
        message_template = MessageChannelTemplates.objects.get(
                            message_template=template, brand=Brands.objects.get(name=self.template_data.get('brand')))
        self.assertEqual(message_template.channel, self.template_data.get('channel'))
        self.assertEqual(message_template.extra, tools._create_extra_field(self.template_data))

        variables = MessageTemplateVariables.objects.filter(message_template=template)
        self.assertEqual(len(variables), 3)
Ejemplo n.º 5
0
    async def setup(self):

        print("Hello World! I'm agent {}".format(str(self.jid)))

        history_data_template = tools.create_template("inform", "history")
        self.add_behaviour(self.HistoryDataBehaviour(self.session),
                           history_data_template)

        current_data_template = tools.create_template("inform", "current")
        self.add_behaviour(self.CurrentDataBehaviour(self.session),
                           current_data_template)

        list_models_template = tools.create_template("inform", "list")
        self.add_behaviour(self.ListModelsBehaviour(self.session),
                           list_models_template)

        get_model_template = tools.create_template("inform", "getModel")
        self.add_behaviour(self.GetModelBehaviour(self.session),
                           get_model_template)

        save_model_template = tools.create_template("inform", "saveModel")
        self.add_behaviour(self.SaveModelBehaviour(self.session),
                           save_model_template)