-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec5cd72
commit a5129d1
Showing
10 changed files
with
119 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from mex.common.identity.base import BaseProvider | ||
from mex.common.identity.dummy import DummyIdentityProvider | ||
from mex.common.identity.models import Identity | ||
from mex.common.identity.types import IdentityProvider | ||
from mex.common.identity.query import assign_identity,fetch_identity | ||
|
||
__all__ = ( | ||
"assign_identity", | ||
"BaseProvider", | ||
"DummyIdentityProvider", | ||
"fetch_identity", | ||
"Identity", | ||
"IdentityProvider", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import pytest | ||
from pytest import MonkeyPatch | ||
|
||
from mex.common.exceptions import MExError | ||
from mex.common.identity import assign_identity, fetch_identity,DummyIdentityProvider | ||
from mex.common.settings import BaseSettings | ||
from mex.common.testing import Joker | ||
from mex.common.types import Identifier,PrimarySourceID | ||
|
||
|
||
def test_assign_identity() -> None: | ||
had_primary_source = PrimarySourceID("0000000000") | ||
identifier_in_primary_source = "thing-1" | ||
|
||
new_identity = assign_identity( had_primary_source, identifier_in_primary_source ) | ||
|
||
assert new_identity.dict() == dict( | ||
hadPrimarySource=had_primary_source, | ||
identifierInPrimarySource=identifier_in_primary_source, | ||
stableTargetId=Joker(), | ||
identifier=Joker(), | ||
) | ||
|
||
found_identity = assign_identity(had_primary_source, identifier_in_primary_source) | ||
|
||
assert found_identity.dict() == dict( | ||
hadPrimarySource=had_primary_source, | ||
identifierInPrimarySource=identifier_in_primary_source, | ||
stableTargetId=new_identity.stableTargetId, | ||
identifier=new_identity.identifier | ||
) | ||
|
||
|
||
def test_fetch_identity() -> None: | ||
had_primary_source = PrimarySourceID("0000000000") | ||
identifier_in_primary_source = "thing-1" | ||
|
||
identity = fetch_identity(had_primary_source,identifier_in_primary_source) | ||
assert identity is None | ||
|
||
identity = assign_identity(had_primary_source,identifier_in_primary_source) | ||
|
||
# | ||
assert fetch_identity( | ||
had_primary_source=identity.hadPrimarySource, | ||
identifier_in_primary_source=identity.identifierInPrimarySource, | ||
stable_target_id=identity.stableTargetId, | ||
) == identity | ||
|
||
|
||
def test_fetch_identity_nothing_found() -> None: | ||
assert fetch_identity( | ||
had_primary_source=PrimarySourceID.generate(), | ||
identifier_in_primary_source="thing-xyz", | ||
) is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters