How to use delete_project method in tempest

Best Python code snippet using tempest_python

test_delete_project.py

Source:test_delete_project.py Github

copy

Full Screen

1from falcon import testing2import pytest,falcon3from ice_rest.rest.services.parse.delete_project import DeleteProject, delete_project_if_exists, uncache_project_if_exists4class TestMiddleware:5 def process_request(self, req, resp):6 resp.body = 'Pass'7@pytest.fixture()8def client():9 api = falcon.API(middleware=TestMiddleware())10 api.add_route('/api/parse/delete_project', DeleteProject())11 client = falcon.testing.TestClient(api)12 return client13req_init = falcon.request.Request.__init__14def mock_init(req, *args, **kwargs):15 req_init(req, *args, **kwargs)16 req.context = {'doc': {17 "serviceid": "abc"18 }}19def test_delete_project_api1(client, mocker):20 mocker.patch('falcon.request.Request.__init__', mock_init)21 headers = {"Content-Type": "application/json"}22 mocker.patch('ice_rest.rest.services.parse.delete_project.uncache_project_if_exists', return_value= None)23 resp = client.simulate_post('/api/parse/delete_project', headers=headers)24 assert resp.status_code == 20025def test_delete_project_api2(client, mocker):26 mocker.patch('falcon.request.Request.__init__', mock_init)27 headers = {"Content-Type": "application/json"}28 mocker.patch('ice_rest.rest.services.parse.delete_project.uncache_project_if_exists', side_effect= AssertionError('foooo'))29 resp = client.simulate_post('/api/parse/delete_project', headers=headers)30 assert resp.status_code == 41231def test_delete_project_api3(client, mocker):32 mocker.patch('falcon.request.Request.__init__', mock_init)33 headers = {"Content-Type": "application/json"}34 mocker.patch('ice_rest.rest.services.parse.delete_project.uncache_project_if_exists', side_effect= Exception('foooo'))35 resp = client.simulate_post('/api/parse/delete_project', headers=headers)36 assert resp.status_code == 50337def mock_init2(req, *args, **kwargs):38 req_init(req, *args, **kwargs)39 req.context = {'doc': {40 "any_other_field": "hello"41 }}42def test_delete_project_api4(client, mocker):43 mocker.patch('falcon.request.Request.__init__', mock_init2)44 headers = {"Content-Type": "application/json"}45 resp = client.simulate_post('/api/parse/delete_project', headers=headers)46 assert resp.status_code == 40047def test_delete_project_if_exists(mocker):48 mocker.patch('ice_rest.rest.services.parse.delete_project.ProjectManager')49 mocker.patch('ice_rest.rest.services.parse.delete_project.DatasourceManager')50 res = delete_project_if_exists('aa')51 assert res == None52def test_uncache_project_if_exists1(mocker):53 mocker.patch('ice_rest.rest.services.parse.delete_project.uncache_project_if_exists')54 m= mocker.patch('ice_rest.rest.services.parse.delete_project.get_model_store')55 m.return_value.get_active_models.return_value = ['a','b']56 mocker.patch('ice_rest.rest.services.parse.delete_project.get_model_name',return_value = 'a')57 mocker.patch('ice_rest.rest.services.parse.delete_project.ProjectManager')58 mocker.patch('ice_rest.rest.services.parse.delete_project.DatasourceManager')59 mocker.patch('ice_rest.rest.services.parse.delete_project.os.path.exists', return_value= True)60 mocker.patch('ice_rest.rest.services.parse.delete_project.shutil.rmtree', return_value= None)61 res = uncache_project_if_exists('aa')62 assert res == None63def test_uncache_project_if_exists2(mocker):64 mocker.patch('ice_rest.rest.services.parse.delete_project.uncache_project_if_exists')65 m= mocker.patch('ice_rest.rest.services.parse.delete_project.get_model_store')66 m.return_value.get_active_models.return_value = ['a','b']67 mocker.patch('ice_rest.rest.services.parse.delete_project.get_model_name',return_value = 'a')68 mocker.patch('ice_rest.rest.services.parse.delete_project.ProjectManager.find_model', return_value= None)69 mocker.patch('ice_rest.rest.services.parse.delete_project.DatasourceManager')70 mocker.patch('ice_rest.rest.services.parse.delete_project.os.path.exists', return_value= True)71 mocker.patch('ice_rest.rest.services.parse.delete_project.shutil.rmtree', return_value= None)72 res = uncache_project_if_exists('aa')...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1"""deepeye URL Configuration2The `urlpatterns` list routes URLs to views. For more information please see:3 https://docs.djangoproject.com/en/3.1/topics/http/urls/4Examples:5Function views6 1. Add an import: from my_app import views7 2. Add a URL to urlpatterns: path('', views.home, name='home')8Class-based views9 1. Add an import: from other_app.views import Home10 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')11Including another URLconf12 1. Import the include() function: from django.urls import include, path13 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))14"""15from django.conf.urls import include, re_path16from django.conf.urls.i18n import i18n_patterns 17from django.views.i18n import JavaScriptCatalog18from django.contrib import admin19from django.urls import path20from deepeye.settings import DEBUG21from main import views22from django.conf import settings23from django.views.static import serve24if DEBUG:25 urlpatterns = i18n_patterns(26 path('', views.home, name='home'),27 path('project_setting', views.project_setting, name='project_setting'),28 path('delete_project/<int:project_id>', views.delete_project, name='delete_project'),29 path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),30 path('classification/', include('classification.urls')),31 path('admin/', admin.site.urls),32 )33else:34 urlpatterns = i18n_patterns(35 path('', views.home, name='home'),36 path('project_setting', views.project_setting, name='project_setting'),37 path('delete_project/<int:project_id>', views.delete_project, name='delete_project'),38 path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),39 path('classification/', include('classification.urls')),40 path('admin/', admin.site.urls),41 re_path(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),42 re_path(r'^projects/(?P<path>.*)$', serve,{'document_root': settings.STATIC_PROJECT_ROOT}),43 re_path(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful