commit 260ce435b05e5696142df56562d4c525614fb2a6 Author: Scott Wallace Date: Sun Dec 19 11:48:42 2021 +0000 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e5f17d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.pyenv/ +.vscode/ +__pycache__/ diff --git a/main.py b/main.py new file mode 100644 index 0000000..d9a5362 --- /dev/null +++ b/main.py @@ -0,0 +1,16 @@ +import sys + +from flask.wrappers import Response + + +def url_home() -> Response: + ... + + +if __name__ == '__main__': + + def main() -> int: + # Start Flask + return 0 + + sys.exit(main()) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/slinky/__init__.py b/slinky/__init__.py new file mode 100644 index 0000000..6899629 --- /dev/null +++ b/slinky/__init__.py @@ -0,0 +1,7 @@ +import random +import string + +def random_string(length: int = 4) -> str: + allowed_chars: str = string.ascii_letters + string.digits + + return ''.join(random.SystemRandom().choice(allowed_chars) for _ in range(length)) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_slinky.py b/tests/test_slinky.py new file mode 100644 index 0000000..2383468 --- /dev/null +++ b/tests/test_slinky.py @@ -0,0 +1,16 @@ +from unittest import TestCase + +import slinky + + +class TestSlinky(TestCase): + def test_random_string(self) -> None: + """ + Ensure the random string generates correctly + """ + + self.assertEqual(4, len(slinky.random_string())) + self.assertEqual(8, len(slinky.random_string(8))) + self.assertEqual(16, len(slinky.random_string(16))) + self.assertEqual(64, len(slinky.random_string(64))) + self.assertTrue(slinky.random_string(128).isalnum(), True)