def test_invalid_target(self): session = client.upload(vector_file('san_andres_y_providencia_poi.shp')) try: session.tasks[0].target.change_datastore('foobar') self.fail('Expected BadRequest') except BadRequest, br: self.assertEqual('Unable to find referenced store', str(br)) except: self.fail('Expected BadRequest') print 'using GEOSERVER_BASE_URL=%s' % GEOSERVER_BASE_URL # Preflight connection testing print 'testing access...', client = Client(GEOSERVER_REST_URL) gscat = catalog.Catalog(GEOSERVER_REST_URL) try: sessions = client.get_sessions() print 'successfully listed imports...', ids = [ s.id for s in sessions ] gscat.get_layers() print 'successfully listed layers...' except socket.error, ex: print 'error connecting to the server, check your GEOSERVER_BASE_URL' print ex sys.exit(1) # handy while testing if '--clean' in sys.argv: print 'cleaning'
ogc_server_settings = OGC_Servers_Handler(settings.OGC_SERVER)['default'] _wms = None _csw = None _user, _password = ogc_server_settings.credentials http_client = httplib2.Http() http_client.add_credentials(_user, _password) http_client.add_credentials(_user, _password) _netloc = urlparse(ogc_server_settings.LOCATION).netloc http_client.authorizations.append( httplib2.BasicAuthentication((_user, _password), _netloc, ogc_server_settings.LOCATION, {}, None, None, http_client)) url = ogc_server_settings.rest gs_catalog = Catalog(url, _user, _password) gs_uploader = Client(url, _user, _password) _punc = re.compile(r"[\.:]") #regex for punctuation that confuses restconfig _foregrounds = [ "#ffbbbb", "#bbffbb", "#bbbbff", "#ffffbb", "#bbffff", "#ffbbff" ] _backgrounds = [ "#880000", "#008800", "#000088", "#888800", "#008888", "#880088" ] _marks = ["square", "circle", "cross", "x", "triangle"] _style_contexts = izip(cycle(_foregrounds), cycle(_backgrounds), cycle(_marks)) _default_style_names = ["point", "line", "polygon", "raster"]