Example #1
0
def test_get_schema_deprecated_paths():
    schema_obj = SchemaOCDS()
    schema_obj.schema_host = os.path.join('cove_ocds', 'fixtures/')
    schema_obj.release_pkg_schema_name = 'release_package_schema_ref_release_schema_deprecated_fields.json'
    schema_obj.release_pkg_schema_url = os.path.join(schema_obj.schema_host, schema_obj.release_pkg_schema_name)
    deprecated_paths = cove_common._get_schema_deprecated_paths(schema_obj)
    expected_results = [
        (('releases', 'initiationType'), ('1.1', 'Not a useful field as always has to be tender')),
        (('releases', 'planning',), ('1.1', "Testing deprecation for objects with '$ref'")),
        (('releases', 'tender', 'hasEnquiries'), ('1.1', 'Deprecated just for fun')),
        (('releases', 'contracts', 'items', 'quantity'), ('1.1', 'Nobody cares about quantities')),
        (('releases', 'tender', 'items', 'quantity'), ('1.1', 'Nobody cares about quantities')),
        (('releases', 'awards', 'items', 'quantity'), ('1.1', 'Nobody cares about quantities'))
    ]
    assert len(deprecated_paths) == 6
    for path in expected_results:
        assert path in deprecated_paths
Example #2
0
def test_get_schema_deprecated_paths():
    schema_obj = SchemaOCDS()
    schema_obj.schema_host = os.path.join('cove_ocds', 'fixtures/')
    schema_obj.release_pkg_schema_name = 'release_package_schema_ref_release_schema_deprecated_fields.json'
    schema_obj.release_pkg_schema_url = os.path.join(schema_obj.schema_host, schema_obj.release_pkg_schema_name)
    deprecated_paths = cove_common._get_schema_deprecated_paths(schema_obj)
    expected_results = [
        (('releases', 'initiationType'), ('1.1', 'Not a useful field as always has to be tender')),
        (('releases', 'planning',), ('1.1', "Testing deprecation for objects with '$ref'")),
        (('releases', 'tender', 'hasEnquiries'), ('1.1', 'Deprecated just for fun')),
        (('releases', 'contracts', 'items', 'quantity'), ('1.1', 'Nobody cares about quantities')),
        (('releases', 'tender', 'items', 'quantity'), ('1.1', 'Nobody cares about quantities')),
        (('releases', 'awards', 'items', 'quantity'), ('1.1', 'Nobody cares about quantities'))
    ]
    assert len(deprecated_paths) == 6
    for path in expected_results:
        assert path in deprecated_paths
def test_get_json_data_deprecated_fields():
    with open(
            os.path.join(
                "tests",
                "fixtures",
                "tenders_releases_2_releases_with_deprecated_fields.json",
            )) as fp:
        json_data_w_deprecations = json.load(fp)

    schema_obj = SchemaOCDS()
    schema_obj.schema_host = os.path.join(
        "tests", "fixtures/")  # "/" is for urljoin in lib-cove
    schema_obj.pkg_schema_name = (
        "release_package_schema_ref_release_schema_deprecated_fields.json")
    schema_obj.pkg_schema_url = os.path.join(schema_obj.schema_host,
                                             schema_obj.pkg_schema_name)
    json_data_paths = cove_common.get_json_data_generic_paths(
        json_data_w_deprecations, generic_paths={})
    deprecated_data_fields = cove_common.get_json_data_deprecated_fields(
        json_data_paths, schema_obj)
    expected_result = OrderedDict([
        (
            "initiationType",
            {
                "paths": ("releases/0", "releases/1"),
                "explanation": (
                    "1.1",
                    "Not a useful field as always has to be tender",
                ),
            },
        ),
        (
            "quantity",
            {
                "paths": ("releases/0/tender/items/0", ),
                "explanation": ("1.1", "Nobody cares about quantities"),
            },
        ),
    ])
    for field_name in expected_result.keys():
        assert field_name in deprecated_data_fields
        assert (expected_result[field_name]["paths"] ==
                deprecated_data_fields[field_name]["paths"])
        assert (expected_result[field_name]["explanation"] ==
                deprecated_data_fields[field_name]["explanation"])
Example #4
0
def test_get_json_data_deprecated_fields():
    with open(os.path.join('cove', 'fixtures', 'tenders_releases_2_releases_with_deprecated_fields.json')) as fp:
        json_data_w_deprecations = json.load(fp)

    schema_obj = SchemaOCDS()
    schema_obj.schema_host = os.path.join('cove_ocds', 'fixtures/')
    schema_obj.release_pkg_schema_name = 'release_package_schema_ref_release_schema_deprecated_fields.json'
    schema_obj.release_pkg_schema_url = os.path.join(schema_obj.schema_host, schema_obj.release_pkg_schema_name)
    json_data_paths = cove_common.get_json_data_generic_paths(json_data_w_deprecations)
    deprecated_data_fields = cove_common.get_json_data_deprecated_fields(json_data_paths, schema_obj)
    expected_result = OrderedDict([
        ('initiationType', {"paths": ('releases/0', 'releases/1'),
                            "explanation": ('1.1', 'Not a useful field as always has to be tender')}),
        ('quantity', {"paths": ('releases/0/tender/items/0',),
                      "explanation": ('1.1', 'Nobody cares about quantities')})
    ])
    for field_name in expected_result.keys():
        assert field_name in deprecated_data_fields
        assert expected_result[field_name]["paths"] == deprecated_data_fields[field_name]["paths"]
        assert expected_result[field_name]["explanation"] == deprecated_data_fields[field_name]["explanation"]
Example #5
0
def test_get_json_data_deprecated_fields():
    with open(os.path.join('cove_ocds', 'fixtures', 'tenders_releases_2_releases_with_deprecated_fields.json')) as fp:
        json_data_w_deprecations = json.load(fp)

    schema_obj = SchemaOCDS()
    schema_obj.schema_host = os.path.join('cove_ocds', 'fixtures/')
    schema_obj.release_pkg_schema_name = 'release_package_schema_ref_release_schema_deprecated_fields.json'
    schema_obj.release_pkg_schema_url = os.path.join(schema_obj.schema_host, schema_obj.release_pkg_schema_name)
    json_data_paths = cove_common.get_json_data_generic_paths(json_data_w_deprecations)
    deprecated_data_fields = cove_common.get_json_data_deprecated_fields(json_data_paths, schema_obj)
    expected_result = OrderedDict([
        ('initiationType', {"paths": ('releases/0', 'releases/1'),
                            "explanation": ('1.1', 'Not a useful field as always has to be tender')}),
        ('quantity', {"paths": ('releases/0/tender/items/0',),
                      "explanation": ('1.1', 'Nobody cares about quantities')})
    ])
    for field_name in expected_result.keys():
        assert field_name in deprecated_data_fields
        assert expected_result[field_name]["paths"] == deprecated_data_fields[field_name]["paths"]
        assert expected_result[field_name]["explanation"] == deprecated_data_fields[field_name]["explanation"]
def test_get_schema_deprecated_paths():
    schema_obj = SchemaOCDS()
    schema_obj.schema_host = os.path.join(
        "tests", "fixtures/")  # "/" is for urljoin in lib-cove
    schema_obj.pkg_schema_name = (
        "release_package_schema_ref_release_schema_deprecated_fields.json")
    schema_obj.pkg_schema_url = os.path.join(schema_obj.schema_host,
                                             schema_obj.pkg_schema_name)
    deprecated_paths = cove_common._get_schema_deprecated_paths(schema_obj)
    expected_results = [
        (
            ("releases", "initiationType"),
            ("1.1", "Not a useful field as always has to be tender"),
        ),
        (
            (
                "releases",
                "planning",
            ),
            ("1.1", "Testing deprecation for objects with '$ref'"),
        ),
        (("releases", "tender", "hasEnquiries"), ("1.1",
                                                  "Deprecated just for fun")),
        (
            ("releases", "contracts", "items", "quantity"),
            ("1.1", "Nobody cares about quantities"),
        ),
        (
            ("releases", "tender", "items", "quantity"),
            ("1.1", "Nobody cares about quantities"),
        ),
        (
            ("releases", "awards", "items", "quantity"),
            ("1.1", "Nobody cares about quantities"),
        ),
    ]
    assert len(deprecated_paths) == 6
    for path in expected_results:
        assert path in deprecated_paths