<commit_before>from unittest.mock import Mock

from smif.controller.build import (get_initial_conditions_strategies,
                                   get_pre_specified_planning_strategies)


class TestStrategies:

    def test_get_pre_specified_planning_strategies(self, get_sos_model_run, initial_system):

        handler = Mock()
        interventions = initial_system
        handler.read_strategies = Mock(return_value=interventions)

        actual = get_pre_specified_planning_strategies(get_sos_model_run, handler)

        assert handler.read_strategies.called_with("energy_supply.csv")
        assert isinstance(actual[0], dict)

        assert isinstance(actual, list)
        assert 'filename' not in actual[0].keys()
        assert 'interventions' in actual[0].keys()
        assert actual[0]['interventions'] == interventions
        assert actual[0]['strategy'] == 'pre-specified-planning'
        assert actual[0]['model_name'] == 'energy_supply'

    def test_get_initial_conditions_strategies(self, initial_system):

        sector_model = Mock()
        sector_model.name = Mock(return_value='test_model')
        sector_model.initial_conditions = initial_system

        actual = get_initial_conditions_strategies([sector_model])

        assert isinstance(actual, list)
        assert isinstance(actual[0], dict)
        assert 'filename' not in actual[0].keys()
        assert 'interventions' in actual[0].keys()
        assert actual[0]['interventions'] == initial_system<commit_msg>Add test for empty pre-specified planning strategy<commit_after>from unittest.mock import Mock

from smif.controller.build import (get_initial_conditions_strategies,
                                   get_pre_specified_planning_strategies)


class TestStrategies:

    def test_get_pre_specified_planning_strategies(self, get_sos_model_run, initial_system):

        handler = Mock()
        interventions = initial_system
        handler.read_strategies = Mock(return_value=interventions)

        actual = get_pre_specified_planning_strategies(get_sos_model_run, handler)

        assert handler.read_strategies.called_with("energy_supply.csv")
        assert isinstance(actual[0], dict)

        assert isinstance(actual, list)
        assert 'filename' not in actual[0].keys()
        assert 'interventions' in actual[0].keys()
        assert actual[0]['interventions'] == interventions
        assert actual[0]['strategy'] == 'pre-specified-planning'
        assert actual[0]['model_name'] == 'energy_supply'

    def test_get_empty_pre_specified_planning_strategies(self, get_sos_model_run, initial_system):

        handler = Mock()
        handler.read_strategies = Mock(return_value=None)

        actual = get_pre_specified_planning_strategies(get_sos_model_run, handler)
        assert actual[0]['interventions'] == []

    def test_get_initial_conditions_strategies(self, initial_system):

        sector_model = Mock()
        sector_model.name = Mock(return_value='test_model')
        sector_model.initial_conditions = initial_system

        actual = get_initial_conditions_strategies([sector_model])

        assert isinstance(actual, list)
        assert isinstance(actual[0], dict)
        assert 'filename' not in actual[0].keys()
        assert 'interventions' in actual[0].keys()
        assert actual[0]['interventions'] == initial_system
{'fraction_non_alphanumeric': 0.0902344909468685, 'fraction_numerical': 0.006233303650934996, 'mean_word_length': 3.667590027700831, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2989719', 'n_tokens_mistral': 974, 'n_tokens_neox': 933, 'n_words': 176}