Exemple #1
0
    def setUp(self):
        self.wps_path = "/ows/wps"
        settings = {
            "weaver.url": "",
            "weaver.wps": True,
            "weaver.wps_path": self.wps_path,
            "weaver.wps_metadata_identification_title":
            "Weaver WPS Test Server",
            "weaver.wps_metadata_provider_name": WpsAppTest.__name__
        }
        config = get_test_weaver_config(settings=settings)
        config = setup_config_with_mongodb(config)
        config = setup_config_with_pywps(config)
        config = setup_config_with_celery(config)
        self.process_store = setup_mongodb_processstore(config)
        self.app = get_test_weaver_app(config=config, settings=settings)

        # add processes by database Process type
        self.process_public = WpsTestProcess(identifier="process_public")
        self.process_private = WpsTestProcess(identifier="process_private")
        self.process_store.save_process(self.process_public)
        self.process_store.save_process(self.process_private)
        self.process_store.set_visibility(self.process_public.identifier,
                                          VISIBILITY_PUBLIC)
        self.process_store.set_visibility(self.process_private.identifier,
                                          VISIBILITY_PRIVATE)

        # add processes by pywps Process type
        self.process_store.save_process(HelloWPS())
        self.process_store.set_visibility(HelloWPS.identifier,
                                          VISIBILITY_PUBLIC)
Exemple #2
0
 def setUpClass(cls):
     config = setup_config_with_mongodb(settings=cls.settings)
     config = setup_config_with_pywps(config)
     config = setup_config_with_celery(config)
     config = get_test_weaver_config(config)
     cls.process_store = setup_mongodb_processstore(config)  # force reset
     cls.job_store = setup_mongodb_jobstore(config)
     cls.app = get_test_weaver_app(config=config, settings=cls.settings)
     cls.db = get_db(config)
     cls.config = config
     cls.settings.update(cls.config.registry.settings)  # back propagate changes
Exemple #3
0
 def setUpClass(cls):
     settings = {
         "weaver.url": "https://localhost",
         "weaver.wps_path": "/ows/wps",
     }
     cls.config = setup_config_with_mongodb(settings=settings)
     cls.app = get_test_weaver_app(config=cls.config)
     cls.json_headers = {
         "Accept": CONTENT_TYPE_APP_JSON,
         "Content-Type": CONTENT_TYPE_APP_JSON
     }
     cls.app = webtest.TestApp(cls.config.make_wsgi_app())
Exemple #4
0
 def setUpClass(cls):
     warnings.simplefilter("ignore", TimeZoneInfoAlreadySetWarning)
     cls.config = setup_config_with_mongodb()
     cls.config.include("weaver.wps")
     cls.config.include("weaver.wps_restapi")
     cls.config.include("weaver.tweens")
     cls.config.registry.settings.update({
         "weaver.url": "localhost",
         "weaver.wps_email_encrypt_salt": "weaver-test",
     })
     cls.config.scan()
     cls.json_headers = {"Accept": CONTENT_TYPE_APP_JSON, "Content-Type": CONTENT_TYPE_APP_JSON}
     cls.app = webtest.TestApp(cls.config.make_wsgi_app())
Exemple #5
0
 def setUp(self):
     config = setup_config_with_mongodb()
     self.testapp = get_test_weaver_app(config)
Exemple #6
0
def test_register_wps_processes_from_config_valid():
    """
    Validate the different combinations of supported remote WPS-1 processes and providers specifications.
    """
    settings = {
        "weaver.url": "https://localhost",
        "weaver.wps_path": "/ows/wps",
        # define some options to avoid useless retry/timeout
        # everything is mocked and should return immediately
        "weaver.request_options": {
            "requests": [{
                "url": WPS1_URL1,
                "method": "get",
                "timeout": 1,
                "retry": 0
            }]
        }
    }
    config = setup_config_with_mongodb(settings=settings)
    p_store = setup_mongodb_processstore(config)
    s_store = setup_mongodb_servicestore(config)
    p_store.clear_processes()
    s_store.clear_services()

    with tempfile.NamedTemporaryFile(mode="w", suffix=".yml") as f:
        yaml.safe_dump(
            {
                # dynamic processes, only register provider explicitly, processes fetched on demand
                "providers": [
                    WPS1_URL1,  # direct URL string
                    {
                        "url": WPS1_URL2
                    },  # implicit name, but as dict
                    {
                        "name": "test-explicit-name",
                        "url": WPS1_URL3
                    },
                ],
                # static processes, all the ones under service are registered explicitly, unless filtered
                "processes": [
                    WPS1_URL1,
                    # direct URL string, has only 1 process that will be retrieved by DescribeProcess 'iteratively'
                    # the 'GetCapabilities' provides which processes to iterate over
                    resources.GET_CAPABILITIES_TEMPLATE_URL.format(WPS1_URL2),
                    # following will call DescribeProcess
                    resources.DESCRIBE_PROCESS_TEMPLATE_URL.format(
                        WPS1_URL3, resources.TEST_REMOTE_PROCESS_WPS1_ID),
                    # same as GetCapabilities with iteration on available processes with DescribeProcess,
                    # but will replace the default server name by the provided one (so can reuse same URL)
                    {
                        "name": "test-static-process",
                        "url": WPS1_URL1
                    },
                    # directly call DescribeProcess bypassing the GetCapabilities
                    {
                        "name":
                        "test-filter-process",
                        "url":
                        WPS1_URL4,
                        # should only fetch following two rather than the 11 (fake) ones reported by GetCapabilities
                        "id": [
                            resources.WPS_ENUM_ARRAY_IO_ID,
                            resources.WPS_LITERAL_COMPLEX_IO_ID
                        ]
                    }
                ]
            },
            f)

        try:
            # note:
            #   can take some time to process since OWSLib must parse all GetCapabilities/DescribeProcesses responses
            register_wps_processes_from_config(f.name, config)
        except Exception:  # noqa
            pytest.fail(
                "Valid definitions in configuration file should not raise any error"
            )

    # validate results
    processes = p_store.list_processes()
    providers = s_store.list_services()

    # generate equivalent of inferred named (simplified)
    infer_name1 = WPS1_URL1.split("://")[-1].replace(".com", "_com")
    infer_name2 = WPS1_URL2.split("://")[-1].replace(".com", "_com")
    infer_name3 = WPS1_URL3.split("://")[-1].replace(".com", "_com")

    # dynamic provider inferred names are sanitized/slug of URL
    assert len(
        providers
    ) == 3, "Number of dynamic WPS-1 providers registered should match number from file."
    svc1 = s_store.fetch_by_name(infer_name1)
    assert svc1.url == WPS1_URL1
    svc2 = s_store.fetch_by_name(infer_name2)
    assert svc2.url == WPS1_URL2
    svc3 = s_store.fetch_by_name("test-explicit-name")
    assert svc3.url == WPS1_URL3

    # (1) first server has 1 process in GetCapabilities, the basic URL registers only that process
    # (1) second server also has 1 process, but GetCapabilities queries already in the URL are cleaned up
    # (1) third directly references the DescribeProcess request, so it is fetched directly
    # (1) fourth entry is the same as first, just using another name
    # (2) fifth entry provided 2 processes ID explicitly. Although 11 processes are available, only those 2 are created.
    assert len(
        processes
    ) == 6, "Number of static remote WPS-1 processes registered should match number from file."

    # static processes inferred names are a concatenation of the URL sanitized/slug + process-ID
    proc1_id = infer_name1 + "_" + resources.TEST_REMOTE_PROCESS_WPS1_ID
    proc1 = p_store.fetch_by_id(proc1_id)
    assert proc1.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "provider"] == WPS1_URL1 + "/"
    assert proc1.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "process"] == resources.TEST_REMOTE_PROCESS_WPS1_ID
    proc2_id = infer_name2 + "_" + resources.TEST_REMOTE_PROCESS_WPS1_ID
    proc2 = p_store.fetch_by_id(proc2_id)
    assert proc2.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "provider"] == WPS1_URL2 + "/"
    assert proc2.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "process"] == resources.TEST_REMOTE_PROCESS_WPS1_ID
    proc3_id = infer_name3 + "_" + resources.TEST_REMOTE_PROCESS_WPS1_ID
    proc3 = p_store.fetch_by_id(proc3_id)
    assert proc3.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "provider"] == WPS1_URL3 + "/"
    assert proc3.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "process"] == resources.TEST_REMOTE_PROCESS_WPS1_ID
    # although an explicit name is provided, the URL point to generic GetCapabilities
    # therefore, multiple processes *could* be registered, which require same server-name+process-id concat as above
    proc4_id = "test-static-process_" + resources.TEST_REMOTE_PROCESS_WPS1_ID
    proc4 = p_store.fetch_by_id(proc4_id)
    assert proc4.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "provider"] == WPS1_URL1 + "/"
    assert proc4.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "process"] == resources.TEST_REMOTE_PROCESS_WPS1_ID
    # last server is the same, but specific IDs are given
    # still, concat happens to avoid conflicts against multiple servers sharing process-IDs, although distinct
    proc5_id = "test-filter-process_" + resources.WPS_ENUM_ARRAY_IO_ID
    proc5 = p_store.fetch_by_id(proc5_id)
    assert proc5.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "provider"] == WPS1_URL4 + "/"
    assert proc5.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "process"] == resources.WPS_ENUM_ARRAY_IO_ID
    proc6_id = "test-filter-process_" + resources.WPS_LITERAL_COMPLEX_IO_ID
    proc6 = p_store.fetch_by_id(proc6_id)
    assert proc6.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "provider"] == WPS1_URL4 + "/"
    assert proc6.package["hints"][CWL_REQUIREMENT_APP_WPS1][
        "process"] == resources.WPS_LITERAL_COMPLEX_IO_ID