Beispiel #1
0
    def test_should_return_service_by_id(self):
        service = default_service()
        self.client.put(
            '/index-to-create/services/' + str(service["service"]["id"]),
            data=json.dumps(service),
            content_type='application/json'
        )

        with self.app.app_context():
            search_service.refresh('index-to-create')

        response = self.client.get(
            '/index-to-create/services/' + str(service["service"]["id"]))

        data = get_json_from_response(response)
        assert_equal(response.status_code, 200)
        assert_equal(
            data['services']["_id"],
            str(service["service"]["id"]))
        assert_equal(
            data['services']["_source"]["id"],
            str(service["service"]["id"]))

        cases = [
            # (indexed name, original name)
            ("filter_lot", "lot"),
            ("serviceName", "serviceName"),
            ("serviceSummary", "serviceSummary"),
            ("serviceBenefits", "serviceBenefits"),
            ("serviceFeatures", "serviceFeatures"),
            ("serviceTypes", "serviceTypes"),
            ("filter_serviceTypes", "serviceTypes"),
            ("supplierName", "supplierName"),
            ("filter_freeOption", "freeOption"),
            ("filter_trialOption", "trialOption"),
            ("filter_minimumContractPeriod", "minimumContractPeriod"),
            ("filter_supportForThirdParties", "supportForThirdParties"),
            ("filter_selfServiceProvisioning", "selfServiceProvisioning"),
            ("filter_datacentresEUCode", "datacentresEUCode"),
            ("filter_dataBackupRecovery", "dataBackupRecovery"),
            ("filter_dataExtractionRemoval", "dataExtractionRemoval"),
            ("filter_networksConnected", "networksConnected"),
            ("filter_apiAccess", "apiAccess"),
            ("filter_openStandardsSupported", "openStandardsSupported"),
            ("filter_openSource", "openSource"),
            ("filter_persistentStorage", "persistentStorage"),
            ("filter_guaranteedResources", "guaranteedResources"),
            ("filter_elasticCloud", "elasticCloud")
        ]

        # filter fields are processed (lowercase etc)
        # and also have a new key (filter_FIELDNAME)
        for key in cases:
            original = service["service"][key[1]]
            indexed = data['services']["_source"][key[0]]
            if key[0].startswith("filter"):
                original = process_values_for_matching(service["service"][key[1]])
            assert_equal(original, indexed)
Beispiel #2
0
    def test_service_should_have_all_exact_match_fields(self):
        service = default_service()
        self.client.put(
            '/index-to-create/services/' + str(service["service"]["id"]),
            data=json.dumps(service),
            content_type='application/json'
        )

        with self.app.app_context():
            search_service.refresh('index-to-create')
        response = self.client.get(
            '/index-to-create/services/' + str(service["service"]["id"]))

        data = get_json_from_response(response)
        assert_equal(response.status_code, 200)

        cases = [
            "lot",
            "serviceTypes",
            "freeOption",
            "trialOption",
            "minimumContractPeriod",
            "supportForThirdParties",
            "selfServiceProvisioning",
            "datacentresEUCode",
            "dataBackupRecovery",
            "dataExtractionRemoval",
            "networksConnected",
            "apiAccess",
            "openStandardsSupported",
            "openSource",
            "persistentStorage",
            "guaranteedResources",
            "elasticCloud"
        ]

        for key in cases:
            assert_equal(
                data['services']["_source"]["filter_" + key],
                process_values_for_matching(service["service"][key]))