'Test to make sure notification to routers occurs when the gateway
ip address of a subnet of the external network is changed.'

def test_update_subnet_gateway_for_external_net(self):

    plugin = directory.get_plugin(plugin_constants.L3)
    if (not hasattr(plugin, 'l3_rpc_notifier')):
        self.skipTest('Plugin    does    not    support    l3_rpc_notifier')
    registry.subscribe(l3_db.L3RpcNotifierMixin._notify_subnet_gateway_ip_update, resources.SUBNET, events.AFTER_UPDATE)
    with mock.patch.object(plugin.l3_rpc_notifier, 'routers_updated') as chk_method:
        with self.network() as network:
            allocation_pools = [{'start': '120.0.0.3', 'end': '120.0.0.254'}]
            with self.subnet(network=network, gateway_ip='120.0.0.1', allocation_pools=allocation_pools, cidr='120.0.0.0/24') as subnet:
                kwargs = {'device_owner': lib_constants.DEVICE_OWNER_ROUTER_GW, 'device_id': 'fake_device'}
                with self.port(subnet=subnet, **kwargs):
                    data = {'subnet': {'gateway_ip': '120.0.0.2'}}
                    req = self.new_update_request('subnets', data, subnet['subnet']['id'])
                    res = self.deserialize(self.fmt, req.get_response(self.api))
                    self.assertEqual(data['subnet']['gateway_ip'], res['subnet']['gateway_ip'])
                    chk_method.assert_called_with(mock.ANY, ['fake_device'], None)
