Best Python code snippet using ddt_python
tests.py
Source:tests.py
1import sys, os2sys.path.append(os.path.dirname(os.path.dirname(__file__)))3from django.test import TestCase4from proxy_server.backend_services import invoke_backend_service5from proxy_server.helpers import generate_service_url6from django.test.client import Client7class ProxyServicesTest(TestCase):8 def test_invoke_backend_service(self):9 c = Client(enforce_csrf_checks=True)10 response = c.get('/test_undecorated/')11 print 'Test undecorated view GET:', response.status_code12 response = c.post('/test_undecorated/')13 print 'Test undecorated view POST:', response.status_code, response.context['reason']14 response = c.post('/test/', **{'HTTP_API_KEY': '^ugfp@+cw!+se1b8kw%!23(sbrzk8f!uzrhqp$s)@67g9f1tdj', 'HTTP_X_FORWARDED_FOR': '127.0.0.1'})15 print 'Invoke backend as proxy response 200 cookies:', response.cookies16 print 'Invoke backend as proxy response 200 content:', response.content17 try:18 c.get('/test_error/', **{'HTTP_API_KEY': '^ugfp@+cw!+se1b8kw%!23(sbrzk8f!uzrhqp$s)@67g9f1tdj', 'HTTP_X_FORWARDED_FOR': '127.0.0.1'})19 except Exception as e:20 print 'Invoke backend as proxy response 500:', str(e)21 response = c.get('/test_token_validation/', **{'HTTP_API_KEY': '^ugfp@+cw!+se1b8kw%!23(sbrzk8f!uzrhqp$s)@67g9f1tdj',22 'HTTP_X_FORWARDED_FOR': '127.0.0.1', 'HTTP_USER_TOKEN': '123token'})23 print 'Invoke backend as proxy response token_validation content:', response.content24class BackendServicesTest(TestCase):25 def test_invoke_backend_service(self):26 service_url = generate_service_url('/login')27 response = invoke_backend_service('POST', service_url, json_data={ 'email': 'admin@test.com', 'password': 'password' })28 print 'Invoke backend response 200: ', response29 try:30 invoke_backend_service('POST', service_url, json_data={ 'email': 'admin@test.com' })31 except Exception as e:...
loader_test_undecorated_test.py
Source:loader_test_undecorated_test.py
1import pysimtest2class Suite(pysimtest.SimTestSuite):3 # Undecorated4 # @pysimtest.test(run=True)5 def test_undecorated(self):6 self.set_vehicle_position(0,0,0)7 # Decorated8 @pysimtest.test(run=True)9 def test_decorated(self):...
urls.py
Source:urls.py
1from django.conf.urls import url, patterns2urlpatterns = patterns('views',3 url(r'^test/$', 'test'),4 url(r'^test_error/$', 'test_error'),5 url(r'^test_token_validation/$', 'test_token_validation'),6 url(r'^test_undecorated/$', 'test_undecorated'),...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!