def _update_datasets(self, model_run, session):
        """
        Update all data sets for this model
        :param model_run: the model run to update
        :param session: a session
        :return:nothing
        """

        run_id = model_run.get_python_parameter_value(constants.JULES_PARAM_OUTPUT_RUN_ID)
        selected_output_profile_names = model_run.get_parameter_values(constants.JULES_PARAM_OUTPUT_PROFILE_NAME)

        selected_output_periods = {}
        for var in model_run.get_parameter_values(constants.JULES_PARAM_OUTPUT_PERIOD):
            selected_output_periods[var.group_id] = var.get_value_as_python()

        if len(selected_output_profile_names) > 0:
            dataset_type = self._get_output_dataset_type(model_run, run_id, selected_output_profile_names, session)

            for selected_output_profile_name in selected_output_profile_names:
                file_path = self._create_file_path(
                    model_run,
                    run_id,
                    selected_output_profile_name.get_value_as_python())
                is_input = False

                profile_name = utils.convert_time_period_to_name(
                    selected_output_periods[selected_output_profile_name.group_id])
                self._create_dataset(dataset_type, file_path, is_input, model_run, session, profile_name)

        input_locations = session \
            .query(DrivingDatasetLocation) \
            .filter(DrivingDatasetLocation.driving_dataset_id == model_run.driving_dataset_id) \
            .all()

        for input_location in input_locations:
            file_path = input_location.base_url
            is_input = True
            self._create_dataset(input_location.dataset_type, file_path, is_input, model_run, session)

        self._create_ancil_datasets(model_run, session)
    def test_GIVEN_Round_number_of_second_not_minutes_WHEN_convert_THEN_XX_seconds(self):
        seconds = 100
        result = utils.convert_time_period_to_name(seconds)

        assert_that(result, is_('Every {} seconds'.format(seconds)))
    def test_GIVEN_none_WHEN_convert_THEN_unknown_time_period(self):
        seconds = None
        result = utils.convert_time_period_to_name(seconds)

        assert_that(result, is_('Unknown time period'))
    def test_GIVEN_Round_number_of_minutes_WHEN_convert_THEN_XX_minutes(self):
        minutes = 30
        result = utils.convert_time_period_to_name(minutes*60)

        assert_that(result, is_('Every {} minutes'.format(minutes)))
    def test_GIVEN_Hourly_time_period_WHEN_convert_THEN_show_hourly(self):

        result = utils.convert_time_period_to_name(60*60)

        assert_that(result, is_('Hourly'))
    def test_GIVEN_Daily_time_period_WHEN_convert_THEN_show_daily(self):

        result = utils.convert_time_period_to_name(24*60*60)

        assert_that(result, is_('Daily'))
    def test_GIVEN_Monthly_constant_WHEN_convert_THEN_show_monthly(self):

        result = utils.convert_time_period_to_name(-1)

        assert_that(result, is_('Monthly'))
    def test_GIVEN_Yearly_constant_WHEN_convert_THEN_show_yearly(self):

        result = utils.convert_time_period_to_name(-2)

        assert_that(result, is_('Yearly'))