From 1f036e51b375d022076292a7626d2086ab646394 Mon Sep 17 00:00:00 2001 From: Patrik <21142447+ggravlingen@users.noreply.github.com> Date: Sat, 6 Jul 2024 19:33:31 +0000 Subject: [PATCH] Add more test data --- pygleif/api/data.py | 6 +- .../fixtures/549300LBI3LRIZ2V8V66_lapsed.json | 142 ++++++++++++++++++ ....json => 9845001B2AD43E664E58_issued.json} | 0 tests/test_gleif.py | 25 ++- 4 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 tests/fixtures/549300LBI3LRIZ2V8V66_lapsed.json rename tests/fixtures/{9845001B2AD43E664E58.json => 9845001B2AD43E664E58_issued.json} (100%) diff --git a/pygleif/api/data.py b/pygleif/api/data.py index 8fc8330..40ec4b8 100644 --- a/pygleif/api/data.py +++ b/pygleif/api/data.py @@ -23,7 +23,7 @@ class Registration(BaseSchema): next_renewal_date: datetime other_validation_authorities: list[Any] status: str - validated_as: str + validated_as: str | None = None validated_at: ValidatedAt @@ -92,11 +92,11 @@ class Entity(BaseSchema): legal_name: Name other_addresses: list[Any] other_names: list[Name] - registered_as: str + registered_as: str | None = None registered_at: RegisteredAt status: str successor_entities: list[Any] - sub_category: str | None + sub_category: str | None | None = None successor_entity: GeneralEntity transliteraded_other_names: list[Any] | None = None diff --git a/tests/fixtures/549300LBI3LRIZ2V8V66_lapsed.json b/tests/fixtures/549300LBI3LRIZ2V8V66_lapsed.json new file mode 100644 index 0000000..1c29af3 --- /dev/null +++ b/tests/fixtures/549300LBI3LRIZ2V8V66_lapsed.json @@ -0,0 +1,142 @@ +{ + "meta":{ + "goldenCopy":{ + "publishDate":"2024-07-06T08:00:00Z" + } + }, + "data":{ + "type":"lei-records", + "id":"549300LBI3LRIZ2V8V66", + "attributes":{ + "lei":"549300LBI3LRIZ2V8V66", + "entity":{ + "legalName":{ + "name":"UK EQUITY FUND (OFFSHORE)", + "language":"en" + }, + "otherNames":[ + + ], + "transliteratedOtherNames":[ + + ], + "legalAddress":{ + "language":"en", + "addressLines":[ + "JP MORGAN HOUSE", + "DUBLIN 1" + ], + "addressNumber":null, + "addressNumberWithinBuilding":null, + "mailRouting":null, + "city":"DUBLIN", + "region":"IE-D", + "country":"IE", + "postalCode":"D01 W213" + }, + "headquartersAddress":{ + "language":"en", + "addressLines":[ + "JP MORGAN HOUSE", + "DUBLIN 1" + ], + "addressNumber":null, + "addressNumberWithinBuilding":null, + "mailRouting":null, + "city":"DUBLIN", + "region":"IE-D", + "country":"IE", + "postalCode":"D01 W213" + }, + "registeredAt":{ + "id":"RA999999", + "other":null + }, + "registeredAs":null, + "jurisdiction":"IE", + "category":"FUND", + "legalForm":{ + "id":"8888", + "other":"FUND" + }, + "associatedEntity":{ + "lei":null, + "name":null + }, + "status":"ACTIVE", + "expiration":{ + "date":null, + "reason":null + }, + "successorEntity":{ + "lei":null, + "name":null + }, + "successorEntities":[ + + ], + "creationDate":null, + "subCategory":null, + "otherAddresses":[ + + ], + "eventGroups":[ + + ] + }, + "registration":{ + "initialRegistrationDate":"2013-11-05T03:03:00Z", + "lastUpdateDate":"2023-07-31T17:11:36Z", + "status":"LAPSED", + "nextRenewalDate":"2014-11-01T10:44:00Z", + "managingLou":"213800WAVVOPS85N2205", + "corroborationLevel":"ENTITY_SUPPLIED_ONLY", + "validatedAt":{ + "id":"RA999999", + "other":null + }, + "validatedAs":null, + "otherValidationAuthorities":[ + + ] + }, + "bic":null, + "mic":null, + "ocid":null, + "spglobal":[ + "288226009" + ], + "conformityFlag":"NON_CONFORMING" + }, + "relationships":{ + "managing-lou":{ + "links":{ + "related":"https:\/\/api.gleif.org\/api\/v1\/lei-records\/549300LBI3LRIZ2V8V66\/managing-lou" + } + }, + "lei-issuer":{ + "links":{ + "related":"https:\/\/api.gleif.org\/api\/v1\/lei-records\/549300LBI3LRIZ2V8V66\/lei-issuer" + } + }, + "field-modifications":{ + "links":{ + "related":"https:\/\/api.gleif.org\/api\/v1\/lei-records\/549300LBI3LRIZ2V8V66\/field-modifications" + } + }, + "direct-parent":{ + "links":{ + "reporting-exception":"https:\/\/api.gleif.org\/api\/v1\/lei-records\/549300LBI3LRIZ2V8V66\/direct-parent-reporting-exception" + } + }, + "ultimate-parent":{ + "links":{ + "reporting-exception":"https:\/\/api.gleif.org\/api\/v1\/lei-records\/549300LBI3LRIZ2V8V66\/ultimate-parent-reporting-exception" + } + } + }, + "links":{ + "self":"https:\/\/api.gleif.org\/api\/v1\/lei-records\/549300LBI3LRIZ2V8V66" + } + } + } \ No newline at end of file diff --git a/tests/fixtures/9845001B2AD43E664E58.json b/tests/fixtures/9845001B2AD43E664E58_issued.json similarity index 100% rename from tests/fixtures/9845001B2AD43E664E58.json rename to tests/fixtures/9845001B2AD43E664E58_issued.json diff --git a/tests/test_gleif.py b/tests/test_gleif.py index 6021ea6..7020bec 100644 --- a/tests/test_gleif.py +++ b/tests/test_gleif.py @@ -16,16 +16,25 @@ def load_mock_data(file_name: str) -> dict[Any, Any]: @pytest.fixture -def fixture_response_a() -> Generator[Any, Any, Any]: +def fixture_response(request) -> Generator[Any, Any, Any]: """Mock data for the security service endpoint.""" with patch( "pygleif.gleif.load_json", ) as mock_response: - mock_response.return_value = load_mock_data("9845001B2AD43E664E58") - yield - - -def test_pygleif(fixture_response_a) -> None: + mock_response.return_value = load_mock_data(request.param) + yield request.param + + +@pytest.mark.parametrize( + "fixture_response", + [ + "9845001B2AD43E664E58_issued", + "549300LBI3LRIZ2V8V66_lapsed" + ], + indirect=True, +) +def test_pygleif(fixture_response) -> None: """Test Pygleif-class.""" - data = PyGleif("9845001B2AD43E664E58") - assert data.response.data.attributes.lei == "9845001B2AD43E664E58" + lei = fixture_response.split("_")[0] + data = PyGleif(lei) + assert data.response.data.attributes.lei == lei