def test_case_form_empty(self): """test minimum form requirements / INVALID""" # get object form = CaseForm(data={}) # compare self.assertFalse(form.is_valid())
def test_case_name_form_filled(self): """ test minimum form requirements / VALID """ # get object form = CaseForm(data={'case_name': 'case_1'}) # compare self.assertTrue(form.is_valid())
def test_case_name_too_many_chars(self): """ test for max length """ # get object form = CaseForm(data={ 'case_name': 'ddddddddddddddddddddddddddddddddddddddddddddddddddd' }) # compare self.assertFalse(form.is_valid())
def test_case_name_proper_chars(self): """ test for max length """ # get object form = CaseForm(data={ 'case_name': 'dddddddddddddddddddddddddddddddddddddddddddddddddd' }) # compare self.assertTrue(form.is_valid())
def cases_add(request): if request.method == 'POST': form = CaseForm(request.POST) if form.is_valid(): case = form.save(commit=False) case.case_created_by_user_id = request.user case.save() case.logger(str(request.user), " CASES_ADD_EXECUTED") messages.success(request, 'Case added') return redirect('/cases')
def test_casepriority_form_filled(self): """test minimum form requirements / INVALID""" # get objects casepriority_1 = Casepriority.objects.get( casepriority_name='casepriority_1') # get object form = CaseForm(data={ 'case_name': 'case_1', 'casepriority': casepriority_1, }) # compare self.assertFalse(form.is_valid())
def test_tag_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['tag'].label, 'Tags')
def test_casestatus_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['casestatus'].label, 'Casestatus (*)')
def test_case_is_incident_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['case_is_incident'].label, 'Is incident')
def test_case_name_form_label(self): """ test form label """ # get object form = CaseForm() # compare self.assertEquals(form.fields['case_name'].label, 'Case name (*)')
def test_casetype_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['casetype'].empty_label, 'Select casetype (optional)')
def test_case_note_internal_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['case_note_internal'].label, 'Internal note')
def test_case_note_analysisresult_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['case_note_analysisresult'].label, 'Analysis result')
def test_case_name_too_many_chars(self): """test for max length""" # get objects casepriority_1 = Casepriority.objects.get( casepriority_name='casepriority_1') casestatus_1 = Casestatus.objects.get(casestatus_name='casestatus_1') # get object form = CaseForm( data={ 'case_name': 'd' * 51, 'casepriority': casepriority_1, 'casestatus': casestatus_1, }) # compare self.assertFalse(form.is_valid())
def test_case_id_external_form_label(self): """test form label""" # get object form = CaseForm() # compare self.assertEqual(form.fields['case_id_external'].label, 'Case external ID')
case.logger(str(self.request.user), " CASEDETAIL_ENTERED") return context @login_required(login_url="/login") def cases_add(request): if request.method == 'POST': form = CaseForm(request.POST) if form.is_valid(): case = form.save(commit=False) case.case_created_by_user_id = request.user case.save() case.logger(str(request.user), " CASES_ADD_EXECUTED") messages.success(request, 'Case added') return redirect('/cases') else: form = CaseForm() debug_logger(str(request.user), " CASES_ADD_ENTERED") return render(request, 'dfirtrack_main/case/cases_add.html', {'form': form}) @login_required(login_url="/login") def cases_edit(request, pk): case = get_object_or_404(Case, pk=pk) if request.method == 'POST': form = CaseForm(request.POST, instance=case) if form.is_valid(): case = form.save(commit=False) case.case_created_by_user_id = request.user case.save() case.logger(str(request.user), " CASES_EDIT_EXECUTED") messages.success(request, 'Case edited') return redirect('/cases')