def test_its_value_condition_match_the_search_regex_regex_success(self): step = MockedStep() step.context.stash = [{ 'address': 'some_resource.id', 'type': 'some_resource_type', 'name': 'some_name', 'values': [{ 'key': 'some_other_key', 'value': 'some_other_value' }, { 'key': 'some_key', 'value': 'some_value' }] }] step.context.type = 'resource' step.context.name = 'some_name' step.context.property_name = 'tags' step.context_sensitive_sentence = 'must' self.assertEqual( its_value_condition_match_the_search_regex_regex( step, 'must', 'some_.*'), None) with self.assertRaises(Failure): self.assertEqual( its_value_condition_match_the_search_regex_regex( step, 'must not', 'some_.*'), None) self.assertEqual( its_value_condition_match_the_search_regex_regex( step, 'must not', 'some_other.*'), None)
def test_its_value_must_not_match_the_search_regex_regex_string_unicode_failure(self): step = MockedStep() step.context.stash = 'some string' step.context.name = 'test name' step.context.type = 'test type' with self.assertRaises(AssertionError) as err: its_value_condition_match_the_search_regex_regex(step, 'must not', '^[sometring\s]+$') self.assertEqual(str(err.exception), '{} {} tests failed on {} regex: {}'.format(step.context.name, step.context.type, '^[sometring\s]+$', step.context.stash))
def test_its_value_must_match_not_the_search_regex_regex_string_unicode_success( self): step = MockedStep() step.context.stash = 'some string' self.assertIsNone( its_value_condition_match_the_search_regex_regex( step, 'must not', 'non_match_regex'))
def test_its_value_condition_match_the_search_regex_regex_resource_list( self): step = MockedStep() step.context.stash.resource_list = None self.assertIsNone( its_value_condition_match_the_search_regex_regex( step, 'condition', 'some_regex'))
def test_its_value_condition_match_the_search_regex_regex_null_value_is_parsed( self): step = MockedStep() step.context.stash = [{ 'address': 'some_resource.id', 'type': 'some_resource_type', 'name': 'some_name', 'values': None }] step.context.type = 'resource' step.context.name = 'some_name' step.context.property_name = 'tags' step.context_sensitive_sentence = 'must' with self.assertRaises(Failure): its_value_condition_match_the_search_regex_regex( step, 'must', 'something') with self.assertRaises(Failure): its_value_condition_equal(step, 'must', 'something')
def test_its_value_must_not_match_the_search_regex_regex_failure(self): step = MockedStep() step.context.stash = MockedTerraformPropertyList() with self.assertRaises(AssertionError): its_value_condition_match_the_search_regex_regex( step, 'must not', 'non_match_regex')
def test_its_value_must_not_match_the_search_regex_regex_success(self): step = MockedStep() step.context.stash = MockedTerraformPropertyList() self.assertIsNone( its_value_condition_match_the_search_regex_regex( step, 'must not', '^[tesvalu_\s]+$'))