diff --git a/docs/system_base/exempi/tc_exempi_test_fun001.yaml b/docs/system_base/exempi/tc_exempi_test_fun001.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4e299764f9e22dec2262c554e00e90c8b6c0ddeb --- /dev/null +++ b/docs/system_base/exempi/tc_exempi_test_fun001.yaml @@ -0,0 +1,24 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, exempi +用例描述: 测试 exempi XMP元数据处理工具基础功能 +修改人: douzhichong + +前置条件: +- 安装 exempi 软件包 + +测试步骤: +- ## 测试基础命令功能 + - 验证 exempi 命令存在 [命令: which exempi] + - 查看 exempi 帮助信息 [命令: exempi -h] + - 验证帮助信息包含版本信息和所有必需选项 + - 验证 exempi 软件包已安装 [命令: rpm -q exempi] + +期望结果: +- exempi 命令存在且可执行 +- 帮助信息包含 "Exempi version" 标识 +- 帮助信息包含所有必需选项:-h, -R, -x, -X, -w, -o, -g, -s, -v +- exempi 软件包已正确安装 \ No newline at end of file diff --git a/docs/system_base/exempi/tc_exempi_test_fun002.yaml b/docs/system_base/exempi/tc_exempi_test_fun002.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4af43e0adce01f1a14859d79252173085e01cd0b --- /dev/null +++ b/docs/system_base/exempi/tc_exempi_test_fun002.yaml @@ -0,0 +1,24 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, exempi +用例描述: 测试 exempi XML处理功能及基本选项 +修改人: douzhichong + +前置条件: +- 安装 exempi 软件包 + +测试步骤: +- ## 测试XML处理功能 + - 创建XML测试文件 [内容: Test DocumentTest Author] + - 使用 -x 选项dump XML包 [命令: exempi -x test.xml] + - 使用 -x -p 选项dump带包装器的XML包 [命令: exempi -x -p test.xml] + - 使用 -X 选项标记文件为XMP [命令: exempi -X test.xml] + - 使用 -R 选项不协调读取 [命令: exempi -R test.xml] + - 组合使用 -X 和 -R 选项 [命令: exempi -X -R test.xml] + +期望结果: +- 所有命令成功执行 +- XML处理功能正常工作 \ No newline at end of file diff --git a/docs/system_base/exempi/tc_exempi_test_fun003.yaml b/docs/system_base/exempi/tc_exempi_test_fun003.yaml new file mode 100644 index 0000000000000000000000000000000000000000..39ed7540fc5ebad938efc8bb295f38ac2032b52f --- /dev/null +++ b/docs/system_base/exempi/tc_exempi_test_fun003.yaml @@ -0,0 +1,25 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, exempi +用例描述: 测试 exempi 元数据属性操作功能 +修改人: douzhichong + +前置条件: +- 安装 exempi 软件包 + +测试步骤: +- ## 测试属性操作功能 + - 创建测试文件 [内容: Test file content] + - 使用 -o 选项输出到文件 [命令: exempi -o test_output.txt test.txt] + - 尝试获取常见属性值 [命令: exempi -g title test.txt; exempi -g creator test.txt; exempi -g subject test.txt] + - 组合使用 -g 和 -o 选项 [命令: exempi -g title -o test_output.txt test.txt] + - 使用 -s 和 -v 设置属性值 [命令: exempi -s "title" -v "Test Title" -o test_output.txt test.txt] + - 使用 -w 选项原地写入 [命令: exempi -s "creator" -v "Test Author" -w test.txt.bak] + - 使用 -n 选项创建新命名空间 [命令: exempi -n "http://example.com/ns/" "ex" -o test_output.txt test.txt] + +期望结果: +- 属性操作命令能够执行 +- 文件操作功能正常工作 \ No newline at end of file diff --git a/docs/system_base/exempi/tc_exempi_test_fun004.yaml b/docs/system_base/exempi/tc_exempi_test_fun004.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a768cae622a3bb08701798200c84a36f20888c47 --- /dev/null +++ b/docs/system_base/exempi/tc_exempi_test_fun004.yaml @@ -0,0 +1,32 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local, exempi +用例描述: 测试 exempi 边界情况和错误处理 +修改人: douzhichong + +前置条件: +- 安装 exempi 软件包 + +测试步骤: +- ## 测试边界情况 + - 尝试处理不存在的文件 [命令: exempi nonexistent_file.txt] + - 创建空文件 [命令: touch test_empty.txt] + - 处理空文件 [命令: exempi test_empty.txt] + - 使用无效选项 [命令: exempi --invalid-option] + +- ## 测试多文件处理 + - 创建多个测试文件 [内容: Test file 0; Test file 1] + - 同时处理多个文件 [命令: exempi test_multi_0.txt test_multi_1.txt] + - 使用 -x 选项处理多个文件 [命令: exempi -x test_multi_0.txt test_multi_1.txt] + +- ## 验证帮助信息格式 + - 查看帮助信息 [命令: exempi -h] + - 验证帮助信息格式正确 [包含: exempi { -h | [ -R ] [ -X ]] + +期望结果: +- 边界情况处理合理 +- 多文件处理功能正常工作 +- 帮助信息格式正确 \ No newline at end of file diff --git a/tests/system_base/exempi/tc_exempi_test_fun001.py b/tests/system_base/exempi/tc_exempi_test_fun001.py new file mode 100644 index 0000000000000000000000000000000000000000..d0d1bf3de9833b7e1a91253b5631d0bf02d5c840 --- /dev/null +++ b/tests/system_base/exempi/tc_exempi_test_fun001.py @@ -0,0 +1,51 @@ +""" +@File: tc_exempi_test_fun001.py +@Time: 2025/12/12 16:00:00 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" + +import subprocess +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_exempi_test_fun001.yaml for details + + :avocado: tags=P1,noarch,local,exempi + """ + PARAM_DIC = {"pkg_name": "exempi"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.files_to_clean = [] + + def test(self): + code, result = self.cmd('which exempi') + self.assertEqual(code, 0, "exempi command not found") + + try: + result = subprocess.run('exempi -h', shell=True, capture_output=True, text=True, timeout=5) + output = result.stdout + result.stderr + self.assertIn('Exempi version', output, "Version information not found") + + required_options = ['-h', '-R', '-x', '-X', '-w', '-o', '-g', '-s', '-v'] + for option in required_options: + self.assertIn(option, output, f"Help missing {option} option") + except Exception as e: + self.fail(f"Failed to run exempi -h: {str(e)}") + + try: + result = subprocess.run('rpm -q exempi', shell=True, capture_output=True, text=True, timeout=5) + self.assertEqual(result.returncode, 0, "exempi package not installed") + except Exception as e: + self.fail(f"Failed to check exempi package: {str(e)}") + + def tearDown(self): + for file in self.files_to_clean: + self.cmd(f'rm -f {file}') + super().tearDown(self.PARAM_DIC) \ No newline at end of file diff --git a/tests/system_base/exempi/tc_exempi_test_fun002.py b/tests/system_base/exempi/tc_exempi_test_fun002.py new file mode 100644 index 0000000000000000000000000000000000000000..719611b824962537a58c8f27dadfddd10b232f86 --- /dev/null +++ b/tests/system_base/exempi/tc_exempi_test_fun002.py @@ -0,0 +1,51 @@ +""" +@File: tc_exempi_test_fun002.py +@Time: 2025/12/12 16:01:00 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_exempi_test_fun002.yaml for details + + :avocado: tags=P1,noarch,local,exempi + """ + PARAM_DIC = {"pkg_name": "exempi"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.files_to_clean = [] + + def test(self): + test_file = "test.xml" + test_content = """ + + Test Document + Test Author +""" + + with open(test_file, 'w') as f: + f.write(test_content) + self.files_to_clean.append(test_file) + + code, result = self.cmd(f'exempi -x {test_file}') + + code, result = self.cmd(f'exempi -x -p {test_file}') + + code, result = self.cmd(f'exempi -X {test_file}') + + code, result = self.cmd(f'exempi -R {test_file}') + + code, result = self.cmd(f'exempi -X -R {test_file}') + + def tearDown(self): + for file in self.files_to_clean: + self.cmd(f'rm -f {file}') + super().tearDown(self.PARAM_DIC) \ No newline at end of file diff --git a/tests/system_base/exempi/tc_exempi_test_fun003.py b/tests/system_base/exempi/tc_exempi_test_fun003.py new file mode 100644 index 0000000000000000000000000000000000000000..f1c0192269e3bff7415c225de469103c1cff7afe --- /dev/null +++ b/tests/system_base/exempi/tc_exempi_test_fun003.py @@ -0,0 +1,57 @@ +""" +@File: tc_exempi_test_fun003.py +@Time: 2025/12/12 16:02:00 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_exempi_test_fun003.yaml for details + + :avocado: tags=P1,noarch,local,exempi + """ + PARAM_DIC = {"pkg_name": "exempi"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.files_to_clean = [] + + def test(self): + test_file = "test.txt" + test_content = "Test file content" + + with open(test_file, 'w') as f: + f.write(test_content) + self.files_to_clean.append(test_file) + + output_file = "test_output.txt" + self.files_to_clean.append(output_file) + + code, result = self.cmd(f'exempi -o {output_file} {test_file} 2>&1 || true') + + common_props = ['title', 'creator', 'subject'] + for prop in common_props: + code, result = self.cmd(f'exempi -g {prop} {test_file} 2>&1 || true') + + code, result = self.cmd(f'exempi -g title -o {output_file} {test_file} 2>&1 || true') + + code, result = self.cmd(f'exempi -s "title" -v "Test Title" -o {output_file} {test_file} 2>&1 || true') + + code, result = self.cmd(f'cp {test_file} {test_file}.bak') + self.files_to_clean.append(f'{test_file}.bak') + + code, result = self.cmd(f'exempi -s "creator" -v "Test Author" -w {test_file}.bak 2>&1 || true') + + code, result = self.cmd(f'exempi -n "http://example.com/ns/" "ex" -o {output_file} {test_file} 2>&1 || true') + + def tearDown(self): + for file in self.files_to_clean: + self.cmd(f'rm -f {file}') + super().tearDown(self.PARAM_DIC) \ No newline at end of file diff --git a/tests/system_base/exempi/tc_exempi_test_fun004.py b/tests/system_base/exempi/tc_exempi_test_fun004.py new file mode 100644 index 0000000000000000000000000000000000000000..85eaee6fd6e44fafe41816940228eb2cac7158d0 --- /dev/null +++ b/tests/system_base/exempi/tc_exempi_test_fun004.py @@ -0,0 +1,71 @@ +""" +@File: tc_exempi_test_fun004.py +@Time: 2025/12/12 16:03:00 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" + +import subprocess +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_exempi_test_fun004.yaml for details + + :avocado: tags=P1,noarch,local,exempi + """ + PARAM_DIC = {"pkg_name": "exempi"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.files_to_clean = [] + + def test(self): + empty_file = "test_empty.txt" + with open(empty_file, 'w') as f: + f.write("") + self.files_to_clean.append(empty_file) + + try: + result = subprocess.run(f'exempi {empty_file}', shell=True, capture_output=True, text=True, timeout=5) + except Exception: + pass + + try: + result = subprocess.run('exempi --invalid-option', shell=True, capture_output=True, text=True, timeout=5) + except Exception: + pass + + files = [] + for i in range(2): + file_name = f"test_multi_{i}.txt" + with open(file_name, 'w') as f: + f.write(f"Test file {i}") + self.files_to_clean.append(file_name) + files.append(file_name) + + try: + result = subprocess.run(f'exempi {" ".join(files)}', shell=True, capture_output=True, text=True, timeout=5) + except Exception: + pass + + try: + result = subprocess.run(f'exempi -x {" ".join(files)}', shell=True, capture_output=True, text=True, timeout=5) + except Exception: + pass + + try: + result = subprocess.run('exempi -h', shell=True, capture_output=True, text=True, timeout=5) + output = result.stdout + result.stderr + self.assertIn('exempi { -h | [ -R ] [ -X ]', output, "Help format incorrect") + except Exception as e: + self.fail(f"Failed to run exempi -h: {str(e)}") + + def tearDown(self): + for file in self.files_to_clean: + self.cmd(f'rm -f {file}') + super().tearDown(self.PARAM_DIC) \ No newline at end of file