self.assertEqual(len(self.operations_called), 0) self.assertTrue( json_matches(json.loads(output[0]), self.expected_policy_document)) # Use case: Expected trust policy already exists # Expected results: No operation is performed by client # The command should print that the trust policy statement already exists @mock.patch('awscli.customizations.emrcontainers.' 'iam.IAM.get_assume_role_policy') @mock.patch('awscli.customizations.emrcontainers.' 'eks.EKS.get_oidc_issuer_id') @mock.patch('awscli.customizations.emrcontainers.' 'eks.EKS.get_account_id') def test_trust_policy_exists(self, get_account_id_patch, get_oidc_issuer_id_patch, get_assume_role_policy_patch): self.policy_document = self.expected_policy_document get_assume_role_policy_patch.return_value = self.policy_document get_oidc_issuer_id_patch.return_value = self.oidc_provider get_account_id_patch.return_value = self.account_id output = self.run_cmd(self.command, expected_rc=0) self.assertEqual(len(self.operations_called), 0) self.assertTrue(TRUST_POLICY_STATEMENT_ALREADY_EXISTS % self.role_name in output[0]) if __name__ == "__main__": unittest.main()
self.assertEqual( '[default]\n' 's3 =\n' ' signature_version = NEWVALUE\n', self.get_config_file_contents()) def test_get_nested_attribute(self): self.set_config_file_contents( '[default]\n' 's3 =\n' ' signature_version = v4\n' ) p = aws('configure get default.s3.signature_version', env_vars=self.env_vars) self.assertEqual(p.stdout.strip(), 'v4') p = aws('configure get default.bad.doesnotexist', env_vars=self.env_vars) self.assertEqual(p.rc, 1) self.assertEqual(p.stdout, '') class TestConfigureHasArgTable(unittest.TestCase): def test_configure_command_has_arg_table(self): m = mock.Mock() command = configure.ConfigureCommand(m) self.assertEqual(command.arg_table, {}) if __name__ == '__main__': unittest.main()