def test_rdk_functions_evaluate_parameters_not_exist(self): module_node = astroid.parse(MISSING_PARAMETERS_EVALUATION) with self.assertAddsMessages( pylint.testutils.Message( msg_id='rdk-functions-not-up-to-date', args="'evaluate_parameters' is not included", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node), pylint.testutils.Message( msg_id='rdk-functions-not-up-to-date', args= "'InvalidParametersError' is not used for evaluating parameters", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node)): self.checker.visit_module(module_node)
def test_gherkin_bad_scenario_format_not_compliant(self): module_node = astroid.parse(BAD_FORMAT_GHERKIN) with self.assertAddsMessages( pylint.testutils.Message( msg_id='gherkin-not-compliant', args= "Scenario line ' Scenario 1:' is not using the right Gherkin Format", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node), pylint.testutils.Message( msg_id='gherkin-not-compliant', args= "Scenario line ' Scenario 2:' is not using the right Gherkin Format", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node)): self.checker.visit_module(module_node)
def test_gherkin_missing_field_not_compliant(self): module_node = astroid.parse(MISSING_FIELD_GHERKIN) with self.assertAddsMessages( pylint.testutils.Message( msg_id='gherkin-not-compliant', args="'Rule Name' is not included", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node)): self.checker.visit_module(module_node)
def test_gherkin_not_exist(self): module_node = astroid.parse(NO_GHERKIN) with self.assertAddsMessages( pylint.testutils.Message( msg_id='gherkin-not-compliant', args="No Gherkin doc found", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node)): self.checker.visit_module(module_node)
def test_rdk_functions_evaluate_function_not_exist(self): module_node = astroid.parse(MISSING_EVALUATION_FUNCTION) with self.assertAddsMessages( pylint.testutils.Message( msg_id='rdk-functions-not-up-to-date', args= "'evaluate_change' or 'evaluate_periodic' is not included", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=module_node)): self.checker.visit_module(module_node)
def test_rdk_functions_no_resource_type_in_lambda_handler(self): func_node = astroid.extract_node(MISSING_RESOURCE_TYPE) with self.assertAddsMessages( pylint.testutils.Message( msg_id='rdk-functions-not-up-to-date', args= "No resource type for Evaluator in lambda_handler, example https://code.amazon.com/packages/AwsFalconOrbiter/blobs/903db8f2fc93711f96047943e3be99c0ad7bd74e/--/managed-rule-code/API_GW_ENDPOINT_TYPE_CHECK.py#L80", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=func_node)): self.checker.visit_functiondef(func_node)
def test_bad_field5_name(self): module_node = astroid.parse(BAD_FIELD5) for sub_node in module_node.body: if isinstance(sub_node, astroid.ClassDef): for function in sub_node.body: function_node = function with self.assertAddsMessages( pylint.testutils.Message( msg_id='testcase-naming-not-compliant', args= "Fifth field in test case name should be <outputResult> from 'returnsNonCompliant', 'returnsCompliant', 'returnsNotApplicable', 'raisesException'", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=function)): self.checker.visit_module(module_node)
def test_bad_field3_name(self): module_node = astroid.parse(BAD_FIELD3) for sub_node in module_node.body: if isinstance(sub_node, astroid.ClassDef): for function in sub_node.body: function_node = function with self.assertAddsMessages( pylint.testutils.Message( msg_id='testcase-naming-not-compliant', args= "Third field in test case name should be <methodName> from 'evaluatePeriodic', 'evaluateParameters', 'evaluateChange'", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=function)): self.checker.visit_module(module_node)
def test_bad_field2_name(self): module_node = astroid.parse(BAD_FIELD2) for sub_node in module_node.body: if isinstance(sub_node, astroid.ClassDef): for function in sub_node.body: function_node = function with self.assertAddsMessages( pylint.testutils.Message( msg_id='testcase-naming-not-compliant', args= "Second field in test case name should be <scenrioName>", confidence=Confidence( name='HIGH', description='No false positive possible.'), node=function)): self.checker.visit_module(module_node)