Ejemplo n.º 1
0
    def test_length(self):
        default_length = 8
        assert_equal(len(generate_verification_code()), default_length,
                     "Verification code length does not match default expected length of %d." % default_length)
        assert_equal(len(generate_verification_code(length=10)), 10,
                     "Verification code length does not match expected length.")

        assert_raises(ValueError, generate_verification_code, 33)
        assert_raises(ValueError, generate_verification_code, 0)
        assert_raises(ValueError, generate_verification_code, -1)
        assert_raises(ValueError, generate_verification_code, 33)
        assert_raises(TypeError, generate_verification_code, None)
        assert_raises(TypeError, generate_verification_code, "")
Ejemplo n.º 2
0
 def test_is_string(self):
     assert_true(isinstance(generate_verification_code(), bytes),
                 "Verification code is not a bytestring.")
Ejemplo n.º 3
0
 def test_uniqueness(self):
     assert_not_equal(generate_verification_code(),
                      generate_verification_code(),
                      "Verification code is not unique.")