def test_load_provider_rules(self): rules_dict = {'labels': {}, 'preanchors': [], 'postanchors': []} with mock.patch('oslo_serialization.jsonutils.load') as load: load.return_value = rules_dict with mock.patch('__builtin__.open') as mock_open: r = conf_mod.load_provider_rules('/the/path') mock_open.assert_called_once_with('/the/path') load.assert_called_once_with(mock_open.return_value) self.assertEqual(r, rules_dict)
def test_load_provider_rules_not_found(self, mock_open): mock_open.side_effect = IOError() res = conf_mod.load_provider_rules('/tmp/path') self.assertEqual(res, {})