def test_osimportname_name_form_filled(self):
        """ test minimum form requirements / INVALID """

        # get object
        form = OsimportnameForm(data={'osimportname_name': 'osimportname_1'})
        # compare
        self.assertFalse(form.is_valid())
Esempio n. 2
0
    def test_osimportname_name_too_many_chars(self):
        """ test for max length """

        # get foreign key object id
        os_id = Os.objects.get(os_name='os_1').os_id
        # get object
        form = OsimportnameForm(data = {
            'osimportname_name': 'ooooooooooooooooooooooooooooooo',
            'osimportname_importer': 'osimportname_importer_1',
            'os': os_id
        })
        # compare
        self.assertFalse(form.is_valid())
Esempio n. 3
0
    def test_osimportname_os_form_filled(self):
        """ test minimum form requirements / VALID """

        # get foreign key object id
        os_id = Os.objects.get(os_name='os_1').os_id
        # get object
        form = OsimportnameForm(data = {
            'osimportname_name': 'osimportname_1',
            'osimportname_importer': 'osimportname_importer_1',
            'os': os_id,
        })
        # compare
        self.assertTrue(form.is_valid())
    def test_osimportname_name_proper_chars(self):
        """test for max length"""

        # get foreign key object id
        os_id = Os.objects.get(os_name='os_1').os_id
        # get object
        form = OsimportnameForm(
            data={
                'osimportname_name': 'o' * 30,
                'osimportname_importer': 'osimportname_importer_1',
                'os': os_id,
            })
        # compare
        self.assertTrue(form.is_valid())
Esempio n. 5
0
def osimportnames_add(request):
    if request.method == 'POST':
        form = OsimportnameForm(request.POST)
        if form.is_valid():
            osimportname = form.save(commit=False)
            osimportname.save()
            osimportname.logger(str(request.user),
                                " OSIMPORTNAME_ADD_EXECUTED")
            messages.success(request, 'OS-Importname added')
            return redirect('/osimportnames')
    else:
        form = OsimportnameForm()
        debug_logger(str(request.user), " OSIMPORTNAME_ADD_ENTERED")
    return render(request,
                  'dfirtrack_main/osimportname/osimportnames_add.html',
                  {'form': form})
Esempio n. 6
0
def osimportnames_edit(request, pk):
    osimportname = get_object_or_404(Osimportname, pk=pk)
    if request.method == 'POST':
        form = OsimportnameForm(request.POST, instance=osimportname)
        if form.is_valid():
            osimportname = form.save(commit=False)
            osimportname.save()
            osimportname.logger(str(request.user),
                                " OSIMPORTNAME_EDIT_EXECUTED")
            messages.success(request, 'OS-Importname edited')
            return redirect('/osimportnames')
    else:
        form = OsimportnameForm(instance=osimportname)
        osimportname.logger(str(request.user), " OSIMPORTNAME_EDIT_ENTERED")
    return render(request,
                  'dfirtrack_main/osimportname/osimportnames_edit.html',
                  {'form': form})