11"""CheckType Implementation."""
22import re
33from typing import Mapping , Tuple , List , Dict , Any , Union
4+ from abc import ABC , abstractmethod
45import jmespath
56
67
1718# pylint: disable=arguments-differ
1819
1920
20- class CheckType :
21- """Check Type Class."""
21+ class CheckType ( ABC ) :
22+ """Check Type Base Abstract Class."""
2223
2324 @staticmethod
24- def init (check_type ):
25+ def init (check_type : str ):
2526 """Factory pattern to get the appropriate CheckType implementation.
2627
2728 Args:
@@ -68,7 +69,7 @@ def get_value(output: Union[Mapping, List], path: str, exclude: List = None) ->
6869 return values
6970
7071 for element in values : # process elements to check is lists should be flatten
71- # TODO: Not sure how this is working becasyse from `jmespath.search` it's supposed to get a flat list
72+ # TODO: Not sure how this is working because from `jmespath.search` it's supposed to get a flat list
7273 # of str or Decimals, not another list...
7374 for item in element :
7475 if isinstance (item , dict ): # raise if there is a dict, path must be more specific to extract data
@@ -88,25 +89,26 @@ def get_value(output: Union[Mapping, List], path: str, exclude: List = None) ->
8889
8990 return values
9091
91- def evaluate (self , value_to_compare : Any , ** kwargs ) -> Tuple [Dict , bool ]:
92+ @abstractmethod
93+ def evaluate (self , * args , ** kwargs ) -> Tuple [Dict , bool ]:
9294 """Return the result of the evaluation and a boolean True if it passes it or False otherwise.
9395
9496 This method is the one that each CheckType has to implement.
9597
9698 Args:
97- value_to_compare: Similar value as above to perform comparison.
99+ *args: arguments specific to child class implementation
100+ **kwargs: named arguments
98101
99102 Returns:
100103 tuple: Dictionary representing check result, bool indicating if differences are found.
101104 """
102105 # This method should call before any other logic the validation of the arguments
103106 # self.validate(**kwargs)
104- raise NotImplementedError
105107
106108 @staticmethod
107- def validate (** kwargs ):
109+ @abstractmethod
110+ def validate (** kwargs ) -> None :
108111 """Method to validate arguments that raises proper exceptions."""
109- raise NotImplementedError
110112
111113
112114class ExactMatchType (CheckType ):
0 commit comments