def test_password_is_valid(): ############### test that exception is raised for invalid passwords ################### with pytest.raises(Exception): assert password_is_valid('') == "password should exist" assert password_is_valid( 'TTTTTTTTT') == 'password should have atleast one lowercase letter' assert password_is_valid( 'ttttttttt') == 'password should atleast have one uppercase letter' assert password_is_valid( 'tTttttttt') == 'password should atleast have one digit' assert password_is_valid( 'tVp9rart') == 'password should be longer than than 8 characters'
def test_password_is_valid(): with pytest.raises(Exception): assert password_is_valid('') == Exception('password should exist') assert password_is_valid('tttdgjgjjhehjxdgj') == Exception('Password must have a minimum of 8 characters') assert password_is_valid('FTJTTJD57I9ETUGJ') == Exception('Password must have atleast one lowercase letter') assert password_is_valid('fdhdfhdfhhfdfhdfhdfh') == Exception('Password must have atleast one uppercase letter') assert password_is_valid('45tr7678sftfg') == Exception('Password must have atleast one digit') assert password_is_valid('45e45#$%^&&*(#$dxf)') == Exception('Password must have atleast one special character')
def test_password_char(): with pytest.raises( Exception, match="password should have at least one special character"): pass_check.password_is_valid("Helllokitty1")
def test_password_digit(): with pytest.raises(Exception, match="password should at least have one digit"): pass_check.password_is_valid("Helllokitty!")
def test_password_uppcase(): with pytest.raises( Exception, match="password should have at least one uppercase letter"): pass_check.password_is_valid("hellokitty1!")
def test_password_lowcase(): with pytest.raises( Exception, match="password should have at least one lowercase letter"): pass_check.password_is_valid("HELLOKITTY1!")
def test_password_len(): with pytest.raises( Exception, match="password should be longer than than 8 characters"): pass_check.password_is_valid("Hell1!")
def test_password_has_lower(): with pytest.raises(Exception, match="password should have a lowercase character"): password_is_valid("JOY12345678")
def test_password_has_digit(): """it sould raise a suitable exception if the password does not contain a digit""" with pytest.raises(Exception, match='password should contain a digit'): password_checker.password_is_valid('Aa_______')
def test_password_has_upper(): """it should raise a suitable exception if the password does not contain an uppercase character""" with pytest.raises(Exception, match='password should contain an uppercase character'): password_checker.password_is_valid('a23456789')
def test_password_length(): """it should raise a suitable exception if the password is not longer than 8 characters""" with pytest.raises(Exception, match='password should be longer than 8 characters'): password_checker.password_is_valid('Aa34')
def test_password_has_special_character(): with pytest.raises( Exception, match="password should have at least one special character"): password_is_valid("Joyjk123456")
def test_password_has_digit(): with pytest.raises(Exception, match="password should have a digit"): password_is_valid("Joymasemola")
def test_password_has_upper(): with pytest.raises(Exception, match="password should have an uppercase character"): password_is_valid("joy123@45678")
def test_password_exists(): with pytest.raises(Exception, match="password should exist"): pass_check.password_is_valid("")
def test_password_exists(): """it should raise a suitable exception if the password does not exist""" with pytest.raises(Exception, match='password should exist'): password_checker.password_is_valid('')
def test_password_length(): with pytest.raises(Exception, match="password should be longer than 8 characters"): password_is_valid("Jo13")