def test_logs_from_workspace_without_logs_returns_emtpy_list(self):
        fake_ws = create_test_workspace()
        fit = FitInformation(mock.MagicMock(), 'func1',
                             [StaticWorkspaceWrapper(fake_ws.name(), fake_ws)],
                             mock.MagicMock(), mock.MagicMock())

        allowed_logs = fit.log_names()
        self.assertEqual(0, len(allowed_logs))
    def test_log_names_uses_filter_fn(self):
        time_series_logs = (('ts_1', (1., )), ('ts_2', (3., )), ('ts_3', [2.]),
                            ('ts_4', [3.]))
        fake1 = create_test_workspace(ws_name='fake1',
                                      time_series_logs=time_series_logs)
        fit = FitInformation(mock.MagicMock(), 'func1',
                             [StaticWorkspaceWrapper(fake1.name(), fake1)],
                             mock.MagicMock(), mock.MagicMock())

        log_names = fit.log_names(lambda log: log.name == 'ts_1')
        self.assertEqual(1, len(log_names))
        self.assertEqual(time_series_logs[0][0], log_names[0])
    def test_logs_for_single_workspace_return_all_time_series_logs(self):
        time_series_logs = (('ts_1', (1., )), ('ts_2', (3., )))
        single_value_logs = (('sv_1', 'val1'), ('sv_2', 'val2'))
        fake_ws = create_test_workspace(time_series_logs=time_series_logs)
        fit = FitInformation(mock.MagicMock(), 'func1',
                             [StaticWorkspaceWrapper(fake_ws.name(), fake_ws)],
                             mock.MagicMock(), mock.MagicMock())

        log_names = fit.log_names()
        for name, _ in time_series_logs:
            self.assertTrue(name in log_names,
                            msg="{} not found in log list".format(name))
        for name, _ in single_value_logs:
            self.assertFalse(name in log_names,
                             msg="{} found in log list".format(name))
    def test_log_names_from_list_of_workspaces_gives_combined_set(self):
        time_series_logs = (('ts_1', (1., )), ('ts_2', (3., )), ('ts_3', [2.]),
                            ('ts_4', [3.]))

        fake1 = create_test_workspace(ws_name='fake1',
                                      time_series_logs=time_series_logs[:2])
        fake2 = create_test_workspace(ws_name='fake2',
                                      time_series_logs=time_series_logs[2:])
        fit = FitInformation(mock.MagicMock(), 'func1', [
            StaticWorkspaceWrapper(fake1.name(), fake1),
            StaticWorkspaceWrapper(fake2.name(), fake2)
        ], mock.MagicMock(), mock.MagicMock())

        log_names = fit.log_names()
        self.assertEqual(len(time_series_logs), len(log_names))
        for name, _ in time_series_logs:
            self.assertTrue(name in log_names,
                            msg="{} not found in log list".format(name))