Skip to content

Commit

Permalink
101 organization abbreviation map is mapping none incorrectly (#103)
Browse files Browse the repository at this point in the history
* fix: strip abbreviations that don't exist from mapping

* chore: lint
  • Loading branch information
dbirman authored Nov 22, 2024
1 parent 97464a3 commit 43cea87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit 43cea87

Please sign in to comment.