Beispiel #1
0
 def test_multiple_attempt(self):
     '''
     Try to connect when a connection already exists
     '''
     for _ in range(10):
         client.connect()
         self.assertTrue(client.isconnected())
Beispiel #2
0
 def test_disconnect(self):
     '''
     Connect and disconnect multiple times, make sure the connection is successfully released
     '''
     for _ in range(5):
         client.connect()
         self.assertEqual(client.isconnected(), True)
         client.disconnect()
         self.assertEqual(client.isconnected(), False)
Beispiel #3
0
 def test_random_operation(self):
     '''
     Connect and disconnect randomly to simulate real world cases
     '''
     for i in range(10):
         choice = random.randrange(2)
         if choice == 1:
             client.connect()
             self.assertEqual(client.isconnected(), True)
         elif choice == 0:
             client.disconnect()
             self.assertEqual(client.isconnected(), False)
Beispiel #4
0
    def test_echo(self):
        '''
        Test `vget /unrealcv/echo` the most basic command of unrealcv
        '''
        import string
        # run an echo command, make sure I can get what I want
        client.connect()

        # Try to produce a very long random string sequence
        nTrial = 10
        for _ in range(nTrial):
            N = 1000 # Define a long string
            msg = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(N))
            res = client.request('vget /unrealcv/echo %s' % msg)
            self.assertEqual(res, msg)
Beispiel #5
0
 def test_multiple_connection(self):
     '''
     Try to use multiple different clients to connect to the server.
     Only the first one should be accepted and the future client will be rejected. #TODO #feature
     '''
     client.disconnect()
     client.connect()
     self.assertTrue(client.isconnected())
     response = client.request(self.test_cmd)
     self.assertEqual(response, 'ok')
     for i in range(10):
         client = unrealcv.Client((self.host, self.port))
         # Create a different client instance
         client.connect()
         # print client.connect()
         self.assertEqual(client.isconnected(), False)
Beispiel #6
0
 def setUp(self):
     client.connect()
Beispiel #7
0
 def test_connect(self):
     '''
     Simply test the connection
     '''
     client.connect()
     self.assertTrue(client.isconnected())