From 2013ad0f9991875fc5ac81f16eef03867f704508 Mon Sep 17 00:00:00 2001 From: Season Zou Date: Wed, 27 Sep 2023 22:14:57 +0800 Subject: [PATCH 1/4] zjj first test --- .github/workflows/ut.yml | 6 ++++++ dplc/motto/motto.py | 27 +++++++++++++++++++++++++-- tests/test_JijieZou.py | 25 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/test_JijieZou.py diff --git a/.github/workflows/ut.yml b/.github/workflows/ut.yml index 84540e0..8824b97 100644 --- a/.github/workflows/ut.yml +++ b/.github/workflows/ut.yml @@ -54,3 +54,9 @@ jobs: source $CONDA/bin/activate cd tests pytest test_YuhangWang.py -v -n auto + + - name: Test JijieZou's codes. + run: | + source $CONDA/bin/activate + cd tests + pytest test_JijieZou.py -v -n auto \ No newline at end of file diff --git a/dplc/motto/motto.py b/dplc/motto/motto.py index 889fd87..21babf5 100644 --- a/dplc/motto/motto.py +++ b/dplc/motto/motto.py @@ -5,7 +5,7 @@ def verifyMotto(P: argparse.Namespace): name = P.name motto = P.motto - is_verified = False + is_verified = True if name == "DPTechnology": is_verified = verifyMottoDPTechnology(motto) elif name == "YuzhiZhang": @@ -18,11 +18,13 @@ def verifyMotto(P: argparse.Namespace): is_verified = verifyMottoYiboWang(motto) elif name == "YuhangWang": is_verified = verifyMottoYuhangWang(motto) + elif name == "JijieZou": + is_verified = verifyMottoJijieZou(motto) else: assert RuntimeError("Your input name is not valid for this test!") if is_verified: - print(f"Your input '{motto}' mˇatches with {name}'s motto! ") + print(f"Your input '{motto}' matches with {name}'s motto! ") else: print(f"Your input '{motto}' doesn't match with {name}'s motto! ") @@ -149,3 +151,24 @@ def verifyMottoYuhangWang(public_string: str) -> bool: False: otherwise. ''' return md5_encoding(public_string) == "48c9598399fca3a74a1f73a641651a25" + +def verifyMottoJijieZou(public_string: str) -> bool: + ''' + + Verify if a public string is Yuzhi Zhang's motto. + + Parameters: + --------- + public_string: string, a public string from user input. + + Returns: + ------- + is_verified: bool, if the string matches with Yuzhi Zhang's motto, + return True. + ''' + md5_string = md5_encoding(public_string) + is_verified = False + if md5_string == "fef14ee8266b9bafce64579da7066385": + is_verified = True + return is_verified + diff --git a/tests/test_JijieZou.py b/tests/test_JijieZou.py new file mode 100644 index 0000000..865db2f --- /dev/null +++ b/tests/test_JijieZou.py @@ -0,0 +1,25 @@ +import unittest +from dplc.motto.motto import verifyMottoJijieZou + + +class TestVerifyMottoJijieZou(unittest.TestCase): + + @classmethod + def setUpClass(self): + pass + + def test_verifyMottoJijieZou_right(self): + right_motto = "You know who" + self.assertEqual(verifyMottoJijieZou(right_motto), True) + + def test_verifyMottoJijieZou_wrong(self): + wrong_motto = "你猜" + self.assertEqual(verifyMottoJijieZou(wrong_motto), False) + + @classmethod + def tearDownClass(cls): + pass + + +if __name__ == '__main__': + unittest.main() From bf224525d0fa9cc0d0c4596c79252ce87b00eccf Mon Sep 17 00:00:00 2001 From: Season Zou Date: Thu, 28 Sep 2023 09:52:21 +0800 Subject: [PATCH 2/4] add personal name in tutorial1_unittest.md --- doc/tutorial1_unittest.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/tutorial1_unittest.md b/doc/tutorial1_unittest.md index 6d31e83..66e869d 100644 --- a/doc/tutorial1_unittest.md +++ b/doc/tutorial1_unittest.md @@ -9,3 +9,4 @@ https://dptechnology.feishu.cn/wiki/wikcn3Qu95x0ItmltztkIvgDEec# 4. Yibo Wang 5. Yuhang Wang 6. Qiangqiang Gu +7. Jijie Zou From 22569d4f5e1ca8211b722eb113b6ae709a4e1b21 Mon Sep 17 00:00:00 2001 From: Season Zou Date: Thu, 28 Sep 2023 10:01:24 +0800 Subject: [PATCH 3/4] fix is_verified setting in verifyMotto --- dplc/motto/motto.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dplc/motto/motto.py b/dplc/motto/motto.py index 1277e78..c3f5d62 100644 --- a/dplc/motto/motto.py +++ b/dplc/motto/motto.py @@ -5,7 +5,7 @@ def verifyMotto(P: argparse.Namespace): name = P.name motto = P.motto - is_verified = True + is_verified = False if name == "DPTechnology": is_verified = verifyMottoDPTechnology(motto) elif name == "YuzhiZhang": From daa430b6e97844db2ca9e8695e954f97e314164f Mon Sep 17 00:00:00 2001 From: Season Zou Date: Thu, 28 Sep 2023 10:04:06 +0800 Subject: [PATCH 4/4] fix docstring in verifyMottoJijieZou --- dplc/motto/motto.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dplc/motto/motto.py b/dplc/motto/motto.py index c3f5d62..d40d1a3 100644 --- a/dplc/motto/motto.py +++ b/dplc/motto/motto.py @@ -180,7 +180,7 @@ def verifyMottoQiangqiangGu(public_string: str) -> bool: def verifyMottoJijieZou(public_string: str) -> bool: ''' - Verify if a public string is Qiangqiang Gu's motto. + Verify if a public string is Jijie Zou's motto. Parameters: --------- @@ -188,8 +188,8 @@ def verifyMottoJijieZou(public_string: str) -> bool: Returns: ------- - Verify if a public string is Qiangqiang Gu's motto. - is_verified: bool, if the string matches with Qiangqiang Gu's motto, + Verify if a public string is Jijie Zou's motto. + is_verified: bool, if the string matches with Jijie Zou's motto, return True. ''' md5_string = md5_encoding(public_string)