<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p></p>
<div class="gmail_quote">Hello All,</div>
<div class="gmail_quote">
<div dir="ltr">
<div><br>
</div>
<div>I have been trying to write a test framework for a pretty simple command server application in python. I have not been able to figure out how to test the socket server.</div>
<div>I would really appreciate if you could help me out in testing this application using unittest.</div>
<div>Please find the commandserver.py file attached. test_commandserver.py is the file i came up with.</div>
<div>Please kindly review it.</div>
<div><br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
The&nbsp;tests cases I came up with are:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
1. Start the server</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
2. Establish&nbsp;connection with client</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
3. Test the server&nbsp;by sending 3 commands</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
&nbsp; &nbsp; - loopback command should &nbsp;send all payload.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
&nbsp; &nbsp; - print command should print payload</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
&nbsp; &nbsp; - close command should close the connection between server and client.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
4. Raise error&nbsp;if any other command is send other than listed 3 commands</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
Other nominal cases</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
1. Check if both the server and client are closed. It might happen that only one is closed.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px;">
2. Go to sleep/Cancel the connection if no command is received after a certain period of time.</div>
</div>
<div><br>
</div>
<div>Thank You</div>
<div><br>
</div>
<div>Harsh</div>
</div>
</div>
<p></p>
</div>
</body>
</html>