示例#1
0
    def test_entries_are_dictionaries_success_only_is_true___only_successes_are_included(
            self, data):
        with patch(
                'oasislmf.keys.lookup.OasisLookupFactory.get_model_exposures'):
            self.create_fake_lookup(return_value=data)

            res = list(
                OasisLookupFactory.get_keys(lookup=self.lookup_instance,
                                            model_exposures_file_path='path'))

            self.assertEqual(res,
                             [d for d in data if d['status'] == 'success'])
示例#2
0
    def test_entries_are_dictionaries_success_only_is_false___all_entries_are_included(
            self, data):
        with patch(
                'oasislmf.keys.lookup.OasisLookupFactory.get_model_exposures'):
            self.create_fake_lookup(return_value=data)

            res = list(
                OasisLookupFactory.get_keys(lookup=self.lookup_instance,
                                            model_exposures_file_path='path',
                                            success_only=False))

            self.assertEqual(res, data)
示例#3
0
    def test_model_exposures_are_provided___exposures_are_passed_to_get_model_exposures_result_is_passed_to_lookup_process_locations(
            self, exposures, result):
        with patch(
                'oasislmf.keys.lookup.OasisLookupFactory.get_model_exposures',
                Mock(return_value=result)):
            list(
                OasisLookupFactory.get_keys(self.create_fake_lookup(),
                                            model_exposures=exposures))

            OasisLookupFactory.get_model_exposures.assert_called_once_with(
                model_exposures=exposures, model_exposures_file_path=None)
            self.lookup_instance.process_locations.assert_called_once_with(
                result)
示例#4
0
 def test_no_model_exposures_are_provided___oasis_exception_is_raised(self):
     with self.assertRaises(OasisException):
         list(OasisLookupFactory.get_keys(self.create_fake_lookup()))