Example #1
0
 def save(self, *args, **kwargs):
     if not self.magic_id or len(self.magic_id) == 0:
         self.magic_id = get_random_id()
     super(Student, self).save(*args, **kwargs)
Example #2
0
 def test_default_length(self):
     self.assertEqual(len(get_random_id()), 8)
Example #3
0
 def test_random_ids_are_different(self):
     self.assertNotEqual(get_random_id(), get_random_id())
Example #4
0
 def test_only_characters_or_digits(self):
     for c in get_random_id(20):
         self.assertTrue(c in string.ascii_letters + string.digits)
Example #5
0
 def test_length_as_specified(self):
     for i in range(1, 10):
         self.assertEqual(len(get_random_id(i)), i)