def test_GIVEN_no_entry_or_instrument_in_file_WHEN_finding_entry_THEN_default_entry_and_instrument_are_created( file, ): wrapper = NexusWrapper(filename="test_nw5") wrapper.find_entries_in_file(file) assert isinstance(wrapper.entry, h5py.Group) assert isinstance(wrapper.instrument, h5py.Group)
def test_GIVEN_multiple_entry_groups_in_file_WHEN_finding_entry_THEN_signal_is_emitted_with_entry_options( ): with InMemoryFile("test_file") as file: entry = file.create_group("entry") # Test with byte string as well as python string. entry.attrs["NX_class"] = b"NXentry" inst_group = entry.create_group("instrument") inst_group.attrs["NX_class"] = "NXinstrument" entry2 = file.create_group("entry2") entry2.attrs["NX_class"] = "NXentry" inst_group2 = entry2.create_group("instrument2") inst_group2.attrs["NX_class"] = "NXinstrument" wrapper = NexusWrapper(filename="test_nw7") wrapper.show_entries_dialog = Mock() wrapper.show_entries_dialog.emit = Mock() wrapper.find_entries_in_file(file) expected_entry_dict = {entry.name: entry, entry2.name: entry2} assert wrapper.show_entries_dialog.emit.called_once_with( expected_entry_dict, file)
def test_GIVEN_single_entry_group_with_instrument_group_WHEN_finding_entry_THEN_file_is_loaded_correctly( file, ): entry = file.create_group("entry") entry.attrs["NX_class"] = "NXentry" inst_group = entry.create_group("instrument") inst_group.attrs["NX_class"] = "NXinstrument" wrapper = NexusWrapper(filename="test_nw5") wrapper.find_entries_in_file(file) assert wrapper.nexus_file == file assert wrapper.entry == entry assert wrapper.instrument == inst_group