def test_try_deploy_active_netipv4(self, test_patch): """Test of error to deploy a active NetworkIPv4.""" mock = MockPluginNetwork() mock.status(False) test_patch.return_value = mock url_post = '/api/v3/networkv4/deploy/1/' response = self.client.post(url_post, content_type='application/json', HTTP_AUTHORIZATION=self.authorization) self.compare_status(400, response.status_code) self.compare_values('Already Active Network. Nothing to do.', response.data['detail']) url_get = '/api/v3/networkv4/1/?fields=active' response = self.client.get(url_get, HTTP_AUTHORIZATION=self.authorization) self.compare_status(200, response.status_code) active = response.data['networks'][0]['active'] self.compare_values(True, active)
def test_try_deploy_inactive_netipv6(self, test_patch): """Test of success to deploy a inactive NetworkIPv6.""" mock = MockPluginNetwork() mock.status(True) test_patch.return_value = mock url_post = '/api/v3/networkv6/deploy/3/' response = self.client.post( url_post, content_type='application/json', HTTP_AUTHORIZATION=self.authorization) self.compare_status(200, response.status_code) url_get = '/api/v3/networkv6/3/?fields=active' response = self.client.get( url_get, HTTP_AUTHORIZATION=self.authorization ) self.compare_status(200, response.status_code) active = response.data['networks'][0]['active'] self.compare_values(True, active)
def test_try_deploy_active_netipv4(self, test_patch): """Test of error to deploy a active NetworkIPv4.""" mock = MockPluginNetwork() mock.status(False) test_patch.return_value = mock url_post = '/api/v3/networkv4/deploy/1/' response = self.client.post( url_post, content_type='application/json', HTTP_AUTHORIZATION=self.authorization) self.compare_status(400, response.status_code) self.compare_values( 'Already Active Network. Nothing to do.', response.data['detail']) url_get = '/api/v3/networkv4/1/?fields=active' response = self.client.get( url_get, HTTP_AUTHORIZATION=self.authorization ) self.compare_status(200, response.status_code) active = response.data['networks'][0]['active'] self.compare_values(True, active)
def test_try_undeploy_netipv4(self, test_patch): """Test of success to undeploy a Network IPv4.""" mock = MockPluginNetwork() mock.status(True) test_patch.return_value = mock response = self.client.delete('/api/v3/networkv4/deploy/1/', HTTP_AUTHORIZATION=self.authorization) self.compare_status(200, response.status_code) response = self.client.get('/api/v3/networkv4/1/?fields=active', HTTP_AUTHORIZATION=self.authorization) self.compare_status(200, response.status_code) active = response.data['networks'][0]['active'] self.compare_values(False, active)
def test_try_undeploy_netipv4(self, test_patch): """Test of success to undeploy a Network IPv4.""" mock = MockPluginNetwork() mock.status(True) test_patch.return_value = mock response = self.client.delete( '/api/v3/networkv4/deploy/1/', HTTP_AUTHORIZATION=self.authorization) self.compare_status(200, response.status_code) response = self.client.get( '/api/v3/networkv4/1/?fields=active', HTTP_AUTHORIZATION=self.authorization ) self.compare_status(200, response.status_code) active = response.data['networks'][0]['active'] self.compare_values(False, active)