[+] add tests for pr34
This commit is contained in:
parent
62063a1448
commit
731c507b95
3
Makefile
3
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;
|
||||
|
@ -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()
|
||||
CLI().run()
|
||||
|
@ -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])
|
||||
|
0
python/online/fxreader/pr34/tests/__init__.py
Normal file
0
python/online/fxreader/pr34/tests/__init__.py
Normal file
19
python/online/fxreader/pr34/tests/test_crypto.py
Normal file
19
python/online/fxreader/pr34/tests/test_crypto.py
Normal file
@ -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',
|
||||
]
|
||||
)
|
Loading…
Reference in New Issue
Block a user