Coverage for source/environment/mock_validator.py: 86%

7 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-06-06 12:00 +0000

1# tests/environment/mock_validator.py 

2 

3from typing import Callable 

4 

5from source.environment import RewardValidatorBase, Order 

6 

7class MockRewardValidator(RewardValidatorBase): 

8 """ 

9 Implements validator that validation policy can be specified from outside of the class. 

10 This allows for creation of simple validators to be mocked during testing. 

11 """ 

12 

13 def __init__(self, mocking_fucntion: Callable[[list[Order]], float]) -> None: 

14 """ 

15 Class constructor. 

16 

17 Parameters: 

18 mocking_fucntion (Callable[[list[Order]], float]): Allows to specify 

19 validator's policy from outside of the class. 

20 """ 

21 

22 self.lambda_mocking_function: Callable[[list[Order]], float] = mocking_fucntion 

23 

24 def validate_orders(self, orders: list[Order]) -> float: 

25 """ 

26 Calculates number of points to be rewarded for list of closed trades. 

27 

28 Parameters: 

29 orders (list[Order]): Orders to be validated. 

30 

31 Returns: 

32 (float): Calcualted reward. 

33 """ 

34 

35 return self.lambda_mocking_function(orders)