From b97a48af1be2107406d860285a7adfdc50374837 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 26 Oct 2021 21:02:45 -0400 Subject: [PATCH 1/2] added cli option testing --- qbay_test/frontend/__init__.py | 0 qbay_test/frontend/test_login/__init__.py | 0 qbay_test/frontend/test_login/test_login.in | 3 ++ qbay_test/frontend/test_login/test_login.out | 1 + qbay_test/frontend/test_login/test_login.py | 30 ++++++++++++++++++++ 5 files changed, 34 insertions(+) create mode 100644 qbay_test/frontend/__init__.py create mode 100644 qbay_test/frontend/test_login/__init__.py create mode 100644 qbay_test/frontend/test_login/test_login.in create mode 100644 qbay_test/frontend/test_login/test_login.out create mode 100644 qbay_test/frontend/test_login/test_login.py diff --git a/qbay_test/frontend/__init__.py b/qbay_test/frontend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/qbay_test/frontend/test_login/__init__.py b/qbay_test/frontend/test_login/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/qbay_test/frontend/test_login/test_login.in b/qbay_test/frontend/test_login/test_login.in new file mode 100644 index 0000000..bb05169 --- /dev/null +++ b/qbay_test/frontend/test_login/test_login.in @@ -0,0 +1,3 @@ +1 +test0@test.com +123456 diff --git a/qbay_test/frontend/test_login/test_login.out b/qbay_test/frontend/test_login/test_login.out new file mode 100644 index 0000000..93a0036 --- /dev/null +++ b/qbay_test/frontend/test_login/test_login.out @@ -0,0 +1 @@ +Welcome. Please type 1 to login. Or type 2 register.Please input emailPlease input password:welcome u0 \ No newline at end of file diff --git a/qbay_test/frontend/test_login/test_login.py b/qbay_test/frontend/test_login/test_login.py new file mode 100644 index 0000000..996ad8f --- /dev/null +++ b/qbay_test/frontend/test_login/test_login.py @@ -0,0 +1,30 @@ +from os import popen +from pathlib import Path +import subprocess + +# get expected input/output file +current_folder = Path(__file__).parent + + +# read expected in/out +expected_in = open(current_folder.joinpath( + 'test_login.in')) +expected_out = open(current_folder.joinpath( + 'test_login.out')).read() + +print(expected_out) + + +def test_login(): + """capsys -- object created by pytest to + capture stdout and stderr""" + + # pip the input + output = subprocess.run( + ['python', '-m', 'qbay'], + stdin=expected_in, + capture_output=True, + ).stdout.decode() + + print('outputs', output) + assert output.strip() == expected_out.strip() From 27c01b38ed5fb427ebff80b611e8737168ef9c66 Mon Sep 17 00:00:00 2001 From: steven Date: Mon, 24 Oct 2022 14:39:40 -0400 Subject: [PATCH 2/2] updated example test case --- qbay_test/frontend/test_login/test_login.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qbay_test/frontend/test_login/test_login.out b/qbay_test/frontend/test_login/test_login.out index 93a0036..eb14d50 100644 --- a/qbay_test/frontend/test_login/test_login.out +++ b/qbay_test/frontend/test_login/test_login.out @@ -1 +1 @@ -Welcome. Please type 1 to login. Or type 2 register.Please input emailPlease input password:welcome u0 \ No newline at end of file +Welcome. Please type 1 to login. Or type 2 register. Or type 3 to exitPlease input emailPlease input password:welcome u0 \ No newline at end of file