diff --git a/Makefile b/Makefile index 279f0d4..2392d8d 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,9 @@ host_deps: python_lint: ./m.py mypy -- -f vscode 2>&1 | less +python_tests: + ./m.py tests + #python_clean_online_fxreader_vpn: # rm -fr \ # deps/com.github.aiortc.aiortc/src/online_fxreader/vpn/dist; diff --git a/python/cli.py b/python/cli.py index 26a704e..3e9e031 100644 --- a/python/cli.py +++ b/python/cli.py @@ -26,6 +26,7 @@ logger = logging.getLogger(__name__) class Command(enum.StrEnum): mypy = 'mypy' deploy_wheel = 'deploy:wheel' + tests = 'tests' @dataclasses.dataclass class Settings( @@ -145,8 +146,17 @@ class CLI(_cli.CLI): self.mypy( argv=args, ) + elif options.command is Command.tests: + for k, v in self.projects.items(): + subprocess.check_call([ + sys.executable, + '-m', + 'unittest', + 'online.fxreader.pr34.tests.test_crypto', + *args, + ], cwd=str(v.source_dir)) else: raise NotImplementedError if __name__ == '__main__': - CLI().run() \ No newline at end of file + CLI().run() diff --git a/python/online/fxreader/pr34/commands_typed/crypto.py b/python/online/fxreader/pr34/commands_typed/crypto.py index 721d81d..fb20856 100644 --- a/python/online/fxreader/pr34/commands_typed/crypto.py +++ b/python/online/fxreader/pr34/commands_typed/crypto.py @@ -45,7 +45,7 @@ class PasswordUtils: return (salt, hashed_secret) elif mode == 'base64': res_tuple = tuple(( - base64.b64encode(o, width=0).decode('utf-8') + base64.b64encode(o).decode('utf-8') for o in (salt, hashed_secret,) )) return (res_tuple[0], res_tuple[1]) diff --git a/python/online/fxreader/pr34/tests/__init__.py b/python/online/fxreader/pr34/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python/online/fxreader/pr34/tests/test_crypto.py b/python/online/fxreader/pr34/tests/test_crypto.py new file mode 100644 index 0000000..f4da055 --- /dev/null +++ b/python/online/fxreader/pr34/tests/test_crypto.py @@ -0,0 +1,19 @@ +from online.fxreader.pr34.commands_typed import crypto +import unittest + + +class TestCrypto(unittest.TestCase): + def test_password_utils(self): + salt = b'asdfasdfasdf' + + self.assertEqual( + crypto.PasswordUtils.encrypt( + 'blah', + mode='bytes', + salt=salt, + ), + [ + salt, + b'asdfasdf', + ] + )