Esempio n. 1
0
    def test_1(self):
        """Test the import of two scenes with 2 bands in a new mapset A"""
        self.check_remove_test_mapsets()

        ############################################################################
        rv = self.server.post(URL_PREFIX +
                              '/locations/LL/mapsets/A/sentinel2_import',
                              headers=self.admin_auth_header,
                              data=json_dump(PRODUCT_IDS),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header)

        rv = self.server.get(URL_PREFIX + '/locations/LL/mapsets/A/strds',
                             headers=self.admin_auth_header)
        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        strds_list = json_load(rv.data)["process_results"]
        self.assertTrue("S2A_B04" in strds_list)
        self.assertTrue("S2A_B08" in strds_list)
Esempio n. 2
0
    def test_sync_sampling_where(self):

        rv = self.server.post(
            URL_PREFIX +
            '/locations/ECAD/mapsets/PERMANENT/strds/temperature_mean_1950_2013_yearly_celsius/'
            'sampling_sync',
            headers=self.user_auth_header,
            data=json_dump({
                "points": [["a", "-5.095406", "38.840583"],
                           ["b", "9.9681980", "51.666166"],
                           ["c", "24.859647", "52.699099"]],
                "where":
                "start_time >'2010-01-01'"
            }),
            content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        value_list = json_load(rv.data)["process_results"]

        self.assertEqual(value_list[0][0], "start_time")
        self.assertEqual(value_list[0][1], "end_time")
        self.assertEqual(value_list[0][2], "a")
        self.assertEqual(value_list[0][3], "b")
        self.assertEqual(value_list[0][4], "c")
    def test_sync_raster_area_stats_module_error(self):
        rv = self.server.post(URL_PREFIX + '/locations/nc_spm_08/mapsets/PERMANENT/raster_layers/basin_50K/'
                              'area_stats_univar_sync',
                              headers=self.admin_auth_header,
                              data=json_dump({}),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 400, "HTML status code is wrong %i"%rv.status_code)
        self.assertEqual(rv.mimetype, "application/json", "Wrong mimetype %s"%rv.mimetype)
Esempio n. 4
0
    def test_1_error_mapset_exists(self):
        """PERMANENT mapset exists. hence an error message is expected
        """
        rv = self.server.post(URL_PREFIX + '/locations/LL/mapsets/PERMANENT/landsat_import',
                              headers=self.admin_auth_header,
                              data=json_dump(SCENE_IDS),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header,
                                       http_status=400, status="error",
                                       message_check="AsyncProcessError:")
Esempio n. 5
0
    def test_error_1(self):
        rv = self.server.post(URL_PREFIX + '/sentinel2a_aws_query',
                              headers=self.user_auth_header,
                              data=json_dump(SCENES_ERROR),
                              content_type="application/json")

        pprint(json_load(rv.data))

        self.assertEqual(rv.status_code, 400,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)
    def test_async_raster_area_stats_json(self):
        rv = self.server.post(
            URL_PREFIX +
            '/locations/nc_spm_08/mapsets/PERMANENT/raster_layers/landuse96_28m/'
            'area_stats_async',
            headers=self.admin_auth_header,
            data=json_dump(JSON),
            content_type="application/json")

        rv = self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header)

        self.assertEqual(len(rv["process_results"]), 16)

        time.sleep(1)
Esempio n. 7
0
    def test_async_raster_area_stats_json(self):
        rv = self.server.post(
            URL_PREFIX +
            '/locations/nc_spm_08/mapsets/PERMANENT/raster_layers/elevation/'
            'area_stats_univar_async',
            headers=self.admin_auth_header,
            data=json_dump(JSON),
            content_type="application/json")

        rv = self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header)

        value_list = rv["process_results"]
        self.assertEqual(value_list[0]["cat"], "1")
        self.assertEqual(value_list[0]["raster_number"], 2025000)
Esempio n. 8
0
    def test_wrong_scene_ids(self):
        """Test the import of two scenes with 2 bands in a new mapset A"""
        self.check_remove_test_mapsets()

        ############################################################################
        rv = self.server.post(URL_PREFIX + '/locations/LL/mapsets/A/landsat_import',
                              headers=self.admin_auth_header,
                              data=json_dump(WRONG_SCENE_IDS),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.waitAsyncStatusAssertHTTP(rv, headers=self.admin_auth_header,
                                       http_status=400, status="error",
                                       message_check="AsyncProcessError:")
    def test_sync_raster_area_stats_error_wrong_timestamp(self):
        rv = self.server.post(URL_PREFIX +
                              '/locations/ECAD/mapsets/PERMANENT/strds/'
                              'temperature_mean_1950_2013_yearly_celsius/'
                              'timestamp/2001-01-01T00.00.00/'
                              'area_stats_univar_sync',
                              headers=self.admin_auth_header,
                              data=json_dump(JSON),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 400,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)
Esempio n. 10
0
    def test_async_sampling(self):

        rv = self.server.post(
            URL_PREFIX +
            '/locations/ECAD/mapsets/PERMANENT/strds/temperature_mean_1950_2013_yearly_celsius/'
            'sampling_async',
            headers=self.user_auth_header,
            data=json_dump({
                "points": [["a", "-5.095406", "38.840583"],
                           ["b", "9.9681980", "51.666166"],
                           ["c", "24.859647", "52.699099"]]
            }),
            content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        resp = json_load(rv.data)

        rv_user_id = resp["user_id"]
        rv_resource_id = resp["resource_id"]

        while True:
            rv = self.server.get(URL_PREFIX + "/resources/%s/%s" %
                                 (rv_user_id, rv_resource_id),
                                 headers=self.user_auth_header)
            print(rv.data)
            resp = json_load(rv.data)
            if resp["status"] == "finished" or resp["status"] == "error":
                break
            time.sleep(0.2)

        self.assertEquals(resp["status"], "finished")
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)

        value_list = json_load(rv.data)["process_results"]

        self.assertEqual(value_list[0][0], "start_time")
        self.assertEqual(value_list[0][1], "end_time")
        self.assertEqual(value_list[0][2], "a")
        self.assertEqual(value_list[0][3], "b")
        self.assertEqual(value_list[0][4], "c")

        time.sleep(1)
Esempio n. 11
0
    def test_4_error_wrong_product_id(self):
        """Check if a missing product id is found
        """
        self.check_remove_test_mapsets()

        rv = self.server.post(URL_PREFIX +
                              '/locations/LL/mapsets/A/sentinel2_import',
                              headers=self.admin_auth_header,
                              data=json_dump(PRODUCT_IDS_ONE_WRONG),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.waitAsyncStatusAssertHTTP(rv,
                                       headers=self.admin_auth_header,
                                       http_status=400,
                                       status="error",
                                       message_check="AsyncProcessError:")
Esempio n. 12
0
    def test_3_error_wrong_bands_ids(self):
        """Check for wrong band ids
        """
        self.check_remove_test_mapsets()

        rv = self.server.post(URL_PREFIX +
                              '/locations/LL/mapsets/A/sentinel2_import',
                              headers=self.admin_auth_header,
                              data=json_dump(WRONG_BANDS_IDS),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.waitAsyncStatusAssertHTTP(rv,
                                       headers=self.admin_auth_header,
                                       http_status=400,
                                       status="error",
                                       message_check="AsyncProcessError:")
    def test_sync_raster_area_stats_1(self):
        rv = self.server.post(
            URL_PREFIX +
            '/locations/nc_spm_08/mapsets/PERMANENT/raster_layers/landuse96_28m/'
            'area_stats_sync',
            headers=self.admin_auth_header,
            data=json_dump(JSON),
            content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        value_list = json_load(rv.data)["process_results"]
        self.assertEqual(len(value_list), 16)
    def test_sync_raster_area_stats_2(self):
        rv = self.server.post(URL_PREFIX +
                              '/locations/ECAD/mapsets/PERMANENT/strds/'
                              'temperature_mean_1950_2013_yearly_celsius/'
                              'timestamp/2001-01-01T00:00:00/'
                              'area_stats_univar_sync',
                              headers=self.admin_auth_header,
                              data=json_dump(JSON),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        value_list = json_load(rv.data)["process_results"]
        self.assertEqual(value_list[0]["cat"], "1")
        self.assertEqual(value_list[0]["raster_number"], 209)
Esempio n. 15
0
    def test_sync_raster_area_stats_2(self):

        rv = self.server.post(
            URL_PREFIX +
            '/locations/nc_spm_08/mapsets/PERMANENT/raster_layers/towns/'
            'area_stats_univar_sync',
            headers=self.admin_auth_header,
            data=json_dump(JSON),
            content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        value_list = json_load(rv.data)["process_results"]
        self.assertEqual(value_list[0]["cat"], "1")
        self.assertEqual(value_list[0]["raster_number"], 2025000)
Esempio n. 16
0
    def test_async_sampling(self):

        rv = self.server.post(URL_PREFIX + '/locations/nc_spm_08/mapsets/PERMANENT/raster_layers/landuse96_28m/'
                              'sampling_async',
                              headers=self.user_auth_header,
                              data=json_dump({"points":[["p1", "638684.0", "220210.0"],
                                                         ["p2", "635676.0", "226371.0"]]}),
                              content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200, "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json", "Wrong mimetype %s" % rv.mimetype)

        resp = json_load(rv.data)

        rv_user_id = resp["user_id"]
        rv_resource_id = resp["resource_id"]

        while True:
            rv = self.server.get(URL_PREFIX + "/resources/%s/%s" % (rv_user_id, rv_resource_id),
                                 headers=self.user_auth_header)
            resp = json_load(rv.data)
            if resp["status"] == "finished" or resp["status"] == "error":
                break
            time.sleep(0.2)

        self.assertEquals(resp["status"], "finished", "Process not finished.")
        self.assertEqual(rv.status_code, 200, "HTML status code is wrong %i"%rv.status_code)

        value_list = json_load(rv.data)["process_results"]

        self.assertIn("p1", value_list[0], "'p1' not in process_results")
        self.assertIn("p2", value_list[1], "'p2' not in process_results")
        self.assertIn("easting", value_list[0]["p1"])
        self.assertIn("northing", value_list[0]["p1"])
        self.assertIn("map_name", value_list[0]["p1"])
        self.assertIn("label", value_list[0]["p1"])
        self.assertIn("value", value_list[0]["p1"])
        self.assertIn("color", value_list[0]["p1"])
        self.assertEqual(value_list[0]["p1"]["map_name"], "landuse96_28m")

        time.sleep(1)
Esempio n. 17
0
    def test_sync_sampling_geojson(self):

        rv = self.server.post(
            URL_PREFIX +
            '/locations/ECAD/mapsets/PERMANENT/strds/temperature_mean_1950_2013_yearly_celsius/'
            'sampling_sync_geojson',
            headers=self.user_auth_header,
            data=json_dump(JSON),
            content_type="application/json")

        pprint(json_load(rv.data))
        self.assertEqual(rv.status_code, 200,
                         "HTML status code is wrong %i" % rv.status_code)
        self.assertEqual(rv.mimetype, "application/json",
                         "Wrong mimetype %s" % rv.mimetype)

        value_list = json_load(rv.data)["process_results"]

        self.assertEqual(value_list[0][0], "start_time")
        self.assertEqual(value_list[0][1], "end_time")
        self.assertEqual(value_list[0][2], "1")
        self.assertEqual(value_list[0][3], "2")
        self.assertEqual(value_list[0][4], "3")