Exemple #1
0
 def test_1_add_user(self):
     for x in range(self.index_tstname):# ini user 
         input_name = self.test_name[x]
         input_id = self.test_slack_name[x]
         input_user = GeniusUser(user_name=input_name, slack_user_id=input_id)
         try:
             self.session.flush()
             self.session.add(input_user)
             self.session.commit()
         except Exception as e:
             self.session.rollback()
     query_res = GeniusUserQuery.get_all(self.session)
     assert_result = len(query_res)
     self.assertEqual(assert_result, self.index_tstname)
Exemple #2
0
 def test_1_add_user(self):
     for x in range(self.index_tstname):  # ini user
         input_name = self.test_name[x]
         input_id = self.test_slack_name[x]
         input_user = GeniusUser(user_name=input_name, slack_user_id=input_id)
         try:
             self.session.flush()
             self.session.add(input_user)
             self.session.commit()
         except Exception as e:
             self.session.rollback()
     query_res = GeniusUserQuery.get_all(self.session)
     assert_result = len(query_res)
     self.assertEqual(assert_result, self.index_tstname)
Exemple #3
0
 def test_3_add_event(self):
     for x in range(self.event_num): 
         self.session.flush()
         input_type = self.event_type[random.randint(0, self.index_type-1)]
         tmpx = random.randint(0, self.index_device-1)
         input_device = GeniusDeviceQuery.get_by_name(self.session, self.test_device[tmpx])
         tmp = random.randint(0, self.index_tstname-1)
         input_user = GeniusUserQuery.get_by_name(self.session, self.test_name[tmp])
         input_event = GeniusEvent(event_type=input_type, device_id=input_device.id, user_id=input_user.id)
         try:
             self.session.flush()
             self.session.add(input_event)
             self.session.commit()
         except Exception as e:
             self.session.rollback()
             print(e)
     query_res = GeniusEventQuery.get_all(self.session)
     assert_result = len(query_res)
     self.assertEqual(assert_result, self.event_num)
Exemple #4
0
 def test_2_add_device(self):
     for x in range(self.index_device): # ini device 
         self.session.flush()
         input_name = self.test_device[x]
         os_id = self.test_osvision[x % self.index_tstname]
         tmp = random.randint(0, self.index_tstname-1)
         holder_input = GeniusUserQuery.get_by_name(self.session, self.test_name[tmp])
         delete_input =  self.test_delete[x]
         input_device = GeniusDevice(device_name = input_name, os_version = os_id,
                                     holder_id = holder_input.id, delete = delete_input)
         try:
             self.session.flush()
             self.session.add(input_device)
             self.session.commit()
         except Exception as e:
             self.session.rollback()
     query_res = GeniusDeviceQuery.get_all(self.session)
     assert_result = len(query_res)
     self.assertEqual(assert_result, self.index_device)
Exemple #5
0
 def test_3_add_event(self):
     for x in range(self.event_num):
         self.session.flush()
         input_type = self.event_type[random.randint(0, self.index_type - 1)]
         tmpx = random.randint(0, self.index_device - 1)
         input_device = GeniusDeviceQuery.get_by_name(self.session, self.test_device[tmpx])
         tmp = random.randint(0, self.index_tstname - 1)
         input_user = GeniusUserQuery.get_by_name(self.session, self.test_name[tmp])
         input_event = GeniusEvent(event_type=input_type, device_id=input_device.id, user_id=input_user.id)
         try:
             self.session.flush()
             self.session.add(input_event)
             self.session.commit()
         except Exception as e:
             self.session.rollback()
             print(e)
     query_res = GeniusEventQuery.get_all(self.session)
     assert_result = len(query_res)
     self.assertEqual(assert_result, self.event_num)
Exemple #6
0
 def test_2_add_device(self):
     for x in range(self.index_device):  # ini device
         self.session.flush()
         input_name = self.test_device[x]
         os_id = self.test_osvision[x % self.index_tstname]
         tmp = random.randint(0, self.index_tstname - 1)
         holder_input = GeniusUserQuery.get_by_name(self.session, self.test_name[tmp])
         delete_input = self.test_delete[x]
         input_device = GeniusDevice(
             device_name=input_name, os_version=os_id, holder_id=holder_input.id, delete=delete_input
         )
         try:
             self.session.flush()
             self.session.add(input_device)
             self.session.commit()
         except Exception as e:
             self.session.rollback()
     query_res = GeniusDeviceQuery.get_all(self.session)
     assert_result = len(query_res)
     self.assertEqual(assert_result, self.index_device)
Exemple #7
0
 def user_query(self):
     return GeniusUserQuery(DBSession)
Exemple #8
0
 def test_4_user_query(self):
     # get_by_name
     pt = GeniusUserQuery.get_by_name(self.session, "RickRick")
     self.assertEqual(pt.slack_user_id, "RRRRRRick")
Exemple #9
0
 def test_4_user_query(self):
     # get_by_name
     pt = GeniusUserQuery.get_by_name(self.session, "RickRick")
     self.assertEqual(pt.slack_user_id, "RRRRRRick")