python - to test the save statement in the views.py -
i designed test initialy, because idea apply tdd, test should test register saved , can executed correctly(the save()), test should fail, because obviously, code in views module doesn't exist save, me complete test adequately test save.
this test file:
from django.test import testcase django.http import httprequest django.conf import settings## django.utils.importlib import import_module## django.core.urlresolvers import reverse key_process_indicator_bsc.views.views_process_indicator import * key_process_indicator_bsc.models import * class processindicatortestcase(testcase): fixtures = ['test_data_key_process_indicator_bsc.json'] def setup(self): pass def test_pi_insert_basic(self): #user = auth_user.objects.get(username="lruedc") indicator_type = indicatortype.objects.get(name="eficacia") unite_measure = unitemeasure.objects.get(name="horas") periodicity_indicator = periodicityindicator.objects.get(pk = 1) indicator_process = indicatorprocess.objects.get(pk = 1) frecuency = frecuency.objects.get(detail="semanal") formula = formula.objects.get(detail = "2ab") request = httprequest() request.method = 'post' request.post['name'] = "cumplimiento del margen ebitda" request.post['goal'] = "100" request.post['weight'] = "50" request.post['minimum_range'] = 20 request.post['hight_range'] = 40 request.post['acountable'] = 1 request.post['responsible'] = 1 request.post['indicator_type'] = indicator_type.id request.post['unite_measure'] = unite_measure.id request.post['formula'] = formula.id request.post['process'] = indicator_process.process request.post['indicator_process_type'] = indicator_process.indicator_process_type request.post['indicator_process'] = indicator_process.id request.post['frecuency'] = frecuency.id engine = import_module(settings.session_engine) processindicatorinsert.as_view()(request)
this views file:
from django.shortcuts import render django.views.generic import view django.http import httpresponse, httpresponseredirect #from ..forms import loginform django.core.urlresolvers import reverse class processindicatorinsert(view): template_name = 'key_process_indicator_bsc/index.html' def post(self, request): return render(request, self.template_name, { })
and run test, can see next:
..................... ---------------------------------------------------------------------- ran 21 tests in 0.694s ok destroying test database alias 'default'... (key_process_indicator_bsc_local) root@leidyj-virtualbox:/home/leidyj/key_process_indicator_bsc_repository/key_process_indicator_bsc#
how can see, test not fail , should, how complete test?.
thanks.
Comments
Post a Comment