Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: RefResolver should not return before calling add_is_codelist #130

Closed
jpmckinney opened this issue Jul 11, 2023 · 2 comments
Closed

Comments

@jpmckinney
Copy link
Contributor

Bug introduced in 011a2bd

lib-cove/libcove/lib/common.py

Lines 1222 to 1231 in a97f769

if self.cache_remote:
self.store[uri] = result
return result
else:
with open(uri) as schema_file:
result = json.load(schema_file)
add_is_codelist(result)
self.store[uri] = result
return result

@jpmckinney
Copy link
Contributor Author

jpmckinney commented Oct 11, 2023

Once fixed, can use test data at open-contracting/lib-cove-ocds#115 (comment)

Here's something I wrote before realizing it was for the wrong issue. (get_schema_obj() is defined in #131

The fixtures should probably be changed to match the test data at the above issue (i.e. "tag": ["bad"] without a "tender" object for the last two parametrizations). The assertion has not yet been developed.

The code in #123 includes a fix for this issue.

@pytest.mark.parametrize(
    "data_type,json_data",
    [
        (
            "release",
            {
                "version": "1.1",
                "publisher": {"name": ""},
                "publishedDate": "2000-01-01T00:00:00Z",
                "uri": "https://",
                "releases": [
                    {
                        "ocid": "ocds-213czf-1",
                        "id": "1",
                        "date": "2000-01-01T00:00:00Z",
                        "tag": ["tender"],
                        "initiationType": "tender",
                        "tender": {"id": "1", "procurementMethod": "bad"},
                    }
                ],
            },
        ),
        (
            "record",
            {
                "version": "1.1",
                "publisher": {"name": ""},
                "publishedDate": "2000-01-01T00:00:00Z",
                "uri": "https://",
                "records": [
                    {
                        "ocid": "ocds-213czf-1",
                        "releases": [
                            {
                                "ocid": "ocds-213czf-1",
                                "id": "1",
                                "date": "2000-01-01T00:00:00Z",
                                "tag": ["tender"],
                                "initiationType": "tender",
                                "tender": {"id": "1", "procurementMethod": "bad"},
                            }
                        ]
                    }
                ],
            },
        ),
        (
            "release",
            {
                "version": "1.1",
                "publisher": {"name": ""},
                "publishedDate": "2000-01-01T00:00:00Z",
                "uri": "https://",
                "releases": [
                    {
                        "ocid": "ocds-213czf-1",
                        "id": "1",
                        "date": "2000-01-01T00:00:00Z",
                        "tag": ["tender"],
                        "initiationType": "tender",
                        "tender": {"id": "1", "procurementMethod": "bad"},
                    }
                ],
            },
        ),
        (
            "record",
            {
                "version": "1.1",
                "publisher": {"name": ""},
                "publishedDate": "2000-01-01T00:00:00Z",
                "uri": "https://",
                "records": [
                    {
                        "ocid": "ocds-213czf-1",
                        "releases": [
                            {
                                "ocid": "ocds-213czf-1",
                                "id": "1",
                                "date": "2000-01-01T00:00:00Z",
                                "tag": ["tender"],
                                "initiationType": "tender",
                                "tender": {"id": "1", "procurementMethod": "bad"},
                            }
                        ]
                    }
                ],
            },
        ),
    ],
)
def test_iscodelist(data_type, json_data, tmpdir):
    schema_obj = get_schema_obj(f"{data_type}-package-schema")
    schema_obj.codelists = "https://raw.githubusercontent.com/open-contracting/standard/1.1/schema/codelists/"
    context = {"file_type": "json"}
    common_checks_context(tmpdir, json_data, schema_obj, "", context)

    assert context == {}

@jpmckinney jpmckinney changed the title RefResolver should not return before calling add_is_codelist BUG: RefResolver should not return before calling add_is_codelist Oct 11, 2023
@jpmckinney
Copy link
Contributor Author

Closed by #142 (adapts #123).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant