Commit 7d59d329 authored by quyuan's avatar quyuan

add cli test

parent dc5684bf
import os
conf = {
"code_path": os.environ.get('CI_PROJECT_DIR'),
"pdf_dev_path" : os.environ.get('CI_PROJECT_DIR') + "/tests/pdf_dev",
"pdf_res_path": "/home/quyuan/code/Magic-PDF/Magic-PDF/Magic-PDF/data"
}
import subprocess
def check_shell(cmd):
res = subprocess.check_output(cmd, shell=True)
assert res == 0
def count_folders_and_check_contents(directory):
# 获取目录下的所有文件和文件夹
contents = os.listdir(directory)
folder_count = 0
for item in contents:
# 检查是否为文件夹
if os.path.isdir(os.path.join(directory, item)):
folder_count += 1
# 检查文件夹是否为空
folder_path = os.path.join(directory, item)
assert os.listdir(folder_path) is not None
assert folder_count == 3
This source diff could not be displayed because it is too large. You can view the blob instead.
import pytest
import os
from conf import conf
import subprocess
from lib import common
import logging
pdf_res_path = conf.conf["pdf_res_path"]
code_path = conf.conf["code_path"]
pdf_dev_path = conf.conf["pdf_dev_path"]
class TestCli:
def test_pdf_specify_dir(self):
"""
输入pdf和指定目录的模型结果
"""
cmd = 'cd %s && export PYTHONPATH=. && find %s -type f -name "*.pdf" | xargs -I{} python magic_pdf/cli/magicpdf.py pdf-command --pdf {}' % (code_path, pdf_dev_path)
logging.info(cmd)
common.check_shell(cmd)
common.count_folders_and_check_contents(pdf_res_path)
def test_pdf_specify_jsonl(self):
"""
输入jsonl
"""
cmd = "cd %s && export PYTHONPATH=. && python "
if __name__ == "__main__":
pytest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment