def test_record_form(self):
     form = RecordForm(instance=self.record)
     self.assertEqual(form.initial['reference_id'].hashid, self.hashids.encode(123))
     form = RecordForm({'name': "A new name", 'reference_id': 987}, instance=self.record)
     self.assertTrue(form.is_valid())
     instance = form.save()
     self.assertEqual(self.record, instance)
     self.assertEqual(str(self.record.reference_id), self.hashids.encode(987))
 def test_int_in_form(self):
     form = RecordForm({'name': "A new name", 'reference_id': 42})
     self.assertTrue(form.is_valid())
 def test_negative_int_in_form(self):
     form = RecordForm({'name': "A new name", 'reference_id': -5})
     self.assertFalse(form.is_valid())
     self.assertIn('reference_id', form.errors)
 def test_invalid_id_in_form(self):
     form = RecordForm({'name': "A new name", 'reference_id': "asdfqwer"})
     self.assertFalse(form.is_valid())
     self.assertIn('reference_id', form.errors)