Exemple #1
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     new_user1 = models.UserConfig(uuid=123456,
                                   login="******",
                                   password="******",
                                   authId="auth_id")
     new_user2 = models.UserConfig(uuid=987654,
                                   login="******",
                                   password="******",
                                   authId="auth_id2")
     new_flow1 = models.Flow(flowId=1,
                             timeCreated=111,
                             flowType='chat',
                             title='title2',
                             info='info2')
     new_flow2 = models.Flow(flowId=2,
                             timeCreated=222,
                             flowType='chat',
                             title='title2',
                             info='info2')
     models.Message(text="Hello1",
                    time=111,
                    userConfig=new_user1,
                    flow=new_flow1)
     models.Message(text="Hello2",
                    time=222,
                    userConfig=new_user2,
                    flow=new_flow2)
     models.Message(text="Hello3",
                    time=333,
                    userConfig=new_user1,
                    flow=new_flow1)
     self.test = api.ValidJSON.parse_obj(GET_UPDATE)
Exemple #2
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     new_user = models.UserConfig(uuid=123456,
                                  login="******",
                                  password="******",
                                  authId="auth_id")
     new_user2 = models.UserConfig(uuid=654321,
                                   login="******",
                                   password="******",
                                   authId="auth_id2")
     new_flow = models.Flow(flowId=123)
     new_flow2 = models.Flow(flowId=321)
     models.Message(text="Hello",
                    time=1,
                    userConfig=new_user,
                    flow=new_flow)
     models.Message(text="Privet",
                    time=2,
                    userConfig=new_user,
                    flow=new_flow)
     models.Message(text="Hello2",
                    time=3,
                    userConfig=new_user2,
                    flow=new_flow2)
     self.test = api.ValidJSON.parse_obj(ALL_MESSAGES)
Exemple #3
0
    def _add_flow(self):
        """Function allows you to add a new flow to the database

        """
        # FIXME после замены flowId на UUID из питоньего модуля
        random.seed(urandom(64))
        flow_id = random.randrange(1, 999999)
        if self.request.data.flow[0].type not in ["chat", "group", "channel"]:
            self.__catching_error(400, "Wrong flow type")
        elif self.request.data.flow[0].type == 'chat' and len(
                self.request.data.user) < 2:
            self.__catching_error(400,
                                  "Two users UUID must be specified for chat")
        else:
            try:
                models.Flow(flowId=flow_id,
                            timeCreated=self.get_time,
                            flowType=self.request.data.flow[0].type,
                            title=self.request.data.flow[0].title,
                            info=self.request.data.flow[0].info)
            except SQLObjectIntegrityError as flow_error:
                self.__catching_error(520, str(flow_error))
            else:
                flow = api.Flow()
                flow.id = flow_id
                flow.time = self.get_time
                flow.type = self.request.data.flow[0].type
                flow.title = self.request.data.flow[0].title
                flow.info = self.request.data.flow[0].info
                self.response.data.flow.append(flow)
                self.__catching_error(200)
Exemple #4
0
 def test_all_flow(self):
     models.Flow(flowId=1,
                 timeCreated=123456,
                 flowType="flow_type",
                 title="title",
                 info="info")
     run_method = controller.ProtocolMethods(self.test)
     result = json.loads(run_method.get_response())
     self.assertEqual(result["data"]["flow"][0]["info"], "info")
Exemple #5
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       authId="auth_id")
     models.Flow(flowId=333)
     logger.remove()
     self.test = api.ValidJSON.parse_obj(ADD_FLOW)
Exemple #6
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       authId="auth_id")
     models.Flow(flowId=123,
                 timeCreated=111,
                 flowType="chat")
     self.test = api.ValidJSON.parse_obj(SEND_MESSAGE)
Exemple #7
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     new_user = models.UserConfig(uuid=123456,
                                  login="******",
                                  password="******",
                                  authId="auth_id")
     new_flow = models.Flow(flowId=123)
     models.Message(id=1,
                    text="Hello",
                    time=123456,
                    userConfig=new_user,
                    flow=new_flow)
     self.test = api.ValidJSON.parse_obj(EDITED_MESSAGE)