aboutsummaryrefslogtreecommitdiff
path: root/benchmark/agbenchmark/challenges/verticals/code/2_password_generator/custom_python/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/agbenchmark/challenges/verticals/code/2_password_generator/custom_python/test.py')
-rw-r--r--benchmark/agbenchmark/challenges/verticals/code/2_password_generator/custom_python/test.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/benchmark/agbenchmark/challenges/verticals/code/2_password_generator/custom_python/test.py b/benchmark/agbenchmark/challenges/verticals/code/2_password_generator/custom_python/test.py
new file mode 100644
index 000000000..86ce911ab
--- /dev/null
+++ b/benchmark/agbenchmark/challenges/verticals/code/2_password_generator/custom_python/test.py
@@ -0,0 +1,25 @@
+import unittest
+
+import password_generator
+
+
+class TestPasswordGenerator(unittest.TestCase):
+ def test_password_length(self):
+ for i in range(8, 17):
+ password = password_generator.generate_password(i)
+ self.assertEqual(len(password), i)
+
+ def test_value_error(self):
+ with self.assertRaises(ValueError):
+ password_generator.generate_password(7)
+ with self.assertRaises(ValueError):
+ password_generator.generate_password(17)
+
+ def test_password_content(self):
+ password = password_generator.generate_password()
+ self.assertTrue(any(c.isdigit() for c in password))
+ self.assertTrue(any(c in password_generator.string.punctuation for c in password))
+
+
+if __name__ == "__main__":
+ unittest.main()