19 lines
1.4 KiB
Python
19 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
import argparse,json,sys,tempfile,unittest
|
|
from pathlib import Path
|
|
P=argparse.ArgumentParser();P.add_argument("--root",type=Path,required=True);R=P.parse_args().root;sys.path.insert(0,str(R/"tools"))
|
|
import phase10dt_metadata_runner as m # noqa:E402
|
|
def rec(d):return {"active":True,"run_id":"T","target":"192.0.2.1","port":9021,"artifact_size":m.ARTIFACT_SIZE,"artifact_sha256":m.ARTIFACT_SHA256,"output_path":str((d/"o").resolve()),"receipt_path":str((d/"r").resolve()),"not_before":1,"not_after":3,"one_connection":True,"one_transfer":True,"one_execution":True,"result_receive":True,"four_exact_metadata_reads":True,"possible_atime_effect_acknowledged":True,"app_pkg_read":False,"backup_read":False,"persistent_device_write":False,"installation":False,"autoload":False,"retry":False,"reconnect":False}
|
|
class Tests(unittest.TestCase):
|
|
def test_inactive(self):
|
|
v=json.loads((R/"manifests/retroarch/phase-1.0dt-inactive-metadata-runner.json").read_text())
|
|
with self.assertRaises(m.RunnerError):m.validate(v,v,2)
|
|
def test_exact(self):
|
|
with tempfile.TemporaryDirectory() as x:v=rec(Path(x));self.assertEqual(m.validate(v,dict(v),2)["run_id"],"T")
|
|
def test_package_forbidden(self):
|
|
with tempfile.TemporaryDirectory() as x:
|
|
v=rec(Path(x));v["app_pkg_read"]=True
|
|
with self.assertRaises(m.RunnerError):m.validate(v,v,2)
|
|
if __name__=="__main__":unittest.main(argv=[__file__])
|