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

101 organization abbreviation map is mapping none incorrectly #103

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Organization:

ONE_OF = Annotated[Union[tuple(_OrganizationModel.__subclasses__())], Field(discriminator="name")]

abbreviation_map = {m().abbreviation: m() for m in ALL}
abbreviation_map = {m().abbreviation: m() for m in ALL if m().abbreviation is not None}

@classmethod
def from_abbreviation(cls, abbreviation: str):
Expand Down
2 changes: 1 addition & 1 deletion src/aind_data_schema_models/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ class Organization:

ONE_OF = Annotated[Union[tuple(_OrganizationModel.__subclasses__())], Field(discriminator="name")]

abbreviation_map = {m().abbreviation: m() for m in ALL}
abbreviation_map = {m().abbreviation: m() for m in ALL if m().abbreviation is not None}

@classmethod
def from_abbreviation(cls, abbreviation: str):
Expand Down
5 changes: 5 additions & 0 deletions tests/test_organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def test_none(self):

self.assertEqual(Organization.LIFECANVAS.abbreviation, None)

def test_from_none(self):
"""Test that you can't get an organization from None"""

self.assertEqual(Organization.from_abbreviation(None), None)

def test_groups(self):
"""Test that the organization groups are present"""

Expand Down
Loading