Пример #1
0
    def test_cleanup(self):
        from geonode.maps.utils import cleanup
        from geoserver.catalog import FailedRequestError

        self.assertRaises(GeoNodeException, cleanup, "CA", "1234")
        cleanup("FOO", "1234")

        def blowup(self):
            raise FailedRequestError()

        with patch('geonode.maps.models.Layer.objects.gs_catalog') as mock_catalog:
            mock_catalog.get_store.return_value = None
            cleanup("FOO", "1234")

        with patch('geonode.maps.models.Layer.objects.gs_catalog') as mock_catalog:
            mock_catalog.get_store.side_effect = blowup

            cleanup("FOO", "1234")

        with patch('geonode.maps.models.Layer.objects.gs_catalog') as mock_catalog:
            mock_catalog.get_layer.return_value = None
            cleanup("FOO", "1234")

        with patch('geonode.maps.models.Layer.objects.gs_catalog') as mock_catalog:
            mock_catalog.delete.side_effect = blowup
            cleanup("FOO", "1234")
Пример #2
0
    def test_cleanup(self):
        from geonode.maps.utils import cleanup
        from geoserver.catalog import FailedRequestError
        from mock import patch

        self.assertRaises(GeoNodeException, cleanup, "CA", "1234")
        cleanup("FOO", "1234")

        def blowup(self):
            raise FailedRequestError()

        with patch('geonode.maps.models.Layer.objects.gs_catalog'
                   ) as mock_catalog:
            mock_catalog.get_store.return_value = None
            cleanup("FOO", "1234")

        with patch('geonode.maps.models.Layer.objects.gs_catalog'
                   ) as mock_catalog:
            mock_catalog.get_store.side_effect = blowup

            cleanup("FOO", "1234")

        with patch('geonode.maps.models.Layer.objects.gs_catalog'
                   ) as mock_catalog:
            mock_catalog.get_layer.return_value = None
            cleanup("FOO", "1234")

        with patch('geonode.maps.models.Layer.objects.gs_catalog'
                   ) as mock_catalog:
            mock_catalog.delete.side_effect = blowup
            cleanup("FOO", "1234")
Пример #3
0
    def test_cleanup(self):
        """Cleanup functions in the utils module work
        """
        from geonode.maps.utils import cleanup

        thefile = os.path.join(TEST_DATA, 'lembang_mmi_hazmap.asc')
        uploaded = save_to_geonode(thefile, user=self.user)
        check_layer(uploaded)

        name = uploaded.name
        uuid = uploaded.uuid
        pk = uploaded.pk

        # try calling the cleanup function when the django record exists:
        try:
            cleanup(name, uuid)
        except GeoNodeException, e:
            pass
Пример #4
0
    def test_cleanup(self):
        """Cleanup functions in the utils module work
        """
        from geonode.maps.utils import cleanup

        thefile = os.path.join(TESTDATA, 'lembang_mmi_hazmap.asc')
        uploaded = save_to_geonode(thefile, user=self.user, overwrite=True)
        check_layer(uploaded, full=True)

        name = uploaded.name
        uuid = uploaded.uuid
        pk = uploaded.pk

        # try calling the cleanup function when the django record exists:
        try:
            cleanup(name, uuid)
        except GeoNodeException, e:
            pass
Пример #5
0
            cleanup(name, uuid)
        except GeoNodeException, e:
            pass
        else:
            msg = ('Cleaup should raise an exception if the layer [%s]'
                   ' exists in the django db' % name)
            assert False, msg

        # Manually delete the layer object with SQL
        from django.db import connection, transaction
        cursor = connection.cursor()
        cursor.execute('DELETE FROM maps_layer WHERE id = %d' % pk)
        transaction.commit_unless_managed()

        # After this, the records should not live in GeoServer or Geonetwork
        cleanup(name, uuid)

        #FIXME: Verify the record does not exist in GS or GN

    def test_keywords(self):
        """Check that keywords are read from the .keywords file
        """
        thefile = os.path.join(TEST_DATA, 'Lembang_Earthquake_Scenario.asc')
        uploaded = save_to_geonode(thefile, user=self.user, overwrite=True)

        keywords = uploaded.keywords
        msg = 'No keywords found in layer %s' % uploaded.name
        assert len(keywords) > 0, msg

        keywords_file = thefile.replace('.asc', '.keywords')
        f = open(keywords_file, 'r')
Пример #6
0
            cleanup(name, uuid)
        except GeoNodeException, e:
            pass
        else:
            msg = ('Cleaup should raise an exception if the layer [%s]'
                   ' exists in the django db' % name)
            assert False, msg

        # Manually delete the layer object with SQL
        from django.db import connection, transaction
        cursor = connection.cursor()
        cursor.execute('DELETE FROM maps_layer WHERE id = %d' % pk)
        transaction.commit_unless_managed()

        # After this, the records should not live in GeoServer or Geonetwork
        cleanup(name, uuid)

        #FIXME: Verify the record does not exist in GS or GN

    def test_keywords(self):
        """Keywords are read correctly from the .keywords file
        """

        for filename in [
                'Earthquake_Ground_Shaking.asc',
                'Lembang_Earthquake_Scenario.asc', 'Padang_WGS84.shp'
        ]:

            _, ext = os.path.splitext(filename)
            thefile = os.path.join(TESTDATA, filename)
            uploaded = save_to_geonode(thefile, user=self.user, overwrite=True)