In my application, i haven’t use model for database. I have traditional way of doing it, that is by mysql server and client. I have used MySQLdb for database access.
Also in my django views, almost all code are written in normal python code, that is i have not used the advantage of django built in view and functions.

def showhome(request):

  if request.user.is_anonymous():       
      return HttpResponseRedirect("/")

  db = MySQLdb.connect(host=dbHost,port=dbPort,user=dbUser,passwd=dbPasswd,db=dbName)

  c = db.cursor()                                                                       
  username=request.user                                                                       
  c.execute("Select firstname from USER where USERNAME=%s,(username,))                     
  name=c.fetchone()
  c.close()

  firstname=name[0]                                                                         
  c=db.cursor()
  c.execute("Select vehicle,status from PROPERTY where firstname=%s,(firstname,))
  deviceDetails=c.fetchall()
  c.close()


  paginator = Paginator(deviceDetails, 10)                                                

  page = request.GET.get('page')
  try:
      List = paginator.page(page)   
  except PageNotAnInteger:
      List = paginator.page(1)      
  except EmptyPage:
      List = paginator.page(paginator.num_pages)       

  current=List.number              
  last_page=paginator.num_pages
  page_limit=10          
  n=current%page_limit

  if n==1:                                                                                        
      start=current                                                                       
  else:
      start=(current-n+1) if n!=0 else current-page_limit+1                               
  end=start+page_limit                                                                    
  if end>last_page:                                                                       
      end=last_page+1
  page_range=range(start,end)                                                             


  context={}
  context['Data']=List
  context['page_range']=page_range
  db.close()
  return render(request,"home/show.html",context)

What type of testing i have to do in .py file blackbox or ?
If it is whitebox which type i have to follow for testing the above function unittest or integration test?
I think unittest is enough for the above function, isn’t it?



Source link https://sqa.stackexchange.com/questions/30573/what--of--testingblack-box-or-white-box-is-done-by-django-

LEAVE A REPLY

Please enter your comment!
Please enter your name here