def test_disassociate_floating_ip(self, client): request = self.mock_rest_request(body='{"address_id": "address"}') response = network.FloatingIP().patch(request) self.assertStatusCode(response, 204) client.floating_ip_disassociate.assert_called_once_with( request, 'address')
def test_disassociate_floating_ip(self): self.mock_floating_ip_disassociate.return_value = None request = self.mock_rest_request(body='{"address_id": "address"}') response = network.FloatingIP().patch(request) self.assertStatusCode(response, 204) self.mock_floating_ip_disassociate.assert_called_once_with( request, 'address')
def test_allocate_floating_ip(self): request = self.mock_rest_request(body='{"pool_id": "pool"}') fip = self.floating_ips.first() self.mock_tenant_floating_ip_allocate.return_value = fip response = network.FloatingIP().post(request) self.assertStatusCode(response, 200) self.assertEqual(response.json, fip.to_dict()) self.mock_tenant_floating_ip_allocate.assert_called_once_with( request, 'pool')
def test_allocate_floating_ip(self, client): request = self.mock_rest_request(body='{"pool_id": "pool"}') client.tenant_floating_ip_allocate.return_value = (mock.Mock( **{'to_dict.return_value': { 'ip': '1.2.3.4' }})) response = network.FloatingIP().post(request) self.assertStatusCode(response, 200) self.assertEqual(response.json, {'ip': '1.2.3.4'}) client.tenant_floating_ip_allocate.assert_called_once_with( request, 'pool')