Coverage for jstark/exceptions.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-02-25 20:09 +0000

1"""jstark exceptions 

2""" 

3from jstark.period_unit_of_measure import PeriodUnitOfMeasure 

4 

5 

6class FeaturePeriodMnemonicIsInvalid(Exception): 

7 """FeaturePeriod mnemonic doesn't match X[dqmqy]Y""" 

8 

9 def __str__(self) -> str: 

10 return ( 

11 "FeaturePeriod mnemonic must be an integer followed by a letter " 

12 + f"from {[e.value for e in PeriodUnitOfMeasure]} followed by an integer" 

13 ) 

14 

15 

16class FeaturePeriodEndGreaterThanStartError(Exception): 

17 """Exception indicating end of a feature period cannot be before the start""" 

18 

19 def __init__(self, start: int, end: int, *args: object) -> None: 

20 super().__init__(*args) 

21 self.start = start 

22 self.end = end 

23 

24 def __str__(self) -> str: 

25 return ( 

26 f"End of the feature period ({self.end}) cannot be " 

27 + f"before the start of the feature period ({self.start})" 

28 ) 

29 

30 

31class AsAtIsNotADate(Exception): 

32 """Exception indicating a value must be of type date""" 

33 

34 def __str__(self) -> str: 

35 return "as_at value must be of type date"