def test_kernel_from_cube_dict_expanded(monkeypatch, tmpdir, pvl_four_group, cube_kernels): monkeypatch.setenv('ISISROOT', str(tmpdir)) monkeypatch.setenv('ISIS3DATA', '/test/path') with open(tmpdir.join('IsisPreferences'), 'w+') as pvl_isisroot_file: pvl_isisroot_file.write(pvl_four_group) pvl_isisroot_file.flush() with tempfile.NamedTemporaryFile('r+') as cube: cube.write(cube_kernels) cube.flush() kernels = util.generate_kernels_from_cube(cube.name, expand=True, format_as='dict') assert kernels == OrderedDict([ ('TargetPosition', [ '/test/path/messenger/targetposition0', '/test/path/messenger/targetposition1' ]), ('InstrumentPosition', ['/test/path/messenger/instrumentposition']), ('InstrumentPointing', [ '/test/path/messenger/instrumentpointing0', '/test/path/messenger/instrumentpointing1' ]), ('Frame', [None]), ('TargetAttitudeShape', ['/test/path/base/attitudeshape']), ('Instrument', ['/test/path/messenger/instrument']), ('InstrumentAddendum', [None]), ('LeapSecond', [None]), ('SpacecraftClock', ['/test/path/base/clock']), ('Extra', [None]), ('Clock', [None]) ])
def test_kernel_from_cube_list(cube_kernels): with tempfile.NamedTemporaryFile('r+') as cube: cube.write(cube_kernels) cube.flush() kernels = util.generate_kernels_from_cube(cube.name) assert kernels == [ '$messenger/targetposition0', '$messenger/targetposition1', '$messenger/instrumentposition', '$messenger/instrumentpointing0', '$messenger/instrumentpointing1', '$base/attitudeshape', '$messenger/instrument', '$base/clock' ]
def test_kernel_from_cube_dict(cube_kernels): with tempfile.NamedTemporaryFile('r+') as cube: cube.write(cube_kernels) cube.flush() kernels = util.generate_kernels_from_cube(cube.name, format_as='dict') assert kernels == OrderedDict([ ('TargetPosition', ['$messenger/targetposition0', '$messenger/targetposition1']), ('InstrumentPosition', ['$messenger/instrumentposition']), ('InstrumentPointing', ['$messenger/instrumentpointing0', '$messenger/instrumentpointing1']), ('Frame', [None]), ('TargetAttitudeShape', ['$base/attitudeshape']), ('Instrument', ['$messenger/instrument']), ('InstrumentAddendum', [None]), ('LeapSecond', [None]), ('SpacecraftClock', ['$base/clock']), ('Extra', [None]), ('Clock', [None]) ])
def test_kernel_from_cube_list_expanded(monkeypatch, tmpdir, pvl_four_group, cube_kernels): monkeypatch.setenv('ISISROOT', str(tmpdir)) monkeypatch.setenv('ISIS3DATA', '/test/path') with open(tmpdir.join('IsisPreferences'), 'w+') as pvl_isisroot_file: pvl_isisroot_file.write(pvl_four_group) pvl_isisroot_file.flush() with tempfile.NamedTemporaryFile('r+') as cube: cube.write(cube_kernels) cube.flush() kernels = util.generate_kernels_from_cube(cube.name, expand=True) assert kernels == [ '/test/path/messenger/targetposition0', '/test/path/messenger/targetposition1', '/test/path/messenger/instrumentposition', '/test/path/messenger/instrumentpointing0', '/test/path/messenger/instrumentpointing1', '/test/path/base/attitudeshape', '/test/path/messenger/instrument', '/test/path/base/clock' ]
def test_kernel_from_cube_no_kernel_group(): with pytest.raises(KeyError): with tempfile.NamedTemporaryFile('w+') as cube: cube.write('') cube.flush() util.generate_kernels_from_cube(cube.name)