diff options
| author | zhaokun <[email protected]> | 2023-11-08 13:44:25 +0800 |
|---|---|---|
| committer | zhaokun <[email protected]> | 2023-11-08 13:44:25 +0800 |
| commit | 4e683d5703daf29810097b9961b5ce02420202ea (patch) | |
| tree | 4ad01d46a7417a14a8c8a9045e95d0387cf24388 /common/ui_read_data | |
| parent | 44ed57c3f0b5f83e2836aadeea34003f08867b08 (diff) | |
updatemain
Diffstat (limited to 'common/ui_read_data')
| -rw-r--r-- | common/ui_read_data/__init__.py | 0 | ||||
| -rw-r--r-- | common/ui_read_data/__pycache__/__init__.cpython-38.pyc | bin | 0 -> 143 bytes | |||
| -rw-r--r-- | common/ui_read_data/__pycache__/read_data.cpython-38.pyc | bin | 0 -> 2424 bytes | |||
| -rw-r--r-- | common/ui_read_data/read_data.py | 72 |
4 files changed, 72 insertions, 0 deletions
diff --git a/common/ui_read_data/__init__.py b/common/ui_read_data/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/common/ui_read_data/__init__.py diff --git a/common/ui_read_data/__pycache__/__init__.cpython-38.pyc b/common/ui_read_data/__pycache__/__init__.cpython-38.pyc Binary files differnew file mode 100644 index 00000000..29d8cfa5 --- /dev/null +++ b/common/ui_read_data/__pycache__/__init__.cpython-38.pyc diff --git a/common/ui_read_data/__pycache__/read_data.cpython-38.pyc b/common/ui_read_data/__pycache__/read_data.cpython-38.pyc Binary files differnew file mode 100644 index 00000000..8201539a --- /dev/null +++ b/common/ui_read_data/__pycache__/read_data.cpython-38.pyc diff --git a/common/ui_read_data/read_data.py b/common/ui_read_data/read_data.py new file mode 100644 index 00000000..52dea141 --- /dev/null +++ b/common/ui_read_data/read_data.py @@ -0,0 +1,72 @@ +import json +import os +from config.workpath import workdir + +class ReadData: + def __init__(self): + #json文件和测试文件目录 + self.workdir = workdir + self.testdata = "testdata" + self.ui_data = "ui_data" + self.profiles_data = "profiles_data" + # 以下是要读取数据的名称 + self.response_pages_name = "response_pages.json" + self.dns_records_name = "dns_records.json" + self.shaping_profile_name = "shaping_profiles.json" + + def _from_json(self, file): + """ + 从json中读取数据函数 + :param file: + :return: + """ + with open(file, "r", encoding="utf-8") as f: + data = json.load(f)["item"] + data = list(data) + return data + + def _abs_path(self, file_name): + """ + 重组路径 + :param file_name: + :return: + """ + file = os.path.join(self.workdir, self.testdata, self.ui_data, self.profiles_data, file_name) + return file + + @property + def read_response_pages(self): + file = self._abs_path(self.response_pages_name) + return self._from_json(file) + + @property + def read_dns_records(self): + file = self._abs_path(self.dns_records_name) + return self._from_json(file) + + @property + def read_shaping_profiles(self): + file = self._abs_path(self.shaping_profile_name) + return self._from_json(file) + + def read_data_profiles(self, file_name): + """ + 通用读取json数据方法 + :param file_name: + :return: + """ + file = self._abs_path(file_name) + return self._from_json(file) + + def generate_id(self, param): + """ + 测试用例中ids信息提取 + :param param: + :return: + """ + ids: str = param["ids"] + #print(ids) + return ids + +if __name__ == '__main__': + ReadData().read_dns_records
\ No newline at end of file |
