def test_invalid_data(self): with open(TAR_FILE, 'rb') as f: form_file_data = dict(upload_file_minidump=SimpleUploadedFile( "foo.tar", f.read(100))) form_data = dict( appid=string_generator(40), userid=string_generator(40), meta=string_generator(40), stacktrace=string_generator(40), stacktrace_json=string_generator(40), signature=string_generator(256), ip=string_generator(40), groupid=string_generator(40), eventid=string_generator(40), ) form = CrashFrom(form_data, form_file_data) self.assertFalse(form.is_valid()) self.assertIn('upload_file_minidump', form.errors) self.assertIn('appid', form.errors) self.assertIn('userid', form.errors) self.assertIn('meta', form.errors) self.assertNotIn('stacktrace', form.errors) self.assertIn('stacktrace_json', form.errors) self.assertIn('signature', form.errors) self.assertIn('ip', form.errors) self.assertIn('groupid', form.errors) self.assertIn('eventid', form.errors)
def test_form(self): form_file_data = dict(upload_file_minidump=SimpleUploadedFile( "7b05e196-7e23-416b-bd13-99287924e214.dmp", b"content")) form_data = dict( appid='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', userid='{2882CF9B-D9C2-4edb-9AAF-8ED5FCF366F7}', ) form = CrashFrom(form_data, form_file_data) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data['upload_file_minidump'].name, '7b05e196-7e23-416b-bd13-99287924e214.dmp')
def test_form_tar_file(self): with open(TAR_FILE, 'rb') as f: form_file_data = dict(upload_file_minidump=SimpleUploadedFile( "foo.tar", f.read())) form_data = dict( appid='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', userid='{2882CF9B-D9C2-4edb-9AAF-8ED5FCF366F7}', ) form = CrashFrom(form_data, form_file_data) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data['upload_file_minidump'].name, '7b05e196-7e23-416b-bd13-99287924e214.dmp') self.assertEqual(form.cleaned_data['archive'].name, 'foo.tar')
def test_form_tar_file(self): with open(TAR_FILE, 'rb') as f: form_file_data = dict( upload_file_minidump=SimpleUploadedFile("foo.tar", f.read())) form_data = dict( appid='{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', userid='{2882CF9B-D9C2-4edb-9AAF-8ED5FCF366F7}', ) form = CrashFrom(form_data, form_file_data) self.assertTrue(form.is_valid()) self.assertEqual(form.cleaned_data['upload_file_minidump'].name, '7b05e196-7e23-416b-bd13-99287924e214.dmp') self.assertEqual(form.cleaned_data['archive'].name, 'foo.tar')