def test_id_generator_len(self): len_id = 8 self.assertEqual(len_id, len(id_generator(len_id=len_id)))
def test_id_generator_suffix(self): suffix = 'comment' output = id_generator(suffix=suffix) self.assertEqual(True, output.endswith(suffix)) self.assertEqual(self.len_id + len(suffix), len(output))
def test_id_generator_chars(self): import string # flake8:no qa chars = string.ascii_uppercase output = id_generator(chars=chars) self.assertEqual(output, output.upper())
def test_id_generator_prefix(self): prefix = 'comment' output = id_generator(prefix=prefix) self.assertEqual(True, output.startswith(prefix)) self.assertEqual(self.len_id + len(prefix), len(output))
def test_id_generator_generates_different_ids(self): self.assertNotEqual(id_generator(), id_generator())
def test_id_generator_length(self): self.assertEqual(self.len_id, len(id_generator()))
def generate_urlhash(): return id_generator(prefix=settings.COMMENT_URL_PREFIX, len_id=settings.COMMENT_URL_ID_LENGTH, suffix=settings.COMMENT_URL_SUFFIX)
def generate_urlhash(): return id_generator(prefix='comment', len_id=8, suffix='')