Exemple #1
0
    def test_reportitem_form_empty(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = ReportitemForm(data={})
        # compare
        self.assertFalse(form.is_valid())
Exemple #2
0
    def test_reportitem_note_form_filled(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = ReportitemForm(data={
            'reportitem_note': 'lorem ipsum',
        })
        # compare
        self.assertFalse(form.is_valid())
Exemple #3
0
    def test_reportitem_system_form_filled(self):
        """ test minimum form requirements / INVALID """

        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = ReportitemForm(data={
            'reportitem_note': 'lorem ipsum',
            'system': system_id,
        })
        # compare
        self.assertFalse(form.is_valid())
Exemple #4
0
    def test_reportitem_notestatus_form_filled(self):
        """ test minimum form requirements / INVALID """

        # get foreign key object id
        notestatus_id = Notestatus.objects.get(
            notestatus_name='notestatus_1').notestatus_id
        # get object
        form = ReportitemForm(data={
            'reportitem_note': 'lorem ipsum',
            'notestatus': notestatus_id,
        })
        # compare
        self.assertFalse(form.is_valid())
Exemple #5
0
def reportitems_edit(request, pk):
    reportitem = get_object_or_404(Reportitem, pk=pk)
    if request.method == 'POST':
        form = ReportitemForm(request.POST, instance=reportitem)
        if form.is_valid():
            reportitem = form.save(commit=False)
            reportitem.reportitem_modified_by_user_id = request.user
            reportitem.save()
            reportitem.logger(str(request.user), " REPORTITEM_EDIT_EXECUTED")
            messages.success(request, 'Reportitem edited')
            return redirect('/systems/' + str(reportitem.system.system_id))
    else:
        form = ReportitemForm(instance=reportitem)
        reportitem.logger(str(request.user), " REPORTITEM_EDIT_ENTERED")
    return render(request, 'dfirtrack_main/reportitem/reportitems_edit.html', {'form': form})
Exemple #6
0
    def test_reportitem_subheadline_form_filled(self):
        """ test additional form content """

        # get foreign key object id
        headline_id = Headline.objects.get(
            headline_name='headline_1').headline_id
        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = ReportitemForm(
            data={
                'reportitem_note': 'lorem ipsum',
                'system': system_id,
                'headline': headline_id,
                'reportitem_subheadline': 'subheadline_1',
            })
        # compare
        self.assertTrue(form.is_valid())
Exemple #7
0
    def test_reportitem_headline_form_filled(self):
        """ test minimum form requirements / VALID """

        # get foreign key object id
        headline_id = Headline.objects.get(
            headline_name='headline_1').headline_id
        notestatus_id = Notestatus.objects.get(
            notestatus_name='notestatus_1').notestatus_id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = ReportitemForm(
            data={
                'reportitem_note': 'lorem ipsum',
                'headline': headline_id,
                'notestatus': notestatus_id,
                'system': system_id,
            })
        # compare
        self.assertTrue(form.is_valid())
Exemple #8
0
    def test_reportitem_subheadline_too_many_chars(self):
        """ test for max length """

        # get foreign key object id
        headline_id = Headline.objects.get(
            headline_name='headline_1').headline_id
        notestatus_id = Notestatus.objects.get(
            notestatus_name='notestatus_1').notestatus_id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = ReportitemForm(
            data={
                'reportitem_note': 'lorem ipsum',
                'headline': headline_id,
                'notestatus': notestatus_id,
                'system': system_id,
                'reportitem_subheadline': 's' * 101,
            })
        # compare
        self.assertFalse(form.is_valid())
Exemple #9
0
def reportitems_add(request):
    if request.method == 'POST':
        form = ReportitemForm(request.POST)
        if form.is_valid():
            reportitem = form.save(commit=False)
            reportitem.reportitem_created_by_user_id = request.user
            reportitem.reportitem_modified_by_user_id = request.user
            reportitem.save()
            reportitem.logger(str(request.user), " REPORTITEM_ADD_EXECUTED")
            messages.success(request, 'Reportitem added')
            return redirect('/systems/' + str(reportitem.system.system_id))
    else:
        if request.method == 'GET' and 'system' in request.GET:
            system = request.GET['system']
            form = ReportitemForm(initial={
                'system': system,
            })
        else:
            form = ReportitemForm()
        debug_logger(str(request.user), " REPORTITEM_ADD_ENTERED")
    return render(request, 'dfirtrack_main/reportitem/reportitems_add.html', {'form': form})
Exemple #10
0
    def test_reportitem_subheadline_proper_chars(self):
        """ test for max length """

        # get foreign key object id
        headline_id = Headline.objects.get(
            headline_name='headline_1').headline_id
        # get foreign key object id
        system_id = System.objects.get(system_name='system_1').system_id
        # get object
        form = ReportitemForm(
            data={
                'reportitem_note':
                'lorem ipsum',
                'system':
                system_id,
                'headline':
                headline_id,
                'reportitem_subheadline':
                'ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss',
            })
        # compare
        self.assertTrue(form.is_valid())