def test_create_deploy_with_mock_success_url(self, test_patch): """Deploy create of one pool with success by url. Method that factory in networkapi.plugins.factory.PluginFactory is mock to test the flow in deploys of pool by url. """ mock = MockPlugin() mock.status(True) test_patch.return_value = mock name_file = 'api_pools/tests/sanity/json/mock/pool_2_created.json' response = self.client.post( '/api/v3/pool/deploy/2/', content_type='application/json', HTTP_AUTHORIZATION=self.get_http_authorization('test')) response = self.client.get( '/api/v3/pool/2/', content_type='application/json', HTTP_AUTHORIZATION=self.get_http_authorization('test')) self.compare_status(200, response.status_code) self.compare_json(name_file, response.data)
def test_update_deploy_without_reals_success(self, test_patch): """Deploy update of one pool without reals with success by url. Method that factory in networkapi.plugins.factory.PluginFactory is mock to test the flow in deploys of pool by url. """ mock = MockPlugin() mock.status(True) test_patch.return_value = mock name_file = 'api_pools/tests/sanity/json/mock/pool_3_put_created_' + \ 'without_reals.json' response = self.client.put( '/api/v3/pool/deploy/3/', data=json.dumps(self.load_json_file(name_file)), content_type='application/json', HTTP_AUTHORIZATION=self.get_http_authorization('test')) self.compare_status(200, response.status_code) response = self.client.get( '/api/v3/pool/3/', content_type='application/json', HTTP_AUTHORIZATION=self.get_http_authorization('test')) self.compare_status(200, response.status_code) self.compare_json(name_file, response.data)
def test_create_deploy_with_mock_error(self, test_patch): """ Deploy create of one pool with error. Method that factory in networkapi.plugins.factory.PluginFactory is mock to test the flow in deploys of pool. """ dp = self.load_json_file( 'api_pools/tests/unit/json/test_pool_post_not_created.json') mock = MockPlugin() mock.status(False) test_patch.return_value = mock dp = dp.get('server_pools') self.assertRaises(Exception, facade_pool_deploy.create_real_pool(dp, self.user))
def test_delete_deploy_with_mock_error(self, test_patch): """ Deploy delete of one pool with error. Method that factory in networkapi.plugins.factory.PluginFactory is mock to test the flow in deploys of pool. """ dp = self.load_json_file( 'api_pools/tests/unit/json/test_pool_delete_created.json') mock = MockPlugin() mock.status(False) test_patch.return_value = mock dp = dp.get('server_pools') self.assertRaises( Exception, facade_pool_deploy.delete_real_pool(dp, self.user) )