def test_start_client(self): ''' Test to make a client object, run send a couple of signals then quite. No real tests, just fist step to catch general exceptions and any othe misc runtime errors. ''' client = client_thread(self.host, self.port, self.in_q, self.out_q) #client.setDaemon(True) client.start() self.in_q.put('test') self.in_q.put('et tu, Brute?') client.join()
def test_client_sends_ping(self): ''' Start the client and tell it to ping the host. Watch for errors. ''' client = client_thread(self.host, self.port, self.in_q, self.out_q) client.daemon = True client.start() self.in_q.put('ping') # join the queue self.in_q.join() self.failUnless(self.in_q.empty()) # now kill the client self.in_q.put('et tu, Brute?') client.join()
def test_client_ping_through_io_queue(self): ''' Create clientobject. Start running, send special 'test' signal in input queue and fail unless 'test' is present in output queue. The client should respond with 'test'. ''' client = client_thread(self.host, self.port, self.in_q, self.out_q) client.start() self.in_q.put('test') response = self.out_q.get() self.failUnless(response == 'test') self.failIf(response == '') # now kill it self.in_q.put('et tu, Brute?') client.join()
def test_client_eats_input_queue(self): ''' Put something in the input queue to the client and fail unless the the queue is empty. I.e. the client needs to eat the queue. ''' client = client_thread(self.host, self.port, self.in_q, self.out_q) client.daemon = True client.start() self.in_q.put('test') self.in_q.put('test') self.in_q.put('test') self.in_q.put('test') # join the queue self.in_q.join() self.failUnless(self.in_q.empty()) # now kill the client self.in_q.put('et tu, Brute?') client.join()
def test_server_recieve_ping(self): ''' Start the client and tell it to ping the host. Compare out queue from host to make sure data matches ''' client = client_thread(self.host, self.port, self.in_q, self.out_q) client.daemon = True client.start() self.in_q.put('hello') val = self.server_out.get() addr, data = val.split(':') #print(data) # join the queue self.in_q.join() # now kill the client self.in_q.put('et tu, Brute?') client.join() print(data) self.failUnless(data == 'hello')
def test_client_close_on_kill_sig(self): client = client_thread(self.host, self.port, self.in_q, self.out_q) client.start() self.in_q.put('et tu, Brute?') client.join()