Skip to content

Conversation

cfulton
Copy link

@cfulton cfulton commented Dec 19, 2024

Improved the validate_unit method so that it can handle both string and enums.

  • Created set of all supported units. Set includes current enums and consts in units.py
  • Handled if unit was string or enum.
  • Checked if provided unit is in set of all supported units. Return unit if it is in set.
  • raise new InvalidUnitOfMeasureException if we didn't return a valid unit.
  • Changed return to always be string and updated implementation.

Tests created to validate scenarios of:

  • Tested with valid units as enum values.
  • Tested with valid units as string.
  • Verified that return is string type.
  • Tested Invalid unit scenarios to always raise InvalidUnitOfMeasureException

@TheJulianJES
Copy link
Contributor

We've gone with this approach for now: #352
Still, thank you very much for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants