arbeiten an unitTests
Abhängigkeit macht Probleme
This commit is contained in:
@@ -6,35 +6,46 @@ const path = require('path');
|
||||
describe('Build Scene JSON Script', () => {
|
||||
const scriptPath = 'programs/02_build_scene_json.py';
|
||||
const timestamp = 1778819665744;
|
||||
const testDir = './test/data/screenShots';
|
||||
const screenshotDir = path.join(__dirname, 'data', 'screenShots');
|
||||
const detectionFiles = [
|
||||
'snapshot_video0_1778819665744_aruco_detection.json',
|
||||
'snapshot_video1_1778819665744_aruco_detection.json',
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
detectionFiles.forEach((file) => {
|
||||
const src = path.join(screenshotDir, file);
|
||||
if (!fs.existsSync(src)) {
|
||||
throw new Error(`Missing test fixture detection file: ${src}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Keep the generated scene JSON in the screenshot directory for real-world behavior.
|
||||
});
|
||||
|
||||
test('should exist and be executable', () => {
|
||||
expect(fs.existsSync(scriptPath)).toBe(true);
|
||||
});
|
||||
|
||||
test('should build scene JSON with timestamp parameter', () => {
|
||||
// Überprüfe, ob der Test-Ordner existiert
|
||||
expect(fs.existsSync(testDir)).toBe(true);
|
||||
|
||||
// Führe das Python-Skript mit den korrekten Parametern aus
|
||||
const cmd = `python ${scriptPath} -timestamp ${timestamp} -dir ${testDir}`;
|
||||
|
||||
const cmd = `python ${scriptPath} -timestamp ${timestamp} -dir "${screenshotDir}"`;
|
||||
|
||||
try {
|
||||
//execSync(cmd, { stdio: 'inherit' });
|
||||
//execSync(cmd, { stdio: 'pipe' });
|
||||
execSync(cmd);
|
||||
console.log("TEST START", process.pid, Date.now());
|
||||
execSync(cmd, { stdio: 'inherit' });
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to build scene JSON: ${error.message}`);
|
||||
}
|
||||
// Überprüfe, ob die erwartete Ausgabedatei erstellt wurde
|
||||
const expectedJsonFile = `./test/data/screenShots/scene_${timestamp}.json`;
|
||||
|
||||
const expectedJsonFile = path.join(screenshotDir, `scene_${timestamp}.json`);
|
||||
expect(fs.existsSync(expectedJsonFile)).toBe(true);
|
||||
|
||||
// Prüfe den Inhalt der JSON-Datei
|
||||
|
||||
const jsonData = JSON.parse(fs.readFileSync(expectedJsonFile, 'utf8'));
|
||||
expect(jsonData).toBeDefined();
|
||||
expect(typeof jsonData).toBe('object');
|
||||
expect(jsonData.cameras).toBeDefined();
|
||||
expect(Object.keys(jsonData.cameras).sort()).toEqual(['0', '1']);
|
||||
});
|
||||
|
||||
test('should handle timestamp parameter correctly', () => {
|
||||
|
||||
Reference in New Issue
Block a user