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

Library update 15/07/24 / Fix unit test typing #3103

Merged
merged 1 commit into from
Jul 15, 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
10 changes: 5 additions & 5 deletions aries_cloudagent/indy/models/tests/test_cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TestIndyKeyCorrectnessProof(TestCase):
def test_serde(self):
"""Test de/serialization."""
kcp = IndyKeyCorrectnessProof.deserialize(KC_PROOF)
assert type(kcp) == IndyKeyCorrectnessProof
assert type(kcp) is IndyKeyCorrectnessProof

kcp_dict = kcp.serialize()
assert kcp_dict == KC_PROOF
Expand All @@ -54,7 +54,7 @@ def test_serde(self):
"key_correctness_proof": KC_PROOF,
}
cred_abstract = IndyCredAbstract.deserialize(obj)
assert type(cred_abstract) == IndyCredAbstract
assert type(cred_abstract) is IndyCredAbstract

cred_abstract_dict = cred_abstract.serialize()
assert cred_abstract_dict == obj
Expand All @@ -73,7 +73,7 @@ def test_serde(self):
"nonce": "1234567890",
}
cred_request = IndyCredRequest.deserialize(obj)
assert type(cred_request) == IndyCredRequest
assert type(cred_request) is IndyCredRequest

cred_request_dict = cred_request.serialize()
assert cred_request_dict == obj
Expand All @@ -89,7 +89,7 @@ def test_serde(self):
"encoded": "1234567890",
}
attr_val = IndyAttrValue.deserialize(obj)
assert type(attr_val) == IndyAttrValue
assert type(attr_val) is IndyAttrValue

attr_val_dict = attr_val.serialize()
assert attr_val_dict == obj
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_serde(self):
"witness": None,
}
cred = IndyCredential.deserialize(obj)
assert type(cred) == IndyCredential
assert type(cred) is IndyCredential

cred_dict = cred.serialize()
assert cred_dict.items() <= obj.items()
2 changes: 1 addition & 1 deletion aries_cloudagent/indy/models/tests/test_cred_precis.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TestCredInfo(TestCase):
def test_serde(self):
"""Test de/serialization."""
cred_info = IndyCredInfo.deserialize(CRED_INFO)
assert type(cred_info) == IndyCredInfo
assert type(cred_info) is IndyCredInfo

ser = cred_info.serialize()
assert ser == CRED_INFO
Expand Down
40 changes: 19 additions & 21 deletions aries_cloudagent/indy/models/tests/test_pres_preview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import pytest

from copy import deepcopy
from time import time
from unittest import TestCase

import pytest

from aries_cloudagent.tests import mock

from ....core.in_memory import InMemoryProfile
Expand All @@ -15,15 +15,13 @@
from ....multitenant.base import BaseMultitenantManager
from ....multitenant.manager import MultitenantManager
from ....protocols.didcomm_prefix import DIDCommPrefix


from ..non_rev_interval import IndyNonRevocationInterval
from ..predicate import Predicate
from ..pres_preview import (
PRESENTATION_PREVIEW,
IndyPresAttrSpec,
IndyPresPredSpec,
IndyPresPreview,
PRESENTATION_PREVIEW,
)

S_ID = {
Expand Down Expand Up @@ -251,7 +249,7 @@ def test_deserialize(self):
)

attr_spec = IndyPresAttrSpec.deserialize(dump)
assert type(attr_spec) == IndyPresAttrSpec
assert type(attr_spec) is IndyPresAttrSpec
assert canon(attr_spec.name) == "player"

dump = json.dumps(
Expand All @@ -264,7 +262,7 @@ def test_deserialize(self):
)

attr_spec = IndyPresAttrSpec.deserialize(dump)
assert type(attr_spec) == IndyPresAttrSpec
assert type(attr_spec) is IndyPresAttrSpec
assert canon(attr_spec.name) == "player"

def test_serialize(self):
Expand Down Expand Up @@ -301,7 +299,7 @@ def test_deserialize(self):
)

pred_spec = IndyPresPredSpec.deserialize(dump)
assert type(pred_spec) == IndyPresPredSpec
assert type(pred_spec) is IndyPresPredSpec
assert canon(pred_spec.name) == "highscore"

def test_serialize(self):
Expand Down Expand Up @@ -418,14 +416,14 @@ async def test_to_indy_proof_request_revo_default_interval(self):

for uuid, attr_spec in indy_proof_req_revo["requested_attributes"].items():
assert set(attr_spec.get("non_revoked", {}).keys()) == {"from", "to"}
copy_indy_proof_req["requested_attributes"][uuid]["non_revoked"] = (
attr_spec["non_revoked"]
)
copy_indy_proof_req["requested_attributes"][uuid]["non_revoked"] = attr_spec[
"non_revoked"
]
for uuid, pred_spec in indy_proof_req_revo["requested_predicates"].items():
assert set(pred_spec.get("non_revoked", {}).keys()) == {"from", "to"}
copy_indy_proof_req["requested_predicates"][uuid]["non_revoked"] = (
pred_spec["non_revoked"]
)
copy_indy_proof_req["requested_predicates"][uuid]["non_revoked"] = pred_spec[
"non_revoked"
]

assert copy_indy_proof_req == indy_proof_req_revo

Expand Down Expand Up @@ -469,14 +467,14 @@ async def test_to_indy_proof_request_revo(self):

for uuid, attr_spec in indy_proof_req_revo["requested_attributes"].items():
assert set(attr_spec.get("non_revoked", {}).keys()) == {"from", "to"}
copy_indy_proof_req["requested_attributes"][uuid]["non_revoked"] = (
attr_spec["non_revoked"]
)
copy_indy_proof_req["requested_attributes"][uuid]["non_revoked"] = attr_spec[
"non_revoked"
]
for uuid, pred_spec in indy_proof_req_revo["requested_predicates"].items():
assert set(pred_spec.get("non_revoked", {}).keys()) == {"from", "to"}
copy_indy_proof_req["requested_predicates"][uuid]["non_revoked"] = (
pred_spec["non_revoked"]
)
copy_indy_proof_req["requested_predicates"][uuid]["non_revoked"] = pred_spec[
"non_revoked"
]

assert copy_indy_proof_req == indy_proof_req_revo

Expand Down Expand Up @@ -544,7 +542,7 @@ def test_deserialize(self):
}

preview = IndyPresPreview.deserialize(dump)
assert type(preview) == IndyPresPreview
assert type(preview) is IndyPresPreview

def test_serialize(self):
"""Test serialization."""
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/indy/models/tests/test_proof.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class TestIndyProof(TestCase):
def test_serde(self):
"""Test de/serialization."""
proof = IndyProof.deserialize(INDY_PROOF)
assert type(proof) == IndyProof
assert type(proof) is IndyProof

proof_dict = proof.serialize()
assert proof_dict == INDY_PROOF
2 changes: 1 addition & 1 deletion aries_cloudagent/indy/models/tests/test_proof_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_serde(self):
"""Test de/serialization."""

proof_req = IndyProofRequest.deserialize(PROOF_REQ)
assert type(proof_req) == IndyProofRequest
assert type(proof_req) is IndyProofRequest

ser = proof_req.serialize()
assert ser == PROOF_REQ
Expand Down
4 changes: 2 additions & 2 deletions aries_cloudagent/messaging/decorators/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class TestBaseDecoratorSet(TestCase):
def test_base_decorator_set(self):
MODELS = {"a": SampleDecorator}
deco_set = BaseDecoratorSet(MODELS)
assert type(deco_set) == BaseDecoratorSet
assert type(deco_set) is BaseDecoratorSet
assert not deco_set.fields
assert deco_set.models == MODELS
assert deco_set.prefix == DECORATOR_PREFIX
assert BaseDecoratorSet.__name__ in str(deco_set)

deco_set_copy = deco_set.copy()
assert type(deco_set_copy) == BaseDecoratorSet
assert type(deco_set_copy) is BaseDecoratorSet
assert deco_set_copy == deco_set
assert not deco_set_copy.fields
assert deco_set_copy.models == MODELS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,49 @@

from ..please_ack_decorator import PleaseAckDecorator


MESSAGE_ID = "abc123"
ON = ("RECEIPT", "OUTCOME")


class TestPleaseAckDecorator(TestCase):
def test_init_serde(self):
decorator = PleaseAckDecorator()
assert type(decorator) == PleaseAckDecorator
assert type(decorator) is PleaseAckDecorator
assert decorator.message_id is None
assert decorator.on is None
dumped = decorator.serialize()
assert dumped == {}
loaded = PleaseAckDecorator.deserialize(dumped)
assert type(loaded) == PleaseAckDecorator
assert type(loaded) is PleaseAckDecorator
assert loaded.message_id is None
assert loaded.on is None

decorator = PleaseAckDecorator(message_id=MESSAGE_ID)
assert type(decorator) == PleaseAckDecorator
assert type(decorator) is PleaseAckDecorator
assert decorator.message_id == MESSAGE_ID
assert decorator.on is None
dumped = decorator.serialize()
assert dumped == {"message_id": MESSAGE_ID}
loaded = PleaseAckDecorator.deserialize(dumped)
assert type(loaded) == PleaseAckDecorator
assert type(loaded) is PleaseAckDecorator
assert loaded.message_id == MESSAGE_ID
assert loaded.on is None

decorator = PleaseAckDecorator(on=ON)
assert type(decorator) == PleaseAckDecorator
assert type(decorator) is PleaseAckDecorator
assert decorator.message_id is None
assert decorator.on == list(ON)
dumped = decorator.serialize()
assert dumped == {
"on": list(ON),
}
loaded = PleaseAckDecorator.deserialize(dumped)
assert type(loaded) == PleaseAckDecorator
assert type(loaded) is PleaseAckDecorator
assert loaded.message_id is None
assert loaded.on == list(ON)

decorator = PleaseAckDecorator(message_id=MESSAGE_ID, on=ON)
assert type(decorator) == PleaseAckDecorator
assert type(decorator) is PleaseAckDecorator
assert decorator.message_id == MESSAGE_ID
assert decorator.on == list(ON)
dumped = decorator.serialize()
Expand All @@ -54,6 +53,6 @@ def test_init_serde(self):
"on": list(ON),
}
loaded = PleaseAckDecorator.deserialize(dumped)
assert type(loaded) == PleaseAckDecorator
assert type(loaded) is PleaseAckDecorator
assert loaded.message_id == MESSAGE_ID
assert loaded.on == list(ON)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import IsolatedAsyncioTestCase

from aries_cloudagent.tests import mock

from ......connections.models.conn_record import ConnRecord
Expand All @@ -8,9 +9,7 @@
from ......protocols.connections.v1_0.messages.connection_invitation import (
ConnectionInvitation,
)

from ...messages.forward_invitation import ForwardInvitation

from .. import forward_invitation_handler as test_module

TEST_DID = "55GkHamhTU1ZbTbV2ab9DE"
Expand Down Expand Up @@ -67,7 +66,7 @@ async def test_handle_x(self):
messages = responder.messages
assert len(messages) == 1
(result, _) = messages[0]
assert type(result) == test_module.ProblemReport
assert type(result) is test_module.ProblemReport

async def test_handle_not_ready(self):
handler = test_module.ForwardInvitationHandler()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import IsolatedAsyncioTestCase

from aries_cloudagent.tests import mock

from ......messaging.base_handler import HandlerException
Expand All @@ -7,10 +8,8 @@
from ......protocols.connections.v1_0.messages.connection_invitation import (
ConnectionInvitation,
)

from ...messages.invitation import Invitation
from ...messages.invitation_request import InvitationRequest

from .. import invitation_request_handler as test_module

TEST_DID = "55GkHamhTU1ZbTbV2ab9DE"
Expand Down Expand Up @@ -70,7 +69,7 @@ async def test_handle_auto_accept(self):
messages = responder.messages
assert len(messages) == 1
(result, _) = messages[0]
assert type(result) == Invitation
assert type(result) is Invitation
assert result._thread._thid == self.context.message._message_id

async def test_handle_not_ready(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from unittest import TestCase

from ......didcomm_prefix import DIDCommPrefix

from ....message_types import CREDENTIAL_PREVIEW

from ..credential_preview import (
CredAttrSpec,
CredentialPreview,
Expand Down Expand Up @@ -82,7 +80,7 @@ def test_deserialize(self):
}

cred_preview = CredentialPreview.deserialize(obj)
assert type(cred_preview) == CredentialPreview
assert type(cred_preview) is CredentialPreview

def test_serialize(self):
"""Test serialization."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from unittest import TestCase

from .....didcomm_prefix import DIDCommPrefix

from ...message_types import CREDENTIAL_PREVIEW, CREDENTIAL_PROPOSAL

from ..credential_proposal import CredentialProposal
from ..inner.credential_preview import CredAttrSpec, CredentialPreview


CRED_PREVIEW = CredentialPreview(
attributes=(
CredAttrSpec.list_plain({"test": "123", "hello": "world"})
Expand Down Expand Up @@ -58,7 +55,7 @@ def test_deserialize(self):
}

cred_proposal = CredentialProposal.deserialize(obj)
assert type(cred_proposal) == CredentialProposal
assert type(cred_proposal) is CredentialProposal

def test_serialize(self):
"""Test serialization."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TestLDProofVCDetail(TestCase):
def test_serde(self):
"""Test de/serialization."""
detail = LDProofVCDetail.deserialize(VC_DETAIL)
assert type(detail) == LDProofVCDetail
assert type(detail) is LDProofVCDetail

detail_dict = detail.serialize()
assert detail_dict == VC_DETAIL
Expand All @@ -63,7 +63,7 @@ class TestLDProofVCDetailOptions(TestCase):
def test_serde(self):
"""Test de/serialization."""
detail_options = LDProofVCDetailOptions.deserialize(VC_DETAIL_OPTIONS)
assert type(detail_options) == LDProofVCDetailOptions
assert type(detail_options) is LDProofVCDetailOptions

detail_options_dict = detail_options.serialize()
assert detail_options_dict == VC_DETAIL_OPTIONS
Loading
Loading