def test_additional_properties_has_validation_error():
    data = load_example_listing("G7-SCS")
    data = drop_api_exported_fields_so_that_api_import_will_validate(data)
    data.update({'newKey': 1})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "Additional properties are not allowed ('newKey' was unexpected)" \
           in "{}".format(errs['_form'])
예제 #2
0
def test_additional_properties_has_validation_error():
    data = load_example_listing("G7-SCS")
    data = drop_api_exported_fields_so_that_api_import_will_validate(data)
    data.update({'newKey': 1})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "Additional properties are not allowed ('newKey' was unexpected)" \
           in "{}".format(errs['_form'])
def test_too_many_list_items_causes_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceBenefits': [
        '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'
    ]})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "max_items_limit" in errs['serviceBenefits']
def test_too_many_list_items_causes_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceBenefits': [
        '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'
    ]})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "max_items_limit" in errs['serviceBenefits']
def test_required_fields_param_requires_specified_fields():
    data = load_example_listing("G7-SCS")
    data.pop("serviceSummary", None)
    data.pop("serviceDefinitionDocumentURL", None)
    errs = get_validation_errors("services-g-cloud-7-scs", data,
                                 enforce_required=False,
                                 required_fields=['serviceSummary'])
    assert "answer_required" in errs['serviceSummary']
def test_required_fields_param_requires_specified_fields():
    data = load_example_listing("G7-SCS")
    data.pop("serviceSummary", None)
    data.pop("serviceDefinitionDocumentURL", None)
    errs = get_validation_errors("services-g-cloud-7-scs", data,
                                 enforce_required=False,
                                 required_fields=['serviceSummary'])
    assert "answer_required" in errs['serviceSummary']
def test_enforce_required_false_allows_missing_fields():
    data = load_example_listing("G7-SCS")
    data = drop_api_exported_fields_so_that_api_import_will_validate(data)
    data.pop("serviceSummary", None)
    data.pop("serviceDefinitionDocumentURL", None)
    errs = get_validation_errors("services-g-cloud-7-scs", data,
                                 enforce_required=False)
    assert not errs
def test_enforce_required_false_allows_missing_fields():
    data = load_example_listing("G7-SCS")
    data = drop_api_exported_fields_so_that_api_import_will_validate(data)
    data.pop("serviceSummary", None)
    data.pop("serviceDefinitionDocumentURL", None)
    errs = get_validation_errors("services-g-cloud-7-scs", data,
                                 enforce_required=False)
    assert not errs
def test_min_price_larger_than_max_price_causes_validation_error():
    cases = ['32.20', '9.00']

    for price_max in cases:
        data = load_example_listing("G7-SCS")
        data.update({"priceMax": price_max})
        errs = get_validation_errors("services-g-cloud-7-scs", data)

        assert 'max_less_than_min' == errs['priceMax']
def test_max_price_larger_than_min_price():
    cases = ['132.20', '']

    for price_max in cases:
        data = load_example_listing("G7-SCS")
        data.update({"priceMax": price_max})
        errs = get_validation_errors("services-g-cloud-7-scs", data)

        assert 'priceMax' not in errs
예제 #11
0
def test_assurance_only_causes_validation_error():
    data = load_example_listing("G6-PaaS")
    data.update({
        'serviceAvailabilityPercentage': {
            "assurance": "Service provider assertion"
        }
    })
    errs = get_validation_errors("services-g-cloud-7-paas", data)
    assert "answer_required" in errs['serviceAvailabilityPercentage']
예제 #12
0
def test_max_price_larger_than_min_price():
    cases = ['132.20', '']

    for price_max in cases:
        data = load_example_listing("G7-SCS")
        data.update({"priceMax": price_max})
        errs = get_validation_errors("services-g-cloud-7-scs", data)

        yield assert_not_in, 'priceMax', errs
def test_min_price_larger_than_max_price_causes_validation_error():
    cases = ['32.20', '9.00']

    for price_max in cases:
        data = load_example_listing("G7-SCS")
        data.update({"priceMax": price_max})
        errs = get_validation_errors("services-g-cloud-7-scs", data)

        assert 'max_less_than_min' == errs['priceMax']
예제 #14
0
def test_non_number_value_causes_validation_error():
    data = load_example_listing("G6-PaaS")
    data.update({
        'serviceAvailabilityPercentage': {
            "value": "a99.9",
            "assurance": "Service provider assertion"
        }
    })
    errs = get_validation_errors("services-g-cloud-7-paas", data)
    assert "not_a_number" in errs['serviceAvailabilityPercentage']
def test_price_not_money_format_validation_error():
    cases = [
        "foo",  # not numeric
        "12.",  # too few decimal places
        "12.000001",  # too many decimal places
        ".1",  # too few digits
    ]
    data = load_example_listing("G7-SCS")

    def check_min_price_error(field, case):
        data[field] = case
        errs = get_validation_errors("services-g-cloud-7-scs", data)
        assert field in errs
        assert "not_money_format" in errs[field]

    check_min_price_error('priceMin', "")

    for case in cases:
        check_min_price_error('priceMin', case)
        check_min_price_error('priceMax', case)
예제 #16
0
def test_price_not_money_format_validation_error():
    cases = [
        "foo",  # not numeric
        "12.",  # too few decimal places
        "12.000001",  # too many decimal places
        ".1",  # too few digits
    ]
    data = load_example_listing("G7-SCS")

    def check_min_price_error(field, case):
        data[field] = case
        errs = get_validation_errors("services-g-cloud-7-scs", data)
        assert field in errs
        assert "not_money_format" in errs[field]

    yield check_min_price_error, 'priceMin', ""

    for case in cases:
        yield check_min_price_error, 'priceMin', case
        yield check_min_price_error, 'priceMax', case
예제 #17
0
def test_price_not_money_format_valid_cases():
    cases = [
        '12',
        '12.1',
        '12.11',
        '12.111',
        '12.1111',
        '12.11111',
    ]
    data = load_example_listing("G7-SCS")

    def check_min_price_valid(field, case):
        data[field] = case
        errs = get_validation_errors("services-g-cloud-7-scs", data)
        assert "not_money_format" not in errs.get(field, "")

    yield check_min_price_valid, 'priceMax', ""

    for case in cases:
        yield check_min_price_valid, 'priceMin', case
        yield check_min_price_valid, 'priceMax', case
def test_price_not_money_format_valid_cases():
    cases = [
        '12',
        '12.1',
        '12.11',
        '12.111',
        '12.1111',
        '12.11111',
    ]
    data = load_example_listing("G7-SCS")

    def check_min_price_valid(field, case):
        data[field] = case
        errs = get_validation_errors("services-g-cloud-7-scs", data)
        assert "not_money_format" not in errs.get(field, "")

    check_min_price_valid('priceMax', "")

    for case in cases:
        check_min_price_valid('priceMin', case)
        check_min_price_valid('priceMax', case)
예제 #19
0
def test_invalid_enum_values_has_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'minimumContractPeriod': 'Fortnight'})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "'Fortnight' is not one of" in errs['minimumContractPeriod']
def test_g7_missing_required_field_has_validation_error():
    data = load_example_listing("G7-SCS")
    data.pop("serviceSummary", None)
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "answer_required" in errs['serviceSummary']
def test_string_too_long_causes_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceName': "a" * 101})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "under_character_limit" in errs['serviceName']
def test_new_supplier_fails_with_bad_duns(duns):
    data = load_example_listing("new-supplier")
    data["dunsNumber"] = duns
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) == 1
def test_valid_g7_service_has_no_validation_errors():
    data = load_example_listing("G7-SCS")
    data = drop_api_exported_fields_so_that_api_import_will_validate(data)
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert not errs
예제 #24
0
def test_too_many_words_causes_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceBenefits': ['more than ten words 5 6 7 8 9 10 11']})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "under_10_words" in errs['serviceBenefits']
def test_supplier_validates_with_no_companies_house_number():
    data = load_example_listing("supplier_creation")
    data.pop("companiesHouseNumber", None)
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) == 0
def test_invalid_enum_values_has_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'minimumContractPeriod': 'Fortnight'})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "'Fortnight' is not one of" in errs['minimumContractPeriod']
def test_invalid_url_field_has_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceDefinitionDocumentURL': 'not_a_url'})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert errs['serviceDefinitionDocumentURL'] == 'invalid_format'
def test_value_only_causes_validation_error():
    data = load_example_listing("G6-PaaS")
    data.update({'serviceAvailabilityPercentage': {"value": 99.9}})
    errs = get_validation_errors("services-g-cloud-7-paas", data)
    assert "assurance_required" in errs['serviceAvailabilityPercentage']
def test_non_number_value_causes_validation_error():
    data = load_example_listing("G6-PaaS")
    data.update({'serviceAvailabilityPercentage': {"value": "a99.9", "assurance": "Service provider assertion"}})
    errs = get_validation_errors("services-g-cloud-7-paas", data)
    assert "not_a_number" in errs['serviceAvailabilityPercentage']
def test_supplier_fails_with_bad_companies_house_number():
    data = load_example_listing("supplier_creation")
    data["companiesHouseNumber"] = "short"
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) == 1
예제 #31
0
def test_invalid_url_field_has_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceDefinitionDocumentURL': 'not_a_url'})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert errs['serviceDefinitionDocumentURL'] == 'invalid_format'
예제 #32
0
def test_supplier_fails_with_bad_companies_house_number():
    data = load_example_listing("supplier_creation")
    data["companiesHouseNumber"] = "short"
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) is 1
def test_api_type_is_optional():
    data = load_example_listing("G6-PaaS")
    del data["apiType"]
    errs = get_validation_errors("services-g-cloud-7-paas", data)

    assert not errs.get('apiType', None)
예제 #34
0
def test_string_too_long_causes_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceName': "a" * 101})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "under_character_limit" in errs['serviceName']
예제 #35
0
def test_supplier_validates():
    data = load_example_listing("supplier_creation")
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) is 0
def test_supplier_validates():
    data = load_example_listing("supplier_creation")
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) == 0
예제 #37
0
def test_supplier_validates_with_no_companies_house_number():
    data = load_example_listing("supplier_creation")
    data.pop("companiesHouseNumber", None)
    errs = get_validation_errors("new-supplier", data)
    assert len(errs) is 0
예제 #38
0
def test_valid_g7_service_has_no_validation_errors():
    data = load_example_listing("G7-SCS")
    data = drop_api_exported_fields_so_that_api_import_will_validate(data)
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert not errs
예제 #39
0
def test_g7_missing_required_field_has_validation_error():
    data = load_example_listing("G7-SCS")
    data.pop("serviceSummary", None)
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "answer_required" in errs['serviceSummary']
예제 #40
0
def test_api_type_is_optional():
    data = load_example_listing("G6-PaaS")
    del data["apiType"]
    errs = get_validation_errors("services-g-cloud-7-paas", data)

    assert not errs.get('apiType', None)
def test_too_many_words_causes_validation_error():
    data = load_example_listing("G7-SCS")
    data.update({'serviceBenefits': ['more than ten words 5 6 7 8 9 10 11']})
    errs = get_validation_errors("services-g-cloud-7-scs", data)
    assert "under_10_words" in errs['serviceBenefits']