From 260ce435b05e5696142df56562d4c525614fb2a6 Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sun, 19 Dec 2021 11:48:42 +0000 Subject: [PATCH] Initial commit --- .gitignore | 3 +++ main.py | 16 ++++++++++++++++ requirements.txt | 1 + slinky/__init__.py | 7 +++++++ tests/__init__.py | 0 tests/test_slinky.py | 16 ++++++++++++++++ 6 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 main.py create mode 100644 requirements.txt create mode 100644 slinky/__init__.py create mode 100644 tests/__init__.py create mode 100644 tests/test_slinky.py 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)