// test/03a_cameraPose.test.js const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); describe('Camera Pose Script', () => { const projectRoot = path.resolve(__dirname, '..'); const scriptPath = path.resolve(projectRoot, 'programs/03a_cameraPose.py'); const timestamp = 1778819665744; const sceneFile = path.resolve(projectRoot, `test/data/screenShots/scene_${timestamp}.json`); const robotDir = path.resolve(projectRoot, 'test/data/robot'); const robotFile = path.resolve(robotDir, 'robot.json'); const outputFile = path.resolve(projectRoot, `test/data/screenShots/scene_${timestamp}_cameras.json`); test('should exist and be executable', () => { expect(fs.existsSync(scriptPath)).toBe(true); }); test('should have scene file', () => { expect(fs.existsSync(sceneFile)).toBe(true); }); test('should have robot file', () => { expect(fs.existsSync(robotFile)).toBe(true); }); test('should compute camera poses with timestamp parameter', () => { // Führe das Python-Skript mit den korrekten Parametern aus const cmd = `python "${scriptPath}" -scene "${sceneFile}" -robot "${robotFile}" -out "${outputFile}"`; try { execSync(cmd, { stdio: 'inherit', cwd: projectRoot }); } catch (error) { throw new Error(`Failed to compute camera poses: ${error.message}`); } // Überprüfe, ob die erwartete Ausgabedatei erstellt wurde expect(fs.existsSync(outputFile)).toBe(true); // Prüfe den Inhalt der JSON-Datei const jsonData = JSON.parse(fs.readFileSync(outputFile, 'utf8')); expect(jsonData).toBeDefined(); expect(typeof jsonData).toBe('object'); expect(jsonData).toHaveProperty('camera_poses'); }); test('should handle timestamp parameter correctly', () => { expect(timestamp).toBe(1778819665744); }); });