Esempio n. 1
0
 def test_testplan_new_form_missing_required_fields(self):
     form_data = {}
     form_data['description'] = 'Description...'
     form_data['latencyEnabled'] = True
     form_data['clientLatency'] = 0
     form_data['serverLatency'] = 100
     form = TestPlanForm(data=form_data)
     self.assertFalse(form.is_valid())
Esempio n. 2
0
 def test_testplan_new_form_missing_required_fields(self):
     form_data = {}
     form_data['description'] = 'Description...'
     form_data['latencyEnabled'] = True
     form_data['clientLatency'] = 0
     form_data['serverLatency'] = 100
     form = TestPlanForm(data=form_data)
     self.assertFalse(form.is_valid())
Esempio n. 3
0
 def test_testplan_new_form_valid_all_fields(self):
     form_data = {}
     form_data['name'] = 'Test Plan %s' % (uuid.uuid4().hex, )
     form_data['description'] = 'Description...'
     form_data['latencyEnabled'] = True
     form_data['clientLatency'] = 0
     form_data['serverLatency'] = 100
     form = TestPlanForm(data=form_data)
     self.assertTrue(form.is_valid())
Esempio n. 4
0
 def test_testplan_new_form_valid_all_fields(self):
     form_data = {}
     form_data['name'] = 'Test Plan %s' % (uuid.uuid4().hex,)
     form_data['description'] = 'Description...'
     form_data['latencyEnabled'] = True
     form_data['clientLatency'] = 0
     form_data['serverLatency'] = 100
     form = TestPlanForm(data=form_data)
     self.assertTrue(form.is_valid())
Esempio n. 5
0
def testplan_new(request):
    form = TestPlanForm(request.POST or None)
    if form.is_valid():
        try:
            testplan_id = TestPlan(auth_token=request.user.password).create(form.cleaned_data)
            return HttpResponseRedirect(reverse('testplan_details', args=(str(testplan_id),)))
        except UnauthorizedException:
            logger.warning('User unauthorized. Signing out...')
            return signout(request)
        except Exception as inst:
            logger.error('Unexpected exception', exc_info=True)
            messages.error(request, inst.message if inst.message else 'Unexpected error')
            return HttpResponseRedirect(reverse('testplan_list'))

    return render(request, 'testplan/testplan_new.html', {'form': form})
Esempio n. 6
0
def testplan_new(request):
    form = TestPlanForm(request.POST or None)
    if form.is_valid():
        try:
            testplan_id = TestPlan(auth_token=request.user.password).create(
                form.cleaned_data)
            return HttpResponseRedirect(
                reverse('testplan_details', args=(str(testplan_id), )))
        except UnauthorizedException:
            logger.warning('User unauthorized. Signing out...')
            return signout(request)
        except Exception as inst:
            logger.error('Unexpected exception', exc_info=True)
            messages.error(
                request, inst.message if inst.message else 'Unexpected error')
            return HttpResponseRedirect(reverse('testplan_list'))

    return render(request, 'testplan/testplan_new.html', {'form': form})
Esempio n. 7
0
 def test_testplan_new_form_valid_minimal_fields(self):
     form_data = {}
     form_data['name'] = 'Test Plan %s' % (uuid.uuid4().hex, )
     form_data['description'] = 'Description...'
     form = TestPlanForm(data=form_data)
     self.assertTrue(form.is_valid())
Esempio n. 8
0
 def test_testplan_new_form_valid_minimal_fields(self):
     form_data = {}
     form_data['name'] = 'Test Plan %s' % (uuid.uuid4().hex,)
     form_data['description'] = 'Description...'
     form = TestPlanForm(data=form_data)
     self.assertTrue(form.is_valid())