From f82415c0aaaf8d4e465ce7375982e79eb2882c00 Mon Sep 17 00:00:00 2001 From: vky Date: Wed, 22 Jun 2022 12:29:32 +0200 Subject: [PATCH 1/3] first draft of test template --- modules/test_class.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 modules/test_class.py diff --git a/modules/test_class.py b/modules/test_class.py new file mode 100644 index 0000000..f7d38a8 --- /dev/null +++ b/modules/test_class.py @@ -0,0 +1,40 @@ +class Test: + def __init__(self, args, agnpath, test_data): + """ + Simple test template. + :param args: List of arguments + :type args: argparse.Namespace + :param agnpath: The path to the discord folder + :type agnpath: agnostic_path.AgnosticPath + :param test_data: The data to be tested + :type test_data: str + """ + self.ptb = args.ptb + self.agnostic_path = agnpath + self.os_name = agnpath.os + self.main_path = agnpath.main_path + self.test_data = test_data + self.is_infected = False + self.status_code = 0 + self.status = "Test not yet initialized." + self.return_code_dict = { + 0: "The test was not run", + 1: "The test is running", + 2: "The test is a success", + 3: "Test has failed", + 4: "Test found problems", + } + + def get_status_code(self): + """ + :return: Status code at the time of call. + :rtype: int + """ + return self.status_code + + def get_status(self): + """ + :return: Status at the time of call. + :rtype: str + """ + return self.status From fe1a7c999d6020a10b651d8d0a33f08010d3347f Mon Sep 17 00:00:00 2001 From: vky Date: Wed, 22 Jun 2022 13:52:08 +0200 Subject: [PATCH 2/3] added get_status_from_code and set_status --- modules/test_class.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/test_class.py b/modules/test_class.py index f7d38a8..54a8658 100644 --- a/modules/test_class.py +++ b/modules/test_class.py @@ -38,3 +38,21 @@ class Test: :rtype: str """ return self.status + + def get_status_from_code(self): + """ + :return: Description of the status code + :rtype: str + """ + return self.return_code_dict[self.status_code] + + def set_status(self, statuscode: int): + """ + Sets a new status code. + :param statuscode: Status code to set + :type statuscode: int + :return: new status code + :rtype: int + """ + self.status_code = statuscode + return self.status_code From 78d262dafcac9e1d360e6acc2cb2d02d25252692 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 22 Jun 2022 15:41:48 +0200 Subject: [PATCH 3/3] Update and rename test_class.py to test_template.py --- modules/{test_class.py => test_template.py} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename modules/{test_class.py => test_template.py} (90%) diff --git a/modules/test_class.py b/modules/test_template.py similarity index 90% rename from modules/test_class.py rename to modules/test_template.py index 54a8658..e9f2d66 100644 --- a/modules/test_class.py +++ b/modules/test_template.py @@ -1,4 +1,4 @@ -class Test: +class TestTemplate: def __init__(self, args, agnpath, test_data): """ Simple test template. @@ -39,12 +39,13 @@ class Test: """ return self.status - def get_status_from_code(self): + @static + def get_status_from_code(code): """ :return: Description of the status code :rtype: str """ - return self.return_code_dict[self.status_code] + return self.return_code_dict[code] def set_status(self, statuscode: int): """ @@ -55,4 +56,5 @@ class Test: :rtype: int """ self.status_code = statuscode + self.status = self.get_status_from_code(statuscode) return self.status_code