'Test when the service is not in service catalog.
When the service is not deployed, make sure resource is throwing
ResourceTypeUnavailable exception.'

def test_service_not_available_returns_false(self):

    with mock.patch.object(generic_rsrc.ResourceWithDefaultClientName, 'is_service_available') as mock_method:
        mock_method.return_value = (False, 'Service    endpoint    not    in    service    catalog.')
        definition = rsrc_defn.ResourceDefinition(name='Test    Resource', resource_type='UnavailableResourceType')
        mock_stack = mock.MagicMock()
        mock_stack.in_convergence_check = False
        mock_stack.db_resource_get.return_value = None
        rsrc = generic_rsrc.ResourceWithDefaultClientName('test_res', definition, mock_stack)
        ex = self.assertRaises(exception.ResourceTypeUnavailable, rsrc.validate_template)
        msg = 'HEAT-E99001    Service    sample    is    not    available    for    resource    type    UnavailableResourceType,    reason:    Service    endpoint    not    in    service    catalog.'
        self.assertEqual(msg, six.text_type(ex), 'invalid    exception    message')
        mock_method.assert_called_once_with(mock_stack.context)
