def test_generate_code_returns_valid_sha1_string(): import re code = Article.generate_code() assert re.match(r'^[0-9a-f]{40}$', code)
def test_generate_code_returns_always_new_code(): codes = [c for c in filter(lambda x: Article.generate_code(), range(5))] assert 5 == len(set(codes))
def test_generate_code_returns_fixed_length_string(): code = Article.generate_code() assert 40 == len(code)