I have view function that uses nmap to scan the devices in the network.
views.py
import nmap
def home(request):
   y=nmap.PortScanner()
   data = y.scan(hosts="192.168.1.*", arguments="-sP")
   context[status]=data['status']['addresses']['ipv4']
   return render_template('home.html',context)
Now i want to test this for no devices, 1 device connected and 2 or more device connected. I need to override data in tests.py.
I was thinking that it can be done using mock function. I can override it in tests.py but when simulate responses it not get override in view function.
How can i test this nmap function ?
 
    