def test_i_expect_the_result_is_more_than_number_success(self): step = MockedStep() step.context.stash = 1 self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'more', 0))
def test_i_action_them_count(self): step = MockedStep() step.context.stash = [1, 2, 3] i_action_them(step, 'count') self.assertEqual(step.context.stash, {'values': 3})
def test_it_condition_contain_something_resource_list(self): step = MockedStep() step.context.stash.resource_list = None self.assertIsNone(it_condition_contain_something(step, 'should', 'not_important'))
def test_it_fails(self, *args): step = MockedStep() step.context.type = 'some_type' step.context.name = 'some_name' with self.assertRaises(Failure): it_fails(step)
def test_it_condition_contain_something_provider_found(self, *args): step = MockedStep() step.context.type = 'provider' step.context.stash = [{'name': 'test'}] self.assertTrue(it_condition_contain_something(step, 'something'))
def test_i_expect_the_result_is_less_and_equal_than_number_failure(self): step = MockedStep() step.context.stash = 1 with self.assertRaises(AssertionError) as err: i_expect_the_result_is_operator_than_number(step, 'less and equal', 0) self.assertEqual(str(err.exception), '1 is not less and equal than 0')
def test_i_action_them_count_list_of_dict_with_properties(self): step = MockedStep() step.context.stash = [{},{},{}] step.context.property_name = 'resource' i_action_them(step, 'count') self.assertEqual(step.context.stash, {'values': 3})
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_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]+$'))
def test_its_value_condition_match_the_search_regex_regex_resource_list(self): step = MockedStep() step.context.stash = MockedTerraformPropertyList() self.assertIsNone(its_value_condition_match_the_search_regex_regex(step, 'condition', 'some_regex'))
def setUp(self): self.step = MockedStep()
def test_encryption_is_enabled_resource_list(self): step = MockedStep() step.context.stash = MockedTerraformResourceList() self.assertIsNone(encryption_is_enabled(step))
def test_it_condition_must_something_property_stash_is_dict_found(self): step = MockedStep() step.context.stash = {'something': 'something else'} self.assertIsNone(it_condition_contain_something(step_obj=step, something='something', resourcelist=MockedTerraformResourceList))
def test_it_condition_must_something_property_is_found(self): step = MockedStep() step.context.stash = MockedTerraformResourceList() step.sentence = 'Then it must ..' it_condition_contain_something(step_obj=step, something='something', resourcelist=MockedTerraformResourceList) self.assertEqual(step.context.stash[0].__class__, MockedTerraformPropertyList)
def test_i_expect_the_result_is_more_than_number_failure(self): step = MockedStep() step.context.stash = 1 with self.assertRaises(AssertionError) as err: self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'more', 1)) self.assertEqual(str(err.exception), '1 is not more than 1')
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_i_expect_the_result_is_less_and_equal_than_number_success(self): step = MockedStep() step.context.stash = 1 self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'less and equal', 1)) self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'less and equal', 2))
def test_its_value_must_be_set_by_a_variable_resource_list(self): step = MockedStep() step.context.stash = MockedTerraformResourceList() step.context.search_value = 'something' self.assertIsNone(its_value_must_be_set_by_a_variable(step))
def test_i_expect_the_result_is_invalid_operator_than_number_failure(self): step = MockedStep() step.context.stash = 1 self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'invalid_operator', 0))
def test_its_value_must_be_set_by_a_variable(self, *args): step = MockedStep() step.context.stash = MockedTerraformResourceList() step.context.search_value = MockedTerraformResourceList() self.assertIsNone(its_value_must_be_set_by_a_variable(step))
def test_i_expect_the_result_is_more_than_number_failure(self): step = MockedStep() step.context.stash = dict(values=3) with self.assertRaises(TerraformComplianceNotImplemented) as err: self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'invalid operator', 1)) self.assertTrue('Invalid operator: invalid operator' in str(err.exception))
def test_i_action_them_sum(self): step = MockedStep() step.context.stash.resource_list = [1,2,3] i_action_them(step, 'sum') self.assertEqual(step.context.stash, 6)
def test_it_condition_contain_something_provider_not_found(self, *args): step = MockedStep() step.context.type = 'provider' step.context.stash = [] self.assertIsNone(it_condition_contain_something(step, 'something'))
def test_i_action_them_resource_list_as_dict(self): step = MockedStep() step.context.stash.resource_list = None self.assertIsNone(i_action_them(step, 'something that is not important'))
def test_property_is_enabled_not_implemented(self): step = MockedStep() step.context.stash = [{'type': 'something'}] with self.assertRaises(Failure): property_is_enabled(step, 'something')
def test_i_expect_the_result_is_operator_than_number_resource_list_as_dict(self): step = MockedStep() step.context.stash = 42 self.assertIsNone(i_expect_the_result_is_operator_than_number(step, 'operator', 'not_important'))
def test_i_action_them_sum(self): step = MockedStep() with self.assertRaises(TerraformComplianceNotImplemented): i_action_them(step, 'something_else')
def test_skip_step(self): step = MockedStep() skip_step(step) self.assertEqual(step.state, 'skipped')