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

Add more test data #321

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pygleif/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down
142 changes: 142 additions & 0 deletions tests/fixtures/549300LBI3LRIZ2V8V66_lapsed.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
25 changes: 17 additions & 8 deletions tests/test_gleif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading