title: Django unit tests mock
body: <p>I came to the <strong><em>mock</em></strong> lib which I never used before in tests. I need the response from server (the server is not actually there) if it is online or not. First of all I need to check that server IP and then check the state of it with the response of TRUE or FALSE. <em>Server.object</em> should come from <em>models.py</em> so I guess I need to start using mock lib here. Maybe some of you could explain me or show me few examples of getting fake response from 'mock'server. I have read Django testing , mock lib official documentation but none of them gave me enough info how to simulate response from fake server.</p>
  
  <p>Code example:</p>
  
  <pre><code>def ssh_server(server_list, timeout=200):
      online = False
      response = []
      server_state = []
      timeout_stamp = datetime.datetime.now() + datetime.timedelta(seconds=timeout)
      for obj_id in server_list:
          server = models.Server.objects.get(id=obj_id)
          ip = server.ip
          client = paramiko.SSHClient()
          client.load_system_host_keys()
          client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
          while True:
              try:
                  client.connect(ip, username='root')
                  online = True
              except:
                  online = False
  </code></pre>