Beispiel #1
0
    def test_produced_keys_are_passed_to_write_oasis_keys_file(self, data):
        write_oasis_keys_file_path = 'oasislmf.model_preparation.lookup.OasisLookupFactory.write_oasis_keys_file'
        with TemporaryDirectory() as d, patch(write_oasis_keys_file_path) as write_oasis_keys_file_mock:
            keys_file_path = os.path.join(d, 'piwind-keys.csv')

            olf.save_keys(
                keys_data=data,
                keys_file_path=keys_file_path,
            )
            write_oasis_keys_file_mock.assert_called_once_with(data, keys_file_path, False)
Beispiel #2
0
    def test_produced_keys_are_passed_to_write_oasis_keys_file(self, data):
        with TemporaryDirectory() as d,\
             patch('oasislmf.model_preparation.lookup.OasisLookupFactory.get_keys', Mock(return_value=(r for r in data))) as get_keys_mock,\
             patch('oasislmf.model_preparation.lookup.OasisLookupFactory.write_oasis_keys_file') as write_oasis_keys_file_mock:

            keys_file_path = os.path.join(d, 'piwind-keys.csv')
            olf.save_keys(lookup=self.create_fake_lookup(),
                          keys_file_path=keys_file_path,
                          source_exposure=json.dumps(data))

            get_keys_mock.assert_called_once_with(
                lookup=self.lookup_instance,
                source_exposure=json.dumps(data),
                source_exposure_fp=None,
                success_only=True)
            write_oasis_keys_file_mock.assert_called_once_with(
                data, keys_file_path, id_col='locnumber')