How to use _set_test_method_and_url method in gabbi

Best Python code snippet using gabbi_python

driver.py

Source:driver.py Github

copy

Full Screen

...77 # NOTE(cdent): Not clear this can happen but just in case.78 raise GabbiFormatError(79 'malformed test chunk "%s": %s' % (test_dict, exc))80 test_name = self._set_test_name(test)81 self._set_test_method_and_url(test, test_name)82 self._validate_keys(test, test_name)83 http_class = httpclient.get_http(verbose=test['verbose'],84 caption=test['name'])85 # Use metaclasses to build a class of the necessary type86 # and name with relevant arguments.87 klass = TestBuilder(test_name, (case.HTTPTestCase,),88 {'test_data': test,89 'test_directory': self.test_directory,90 'fixtures': self.fixture_classes,91 'http': http_class,92 'host': self.host,93 'intercept': self.intercept,94 'port': self.port,95 'prefix': self.prefix,96 'prior': prior_test})97 tests = self.loader.loadTestsFromTestCase(klass)98 # Return the first (and only) test in the klass.99 return tests._tests[0]100 def _set_test_name(self, test):101 """Set the name of the test102 The original name is lowercased and spaces are replaces with '_'.103 The result is appended to the test_base_name, which is based on the104 name of the input data file.105 """106 if not test['name']:107 raise GabbiFormatError('Test name missing in a test in %s.'108 % self.test_base_name)109 return '%s_%s' % (self.test_base_name,110 test['name'].lower().replace(' ', '_'))111 @staticmethod112 def _set_test_method_and_url(test, test_name):113 """Extract the base URL and method for this test.114 If there is an upper case key in the test, that is used as the115 method and the value is used as the URL. If there is more than116 one uppercase that is a GabbiFormatError.117 If there is no upper case key then 'url' must be present.118 """119 method_key = None120 for key, val in six.iteritems(test):121 if _is_method_shortcut(key):122 if method_key:123 raise GabbiFormatError(124 'duplicate method/URL directive in "%s"' %125 test_name)126 test['method'] = key...

Full Screen

Full Screen

suitemaker.py

Source:suitemaker.py Github

copy

Full Screen

...66 # NOTE(cdent): Not clear this can happen but just in case.67 raise GabbiFormatError(68 'malformed test chunk "%s": %s' % (test_dict, exc))69 test_name = self._set_test_name(test)70 self._set_test_method_and_url(test, test_name)71 self._validate_keys(test, test_name)72 # Set server hostname in http request if host header is set.73 if 'request_headers' in test and 'host' in test['request_headers']:74 hostname = test['request_headers']['host']75 else:76 hostname = None77 http_class = httpclient.get_http(verbose=test['verbose'],78 caption=test['name'],79 cert_validate=test['cert_validate'],80 hostname=hostname)81 if prior_test:82 history = prior_test.history83 else:84 history = {}85 test_method_name = 'test_request'86 test_method = getattr(case.HTTPTestCase, test_method_name)87 @unittest.skipIf(self.host == '', 'No host configured')88 @functools.wraps(test_method)89 def do_test(*args, **kwargs):90 return test_method(*args, **kwargs)91 # Use metaclasses to build a class of the necessary type92 # and name with relevant arguments.93 klass = TestBuilder(test_name, (case.HTTPTestCase,),94 {'test_data': test,95 'test_directory': self.test_directory,96 'fixtures': self.fixture_classes,97 'inner_fixtures': self.inner_fixtures,98 'http': http_class,99 'host': self.host,100 'intercept': self.intercept,101 'content_handlers': self.content_handlers,102 'response_handlers': self.response_handlers,103 'port': self.port,104 'prefix': self.prefix,105 'prior': prior_test,106 'history': history,107 'test_base_name': self.test_base_name,108 test_method_name: do_test,109 })110 # We've been asked to, make this test class think it comes111 # from a different module.112 if self.test_loader_name:113 klass.__module__ = self.test_loader_name114 tests = self.loader.loadTestsFromTestCase(klass)115 history[test['name']] = tests._tests[0]116 # Return the first (and only) test in the klass.117 return tests._tests[0]118 def _set_test_name(self, test):119 """Set the name of the test120 The original name is lowercased and spaces are replaces with '_'.121 The result is appended to the test_base_name, which is based on the122 name of the input data file.123 """124 if not test['name']:125 raise GabbiFormatError('Test name missing in a test in %s.'126 % self.test_base_name)127 return '%s_%s' % (self.test_base_name,128 test['name'].lower().replace(' ', '_'))129 @staticmethod130 def _set_test_method_and_url(test, test_name):131 """Extract the base URL and method for this test.132 If there is an upper case key in the test, that is used as the133 method and the value is used as the URL. If there is more than134 one uppercase that is a GabbiFormatError.135 If there is no upper case key then 'url' must be present.136 """137 method_key = None138 for key, val in test.items():139 if _is_method_shortcut(key):140 if method_key:141 raise GabbiFormatError(142 'duplicate method/URL directive in "%s"' %143 test_name)144 test['method'] = key...

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 gabbi 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