def test_get_key_from_file_invalid_key_name(self): """Error dictionary is returned with message.""" data = tasks.get_key_from_file(self.dummy_fname, 'fake_key') for k in ('success', 'message'): assert k in data assert 'data' not in data assert data['success'] == False assert data['message'].startswith('Could not find')
def test_get_key_from_file_invalid_filename(self): """Error dictionary is returned with message.""" # As this test intentionally tries to open a non-existent file, which # ROOT would by default print an error about, temporarily change the # logging level to suppress such a message originalErrorIgnoreLevel = ROOT.gErrorIgnoreLevel ROOT.gErrorIgnoreLevel = ROOT.kFatal data = tasks.get_key_from_file('fake_file.root', self.dummy_keys[0]) ROOT.gErrorIgnoreLevel = originalErrorIgnoreLevel for k in ('success', 'message'): assert k in data assert 'data' not in data assert data['success'] == False assert data['message'].startswith('Could not open')
def test_get_key_from_file(self): """Dictionary describing key in file is returned.""" data = tasks.get_key_from_file(self.dummy_fname, self.dummy_keys[0]) for k in ('success', 'data'): assert k in data data_data = data['data'] assert data['success'] == True assert data_data for k in ('filename', 'key_name', 'key_title', 'key_class', 'key_data'): assert k in data_data assert data_data['filename'].endswith(self.dummy_fname) assert data_data['key_name'] == self.dummy_keys[0] assert data_data['key_title'] == 'Gaussian' assert data_data['key_class'] == 'TH1F'