def test_path_and_query(self): method = SporeMethod(method='GET', name='test_method', path='/test?format=json', base_url='http://api.test.org/v2/') base_environ = method.base_environ() self.assertEqual(base_environ['spore.userinfo'], '') self.assertEqual(base_environ['SERVER_NAME'], 'api.test.org') self.assertEqual(base_environ['SERVER_PORT'], 80) self.assertEqual(base_environ['SCRIPT_NAME'], '/v2') self.assertEqual(base_environ['PATH_INFO'], '/test') self.assertEqual(base_environ['QUERY_STRING'], 'format=json') self.assertEqual(base_environ['wsgi.url_scheme'], 'http')
def test_server_port(self): method = SporeMethod(method='GET', name='test_method', path='/test', base_url='https://api.test.org:8081/') base_environ = method.base_environ() self.assertEqual(base_environ['spore.userinfo'], '') self.assertEqual(base_environ['SERVER_NAME'], 'api.test.org') self.assertEqual(base_environ['SERVER_PORT'], 8081) self.assertEqual(base_environ['SCRIPT_NAME'], '') self.assertEqual(base_environ['PATH_INFO'], '/test') self.assertEqual(base_environ['QUERY_STRING'], '') self.assertEqual(base_environ['wsgi.url_scheme'], 'https')
def test_userinfo(self): method = SporeMethod(method='GET', name='test_method', path='/test', base_url='http://*****:*****@api.test.org/') base_environ = method.base_environ() self.assertEqual(base_environ['spore.userinfo'], 'toto:123456789') self.assertEqual(base_environ['SERVER_NAME'], 'api.test.org') self.assertEqual(base_environ['SERVER_PORT'], 80) self.assertEqual(base_environ['SCRIPT_NAME'], '') self.assertEqual(base_environ['PATH_INFO'], '/test') self.assertEqual(base_environ['QUERY_STRING'], '') self.assertEqual(base_environ['wsgi.url_scheme'], 'http')