From 2cd048c3f5419d0e0b396ca4e087ac6c5e5c7611 Mon Sep 17 00:00:00 2001 From: ziadahanass Date: Fri, 10 Jan 2025 07:17:44 -0800 Subject: [PATCH 1/2] password --- solutions/tests/test_password_strength.py | 34 +++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/solutions/tests/test_password_strength.py b/solutions/tests/test_password_strength.py index 14c84a14b..c80c38a84 100644 --- a/solutions/tests/test_password_strength.py +++ b/solutions/tests/test_password_strength.py @@ -27,24 +27,42 @@ def test_strong_password(self): self.assertEqual(password_strength("StrongP@ssw0rd"), "Strong password") def test_weak_password_no_uppercase(self): - """Test that a weak password with no uppercase letter returns 'Weak password'.""" - self.assertEqual(password_strength("weakpass1@"), "Weak password") + """Test that a weak password with no uppercase letter returns 'Missing uppercase letter'.""" + self.assertEqual(password_strength("weakpass1@"), "Missing uppercase letter") def test_weak_password_no_special_char(self): - """Test that a weak password with no special character returns 'Weak password'.""" - self.assertEqual(password_strength("NoSpecial123"), "Weak password") + """Test that a weak password with no special character returns 'Missing special character'.""" + self.assertEqual(password_strength("NoSpecial123"), "Missing special character") def test_weak_password_too_short(self): - """Test that a short password returns 'Weak password'.""" - self.assertEqual(password_strength("Short1!"), "Weak password") + """Test that a short password returns 'Password too short'.""" + self.assertEqual(password_strength("Short1!"), "Password too short") def test_strong_password_with_special_characters(self): """Test that a valid password with all requirements returns 'Strong password'.""" self.assertEqual(password_strength("GoodPassword1@"), "Strong password") def test_weak_password_missing_special_characters(self): - """Test that a password missing special characters returns 'Weak password'.""" - self.assertEqual(password_strength("NoSpecial123"), "Weak password") + """Test that a password missing special characters returns 'Missing special character'.""" + self.assertEqual(password_strength("NoSpecial123"), "Missing special character") + + def test_empty_password(self): + """Test that an empty password returns 'Password too short'.""" + self.assertEqual(password_strength(""), "Password too short") + + def test_password_with_only_digits(self): + """Test that a password with only digits returns 'Missing uppercase letter'.""" + self.assertEqual(password_strength("12345678"), "Missing uppercase letter") + + def test_password_with_only_special_characters(self): + """Test that a password with only special characters returns 'Missing uppercase letter'.""" + self.assertEqual(password_strength("!@#$%^&*"), "Missing uppercase letter") + + def test_invalid_input(self): + """Test that a non-string input raises an AssertionError.""" + with self.assertRaises(AssertionError) as context: + password_strength(12345) # Non-string input + self.assertEqual(str(context.exception), "Password must be a string") if __name__ == "__main__": From 6e65b5c21983edebdf34cc8c11c385ae226b4c63 Mon Sep 17 00:00:00 2001 From: ziadahanass Date: Sat, 11 Jan 2025 11:57:42 -0800 Subject: [PATCH 2/2] add_new_changes_tosolution_readme --- solutions/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solutions/README.md b/solutions/README.md index 453510597..42696557a 100644 --- a/solutions/README.md +++ b/solutions/README.md @@ -36,6 +36,8 @@ while corresponding test files are maintained in the `tests` folder. | `miles_to_kilometers.py` | Converting miles to kilometers| Obay | | `greatest_number.py` | Finding greatest number in a list| Razan | | `check_prime_number.py` | Given a positive int if it is a prime number| Özgür | +| `password_strength.py` | Checks the strength of a password| Anas | +| `decimal_to_binary.py` | Converts decimal to its equivalent binary| Anas | ---