コード例 #1
0
    def test_login_and_upload_layers(self):
        """Test login page."""
        # Connection
        session = login_user(GEONODE_URL, LOGIN, PASSWORD)

        # Upload a single raster layer
        result = upload(GEONODE_URL, session, self.raster.source())
        self.assertTrue(result['success'])

        # Upload a vector layer (with many files)
        result = upload(GEONODE_URL, session, self.vector.source())
        self.assertTrue(result['success'])
コード例 #2
0
    def accept(self):
        """Upload the layer to Geonode."""
        enable_busy_cursor()
        self.button_box.setEnabled(False)
        layer = layer_from_combo(self.layers)

        login = self.login.text()
        if self.save_login.isChecked():
            set_setting(GEONODE_USER, login)
        else:
            set_setting(GEONODE_USER, '')

        password = self.password.text()
        if self.save_password.isChecked():
            set_setting(GEONODE_PASSWORD, password)
        else:
            set_setting(GEONODE_PASSWORD, '')

        url = self.url.text()
        if self.save_url.isChecked():
            set_setting(GEONODE_URL, url)
        else:
            set_setting(GEONODE_URL, '')

        geonode_session = login_user(url, login, password)

        try:
            result = upload(url, geonode_session, layer.source())
        except GeoNodeLayerUploadError as e:
            result = {
                'success': False,
                'message': str(e)
            }
        finally:
            self.button_box.setEnabled(True)
            disable_busy_cursor()

        if result['success']:
            self.done(QDialog.Accepted)
            layer_url = urljoin(url, result['url'])
            # Link is not working in QGIS 2.
            # It's gonna work in QGIS 3.
            if qgis_version() >= 29900:
                external_link = '<a href=\"{url}\">{url}</a>'.format(
                    url=layer_url)
            else:
                external_link = layer_url

            display_success_message_bar(
                tr('Uploading done'),
                tr('Successfully uploaded to {external_link}').format(
                    external_link=external_link),
            )
        else:
            display_warning_message_box(
                self,
                tr('Error while uploading the layer.'),
                str(result)
            )
コード例 #3
0
    def test_upload_tif_layer(self):
        """Test upload tif layer."""
        # Connection
        session = login_user(GEONODE_URL, LOGIN, PASSWORD)

        # Upload a single raster layer
        result = upload(GEONODE_URL, session, tif_layer_uri)
        self.assertTrue(result['success'])
        self.assertTrue(result['full_url'].startswith(GEONODE_URL))
コード例 #4
0
    def test_upload_shapefile_layers(self):
        """Test upload shapefile layer."""
        # Connection
        session = login_user(GEONODE_URL, LOGIN, PASSWORD)

        # Upload a vector layer (with many files)
        result = upload(GEONODE_URL, session, shapefile_layer_uri)
        self.assertTrue(result['success'])
        self.assertTrue(result['full_url'].startswith(GEONODE_URL))
コード例 #5
0
    def test_upload_shapefile_layers(self):
        """Test upload shapefile layer."""
        # Connection
        session = login_user(GEONODE_URL, LOGIN, PASSWORD)

        # Upload a vector layer (with many files)
        result = upload(GEONODE_URL, session, shapefile_layer_uri)
        self.assertTrue(result['success'])
        self.assertTrue(result['full_url'].startswith(GEONODE_URL))
コード例 #6
0
    def test_upload_ascii_layer(self):
        """Test upload ascii layer."""
        # Connection
        session = login_user(GEONODE_URL, LOGIN, PASSWORD)

        # Upload a single raster layer
        result = upload(GEONODE_URL, session, ascii_layer_uri)
        self.assertTrue(result['success'])
        self.assertTrue(result['full_url'].startswith(GEONODE_URL))