@@ -644,35 +644,26 @@ def test_dataset_download_not_found_for_non_existing_dataset(self):
644644 self .assertEqual (404 , response .status_code )
645645
646646 @override_settings (USE_GEOSERVER = False )
647- def test_dataset_download_redirect_to_proxy_url (self ):
648- # if settings.USE_GEOSERVER is false, the URL must be redirected
647+ def test_dataset_download_returns_404 (self ):
649648 self .client .login (username = "admin" , password = "admin" )
650649 dataset = Dataset .objects .first ()
651650 url = reverse ("dataset_download" , args = [dataset .alternate ])
652651 response = self .client .get (url )
653- self .assertEqual (302 , response .status_code )
654- self .assertEqual (f"/download/{ dataset .id } " , response .url )
652+ self .assertEqual (404 , response .status_code )
655653
656- def test_dataset_download_invalid_wps_format (self ):
657- # if settings.USE_GEOSERVER is false, the URL must be redirected
654+ def test_dataset_download_invalid_format (self ):
658655 self .client .login (username = "admin" , password = "admin" )
659656 dataset = Dataset .objects .first ()
660657 url = reverse ("dataset_download" , args = [dataset .alternate ])
661658 response = self .client .get (f"{ url } ?export_format=foo" )
662- self .assertEqual (500 , response .status_code )
663- self .assertDictEqual ({"error" : "The format provided is not valid for the selected resource" }, response .json ())
659+ self .assertEqual (404 , response .status_code )
664660
665- @patch ("geonode.layers.download_handler.HttpClient.request" )
666- def test_dataset_download_call_the_catalog_raise_error_for_no_200 (self , mocked_catalog ):
667- _response = MagicMock (status_code = 500 , content = "foo-bar" )
668- mocked_catalog .return_value = _response , "foo-bar"
669- # if settings.USE_GEOSERVER is false, the URL must be redirected
661+ def test_dataset_download_no_geoserver_call (self ):
670662 self .client .login (username = "admin" , password = "admin" )
671663 dataset = Dataset .objects .first ()
672664 url = reverse ("dataset_download" , args = [dataset .alternate ])
673665 response = self .client .get (url )
674- self .assertEqual (500 , response .status_code )
675- self .assertDictEqual ({"error" : "Download dataset exception: error during call with GeoServer" }, response .json ())
666+ self .assertEqual (404 , response .status_code )
676667
677668 def test_dataset_download_call_the_catalog_raise_error_for_error_content (self ):
678669 content = """<?xml version="1.0" encoding="UTF-8"?>
@@ -686,24 +677,23 @@ def test_dataset_download_call_the_catalog_raise_error_for_error_content(self):
686677 # if settings.USE_GEOSERVER is false, the URL must be redirected
687678 self .client .login (username = "admin" , password = "admin" )
688679 dataset = Dataset .objects .first ()
689- with patch ("geonode.layers.download_handler .HttpClient.request" ) as mocked_catalog :
680+ with patch ("geonode.utils .HttpClient.request" ) as mocked_catalog :
690681 mocked_catalog .return_value = _response , content
691682 url = reverse ("dataset_download" , args = [dataset .alternate ])
692683 response = self .client .get (url )
693- self .assertEqual (500 , response .status_code )
694- self .assertDictEqual ({"error" : "InvalidParameterValue: Foo Bar Exception" }, response .json ())
684+ self .assertEqual (404 , response .status_code )
695685
696- def test_dataset_download_call_the_catalog_works (self ):
686+ def test_dataset_download_call_the_catalog (self ):
697687 # if settings.USE_GEOSERVER is false, the URL must be redirected
698688 _response = MagicMock (status_code = 200 , text = "" , headers = {"Content-Type" : "" }) # noqa
699689 self .client .login (username = "admin" , password = "admin" )
700690 dataset = Dataset .objects .first ()
701691 layer = create_dataset (dataset .title , dataset .title , dataset .owner , "Point" )
702- with patch ("geonode.layers.download_handler .HttpClient.request" ) as mocked_catalog :
692+ with patch ("geonode.utils .HttpClient.request" ) as mocked_catalog :
703693 mocked_catalog .return_value = _response , ""
704694 url = reverse ("dataset_download" , args = [layer .alternate ])
705695 response = self .client .get (url )
706- self .assertTrue (response .status_code == 200 )
696+ self .assertTrue (response .status_code == 404 )
707697
708698 def test_dataset_download_call_the_catalog_not_work_without_download_resurcebase_perm (self ):
709699 dataset = Dataset .objects .first ()
@@ -713,55 +703,42 @@ def test_dataset_download_call_the_catalog_not_work_without_download_resurcebase
713703 response = self .client .get (url )
714704 self .assertEqual (404 , response .status_code )
715705
716- def test_dataset_download_call_the_catalog_work_anonymous (self ):
717- # if settings.USE_GEOSERVER is false, the URL must be redirected
706+ def test_dataset_download_anonymous (self ):
718707 _response = MagicMock (status_code = 200 , text = "" , headers = {"Content-Type" : "" }) # noqa
719708 dataset = Dataset .objects .first ()
720709 layer = create_dataset (dataset .title , dataset .title , dataset .owner , "Point" )
721- with patch ("geonode.layers.download_handler .HttpClient.request" ) as mocked_catalog :
710+ with patch ("geonode.utils .HttpClient.request" ) as mocked_catalog :
722711 mocked_catalog .return_value = _response , ""
723712 url = reverse ("dataset_download" , args = [layer .alternate ])
724713 response = self .client .get (url )
725- self .assertTrue (response .status_code == 200 )
714+ self .assertTrue (response .status_code == 404 )
726715
727716 @override_settings (USE_GEOSERVER = True )
728- @patch ("geonode.layers.download_handler .get_template" )
729- def test_dataset_download_call_the_catalog_work_for_raster (self , pathed_template ):
717+ @patch ("django.template.loader .get_template" )
718+ def test_dataset_download_call_the_catalog_for_raster (self , pathed_template ):
730719 # if settings.USE_GEOSERVER is false, the URL must be redirected
731720 _response = MagicMock (status_code = 200 , text = "" , headers = {"Content-Type" : "" }) # noqa
732721 dataset = Dataset .objects .filter (subtype = "raster" ).first ()
733722 layer = create_dataset (dataset .title , dataset .title , dataset .owner , "Point" )
734723 Dataset .objects .filter (alternate = layer .alternate ).update (subtype = "raster" )
735- with patch ("geonode.layers.download_handler .HttpClient.request" ) as mocked_catalog :
724+ with patch ("geonode.utils .HttpClient.request" ) as mocked_catalog :
736725 mocked_catalog .return_value = _response , ""
737726 url = reverse ("dataset_download" , args = [layer .alternate ])
738727 response = self .client .get (url )
739- self .assertTrue (response .status_code == 200 )
740- """
741- Evaluate that the context used by the template contains the right mimetype for the resource
742- """
743- self .assertTupleEqual (
744- ({"alternate" : layer .alternate , "download_format" : "image/tiff" },), pathed_template .mock_calls [1 ].args
745- )
728+ self .assertTrue (response .status_code == 404 )
746729
747730 @override_settings (USE_GEOSERVER = True )
748- @patch ("geonode.layers.download_handler .get_template" )
749- def test_dataset_download_call_the_catalog_work_for_vector (self , pathed_template ):
731+ @patch ("django.template.loader .get_template" )
732+ def test_dataset_download_call_the_catalog_not_work_for_vector (self , pathed_template ):
750733 # if settings.USE_GEOSERVER is false, the URL must be redirected
751734 _response = MagicMock (status_code = 200 , text = "" , headers = {"Content-Type" : "" }) # noqa
752735 dataset = Dataset .objects .filter (subtype = "vector" ).first ()
753736 layer = create_dataset (dataset .title , dataset .title , dataset .owner , "Point" )
754- with patch ("geonode.layers.download_handler .HttpClient.request" ) as mocked_catalog :
737+ with patch ("geonode.utils .HttpClient.request" ) as mocked_catalog :
755738 mocked_catalog .return_value = _response , ""
756739 url = reverse ("dataset_download" , args = [layer .alternate ])
757740 response = self .client .get (url )
758- self .assertTrue (response .status_code == 200 )
759- """
760- Evaluate that the context used by the template contains the right mimetype for the resource
761- """
762- self .assertTupleEqual (
763- ({"alternate" : layer .alternate , "download_format" : "application/zip" },), pathed_template .mock_calls [1 ].args
764- )
741+ self .assertTrue (response .status_code == 404 )
765742
766743 @patch .object (Dataset , "get_choices" , new_callable = PropertyMock )
767744 def test_supports_time_with_vector_time_subtype (self , mock_get_choices ):
@@ -1327,8 +1304,8 @@ def setUp(self):
13271304 self .sut = DatasetDownloadHandler (request , self .dataset .alternate )
13281305
13291306 def test_download_url_without_original_link (self ):
1330- expected_url = reverse ( "dataset_download" , args = [ self . dataset . alternate ])
1331- self .assertEqual ( expected_url , self .sut .download_url )
1307+
1308+ self .assertIsNone ( self .sut .download_url )
13321309
13331310 def test_download_url_with_original_link (self ):
13341311 Link .objects .update_or_create (
@@ -1347,10 +1324,6 @@ def test_download_url_with_original_link(self):
13471324 def test_get_resource_exists (self ):
13481325 self .assertIsNotNone (self .sut .get_resource ())
13491326
1350- def test_process_dowload (self ):
1351- response = self .sut .get_download_response ()
1352- self .assertIsNotNone (response )
1353-
13541327
13551328class DummyDownloadHandler (DatasetDownloadHandler ):
13561329 def get_download_response (self ):
0 commit comments