def run(): responses.mock.start() StackInABox.register_service(AdvancedService()) stackinabox.util_responses.responses_registration('localhost') res = requests.get('http://localhost/advanced/') assert res.status_code == 200 assert res.text == 'Hello' res = requests.get('http://localhost/advanced/h') assert res.status_code == 200 assert res.text == 'Good-Bye' expected_result = { 'bob': 'bob: Good-Bye alice', 'alice': 'alice: Good-Bye bob', 'joe': 'joe: Good-Bye jane' } res = requests.get('http://localhost/advanced/g?bob=alice;' 'alice=bob&joe=jane') assert res.status_code == 200 assert res.json() == expected_result StackInABox.reset_services() responses.mock.stop() responses.mock.reset()
def run(): StackInABox.reset_services() StackInABox.register_service(HelloService()) stackinabox.util.responses.registration('localhost') res = requests.get('http://localhost/hello/') assert res.status_code == 200 assert res.text == 'Hello'
def run(): StackInABox.reset_services() StackInABox.register_service(HelloService()) stackinabox.util_responses.responses_registration('localhost') res = requests.get('http://localhost/hello/') assert res.status_code == 200 assert res.text == 'Hello'
def run(): responses.mock.start() StackInABox.reset_services() for service in self.services.values(): StackInABox.register_service(service) responses_registration(self.uri) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() responses.mock.stop() responses.mock.reset()
def run(): responses.mock.start() StackInABox.reset_services() for service in self.services.values(): StackInABox.register_service(service) responses_registration(self.uri) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() responses.mock.stop() responses.mock.reset()
def wrapped(*args, **kwargs): args_copy = list(args) for arg in self.args: args_copy.append(arg) args_finalized = tuple(args_copy) kwargs.update(self.kwargs) if self.enable_service_access is not None: kwargs[self.enable_service_access] = self.services with requests_mock_activate(): if self.session is not None: kwargs[self.session] = requests.Session() StackInABox.reset_services() for service in self.services.values(): StackInABox.register_service(service) requests_mock_session_registration( self.uri, kwargs[self.session] ) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() else: StackInABox.reset_services() for service in self.services.values(): StackInABox.register_service(service) requests_mock_registration(self.uri) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() return return_value
def wrapped(*args, **kwargs): args_copy = list(args) for arg in self.args: args_copy.append(arg) args_finalized = tuple(args_copy) kwargs.update(self.kwargs) if self.enable_service_access is not None: kwargs[self.enable_service_access] = self.services with requests_mock_activate(): if self.session is not None: kwargs[self.session] = requests.Session() StackInABox.reset_services() for service in self.services.values(): StackInABox.register_service(service) requests_mock_session_registration(self.uri, kwargs[self.session]) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() else: StackInABox.reset_services() for service in self.services.values(): StackInABox.register_service(service) requests_mock_registration(self.uri) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() return return_value
def run(use_deprecated): responses.mock.start() StackInABox.register_service(AdvancedService()) if use_deprecated: stackinabox.util.responses.responses_registration('localhost') else: stackinabox.util.responses.registration('localhost') res = requests.get('http://localhost/advanced/') assert res.status_code == 200 assert res.text == 'Hello' res = requests.get('http://localhost/advanced/h') assert res.status_code == 200 assert res.text == 'Good-Bye' expected_result = { 'bob': 'bob: Good-Bye alice', 'alice': 'alice: Good-Bye bob', 'joe': 'joe: Good-Bye jane' } res = requests.get('http://localhost/advanced/g?bob=alice;' 'alice=bob&joe=jane') assert res.status_code == 200 assert res.json() == expected_result res = requests.get('http://localhost/advanced/1234567890') assert res.status_code == 200 assert res.text == 'okay' res = requests.get('http://localhost/advanced/_234567890') assert res.status_code == 595 res = requests.put('http://localhost/advanced/h') assert res.status_code == 405 res = requests.put('http://localhost/advanced2/i') assert res.status_code == 597 StackInABox.reset_services() responses.mock.stop() responses.mock.reset()
def run(): responses.mock.start() StackInABox.register_service(AdvancedService()) stackinabox.util.responses.registration('localhost') res = requests.get('http://localhost/advanced/') assert res.status_code == 200 assert res.text == 'Hello' res = requests.get('http://localhost/advanced/h') assert res.status_code == 200 assert res.text == 'Good-Bye' expected_result = { 'bob': 'bob: Good-Bye alice', 'alice': 'alice: Good-Bye bob', 'joe': 'joe: Good-Bye jane' } res = requests.get('http://localhost/advanced/g?bob=alice;' 'alice=bob&joe=jane') assert res.status_code == 200 assert res.json() == expected_result res = requests.get('http://localhost/advanced/1234567890') assert res.status_code == 200 assert res.text == 'okay' res = requests.get('http://localhost/advanced/_234567890') assert res.status_code == 595 res = requests.put('http://localhost/advanced/h') assert res.status_code == 405 res = requests.put('http://localhost/advanced2/i') assert res.status_code == 597 StackInABox.reset_services() responses.mock.stop() responses.mock.reset()
def test_user_listing(self): stackinabox.util_httpretty.httpretty_registration('localhost') neo_tenant_id = self.keystone.backend.add_tenant(tenantname='neo', description='The One') tom = self.keystone.backend.add_user(neo_tenant_id, 'tom', '*****@*****.**', 'bluepill', 'iamnottheone', enabled=True) self.keystone.backend.add_user_role_by_rolename( neo_tenant_id, tom, 'identity:user-admin') self.keystone.backend.add_token(neo_tenant_id, tom) user_data = self.keystone.backend.get_token_by_userid(tom) self.headers['x-auth-token'] = user_data['token'] res = requests.get('http://localhost/keystone/v2.0/users', headers=self.headers) print(res.text) self.assertEqual(res.status_code, 200) user_data = res.json() self.assertEqual(len(user_data['users']), 1) self.keystone.backend.add_user(neo_tenant_id, 'neo', '*****@*****.**', 'redpill', 'iamtheone', enabled=True) res = requests.get('http://localhost/keystone/v2.0/users', headers=self.headers) self.assertEqual(res.status_code, 200) user_data = res.json() self.assertEqual(len(user_data['users']), 2) StackInABox.reset_services()
def wrapped(*args, **kwargs): args_copy = list(args) for arg in self.args: args_copy.append(arg) args_finalized = tuple(args_copy) kwargs.update(self.kwargs) if self.enable_service_access is not None: kwargs[self.enable_service_access] = self.services httpretty.reset() httpretty.enable() for service in self.services.values(): StackInABox.register_service(service) httpretty_registration(self.uri) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() httpretty.disable() httpretty.reset() return return_value
def wrapped(*args, **kwargs): args_copy = list(args) for arg in self.args: args_copy.append(arg) args_finalized = tuple(args_copy) kwargs.update(self.kwargs) if self.enable_service_access is not None: kwargs[self.enable_service_access] = self.services httpretty.reset() httpretty.enable() for service in self.services.values(): StackInABox.register_service(service) httpretty_registration(self.uri) return_value = fn(*args_finalized, **kwargs) StackInABox.reset_services() httpretty.disable() httpretty.reset() return return_value
def tearDown(self): super(TestRequestsMockBasic, self).tearDown() StackInABox.reset_services() self.session.close()
def tearDown(self): super(TestHttprettyAdvanced, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestServiceRouteRegistration, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestKeystoneV2UserAddCredentials, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestKeystoneV2AuthBase, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestMetrics, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestHttprettyKeystone, self).tearDown() StackInABox.reset_services() self.session.close()
def tearDown(self): super(TestKeystoneV2Tenants, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestHttprettyAdvanced, self).tearDown() StackInABox.reset_services()
def tearDown(self): """ Test Teardown """ StackInABox.reset_services()
def tearDown(self): super(TestRequestMockAdvanced, self).tearDown() StackInABox.reset_services() self.session.close()
def tearDown(self): super(TestRequestsMockBasic, self).tearDown() StackInABox.reset_services() self.session.close()
def tearDown(self): super(TestHttprettyKeystone, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestKeystoneV2UserListing, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestMetrics, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestServiceRouteRegistration, self).tearDown() StackInABox.reset_services()
def tearDown(self): super(TestRequestMockAdvanced, self).tearDown() StackInABox.reset_services() self.session.close()