def runTest(self): logging.debug('Retrieving list of custom test endpoints.') output, status_code = test_util.get(self._url) self.assertEquals(status_code, 0, 'Cannot connect to sample application!') test_num = 0 if not output: logging.debug('No custom tests specified.') else: for test_info in json.loads(output): test_num += 1 name = test_info.get('name', 'test_{0}'.format(test_num)) path = test_info.get('path') if path is None: logging.warn( 'Test \'%s\' has no path specified! ' 'Skipping...', name) continue timeout = test_info.get('timeout', 500) test_endpoint = urlparse.urljoin(self._base_url, path) logging.info('Running custom test: %s', name) response, _ = test_util.get(test_endpoint, timeout=timeout) logging.debug(response)
def runTest(self): logging.debug('Hitting endpoint: {0}'.format(self._url)) output, status_code = test_util.get(self._url) logging.info('output is: {0}'.format(output)) self.assertEquals(status_code, 0, 'Cannot connect to sample application!') self.assertEquals(output, test_util.ROOT_EXPECTED_OUTPUT, 'Unexpected output: expected {0}, received {1}' .format(test_util.ROOT_EXPECTED_OUTPUT, output))
def _test_root(self): logging.debug('Hitting endpoint: {0}'.format(self._url)) output, status_code = test_util.get(self._url) logging.info('output is: {0}'.format(output)) if status_code != 0: raise Exception('Cannot connect to sample application!') self.assertEquals( output, constants.ROOT_EXPECTED_OUTPUT, 'Unexpected output: expected {0}, received {1}'.format( constants.ROOT_EXPECTED_OUTPUT, output))
def runTest(self): """Retrieve the configuration for the custom tests and launch the tests. Returns: None. """ logging.debug('Retrieving list of custom test endpoints.') output, status_code = test_util.get(self._url) self.assertEquals(status_code, 0, 'Cannot connect to sample application!') test_num = 0 if not output: logging.debug('No custom tests specified.') else: for specification in json.loads(output): test_num += 1 self._run_test_for_specification(specification, test_num)
def _run_simple_test(self, specification): """Send a request to the url specified in the path field of the specification. Args: specification: Dictionary containing the specification for the test. Returns: In the case where the test is executed but the result is negative the TestCase is considered as fail. """ path = specification.get('path') timeout = specification.get('timeout', 2000) test_endpoint = urlparse.urljoin(self._base_url, path) response, status = test_util.get(test_endpoint, timeout=timeout) logging.debug(response) self.assertEqual( status, 0, 'The response of the endpoint {0} ' 'is not valid (2xx expected)'.format(path))