Skip to content

Commit

Permalink
test exe
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukiy committed Sep 21, 2024
1 parent c64de07 commit 3630e0b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions unittest/test_exe.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
import os
import sys
import random
import string
import shutil
import subprocess
from glob import glob

# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
# from core.config import cfg
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from core.config import cfg


def test_javsp_exe():
cwd = os.getcwd()
dist_dir = os.path.normpath(os.path.join(os.path.dirname(__file__) + '/../dist'))
os.chdir(dist_dir)

size = 300 * 2**20
tmp_folder = 'TMP_' + ''.join(random.choices(string.ascii_uppercase, k=6))
size = cfg.File.ignore_video_file_less_than
tmp_folder = '.TMP_' + ''.join(random.choices(string.ascii_uppercase, k=6))
FILE = '300MAAN-642.RIP.f4v'
try:
os.system(f"fsutil file createnew {FILE} {size}")
r = subprocess.run(f"JavSP.exe --auto-exit --input . --output {tmp_folder}".split(), capture_output=True)
with open('xx.txt', 'wb') as f:
f.write(r.stderr)
assert r.returncode == 0, f"Non-zero exit code: {r.returncode}"
r = subprocess.run(f"JavSP.exe --auto-exit --input . --output {tmp_folder}".split(), capture_output=True, encoding='utf-8')
print(r.stdout, r.stderr.encode().decode("unicode_escape"), sep='\n')
r.check_returncode()
# Check generated files
files = glob(tmp_folder + '/**/*.*', recursive=True)
assert all('横宮七海' in i for i in files), "Actress name not found"
print('\n'.join(files))
# assert all('横宮七海' in i for i in files), "Actress name not found"
assert any(i.endswith('fanart.jpg') for i in files), "fanart not found"
assert any(i.endswith('poster.jpg') for i in files), "poster not found"
assert any(i.endswith('.f4v') for i in files), "video file not found"
Expand All @@ -36,4 +37,3 @@ def test_javsp_exe():
if os.path.exists(tmp_folder):
shutil.rmtree(tmp_folder)
os.chdir(cwd)

0 comments on commit 3630e0b

Please sign in to comment.