def test_get_ip_for_unknown_subscriber(self): """ Getting ip for non existent subscriber should return NOT_FOUND status code """ lookup_request0 = IPLookupRequest(sid=self._sid0, apn=self._apn0) with self.assertRaises(grpc.RpcError) as err: self._stub.GetIPForSubscriber(lookup_request0) self.assertEqual(err.exception.code(), grpc.StatusCode.NOT_FOUND)
def test_get_ip_for_subscriber(self): """ test GetIPForSubscriber """ self._stub.AddIPBlock(self._block_msg) alloc_request0 = AllocateIPRequest(sid=self._sid0, version=AllocateIPRequest.IPV4, apn=self._apn0) ip_msg0 = self._stub.AllocateIPAddress(alloc_request0) ip0 = ipaddress.ip_address(ip_msg0.address) lookup_request0 = IPLookupRequest(sid=self._sid0, apn=self._apn0) ip_msg0_returned = self._stub.GetIPForSubscriber(lookup_request0) ip0_returned = ipaddress.ip_address(ip_msg0_returned.address) self.assertEqual(ip0, ip0_returned)