コード例 #1
0
    def test_5_device_query(self):
        # get_by_enable_device
        pt = GeniusDeviceQuery.get_enable_device(self.session)
        assert_result = len(pt)
        self.assertEqual(assert_result, self.test_delete.count(0))

        # get_by_name
        pt_2 = GeniusDeviceQuery.get_by_name(self.session, "iphone10")
        self.assertEqual(pt_2.device_name, "iphone10")
コード例 #2
0
ファイル: tests.py プロジェクト: Agby/genius-bar
    def test_5_device_query(self):
        # get_by_enable_device
        pt = GeniusDeviceQuery.get_enable_device(self.session)
        assert_result = len(pt)
        self.assertEqual(assert_result, self.test_delete.count(0))

        # get_by_name
        pt_2 = GeniusDeviceQuery.get_by_name(self.session, "iphone10")
        self.assertEqual(pt_2.device_name, "iphone10")
コード例 #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)
コード例 #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)
コード例 #5
0
ファイル: tests.py プロジェクト: Agby/genius-bar
 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)
コード例 #6
0
ファイル: tests.py プロジェクト: Agby/genius-bar
 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)
コード例 #7
0
 def device_query(self):
     return GeniusDeviceQuery(DBSession)
コード例 #8
0
 def test_7_complex_query(self):
     # get_device_by_holder_name
     pt_3 = GeniusDeviceQuery.get_device_by_holder_name(self.session, "RickRick")
     for pt in pt_3:
         self.assertEqual(pt.genius_user.user_name, "RickRick")
コード例 #9
0
ファイル: tests.py プロジェクト: Agby/genius-bar
 def test_7_complex_query(self):
     # get_device_by_holder_name
     pt_3 = GeniusDeviceQuery.get_device_by_holder_name(self.session, "RickRick")
     for pt in pt_3:
         self.assertEqual(pt.genius_user.user_name, "RickRick")