<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division

from mock import patch, Mock
from unittest2 import TestCase
from afp_cli import AWSFederationClientCmd


class AWSFederationClientCmdTest(TestCase):
    def setUp(self):
        self.api_client = AWSFederationClientCmd()

    @patch("afp_cli.client.requests.get")
    def test_get_correct_account_and_role_list(self, mock_get):
        expected_result = Mock(text='{"testaccount": ["testrole"]}',
                               status_code=200,
                               reason="Ok")
        mock_get.return_value = expected_result
        result = self.api_client.get_account_and_role_list()
        self.assertEqual(
            result, {"testaccount": ["testrole"]}, msg='Should be the same')

    @patch("afp_cli.client.requests.get")
    def test_get_correct_aws_credentials(self, mock_get):
        expected_result = Mock(
            text='{"Code": "Success", '
            '"AccessKeyId": "testAccessKey", '
            '"SecretAccessKey": "testSecretAccessKey", '
            '"Token": "<PASSWORD>", '
            '"Expiration": "2015-01-01T12:34:56Z"}',
            status_code=200,
            reason="Ok")
        mock_get.return_value = expected_result
        result = self.api_client.get_aws_credentials("testaccount", "testrole")
        self.assertEqual(result, {
            "AWS_ACCESS_KEY_ID": "testAccessKey",
            "AWS_SECRET_ACCESS_KEY": "testSecretAccessKey",
            "AWS_SESSION_TOKEN": "<PASSWORD>",
            "AWS_SECURITY_TOKEN": "<PASSWORD>",
            "AWS_EXPIRATION_DATE": "2015-01-01T12:34:56Z"},
            msg='Should be the same')<commit_msg>fix unittests to work with requests.Session()<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import, division

from mock import patch, Mock
from unittest2 import TestCase
from afp_cli import AWSFederationClientCmd


class AWSFederationClientCmdTest(TestCase):
    def setUp(self):
        self.api_client = AWSFederationClientCmd()

    def test_get_correct_account_and_role_list(self):
        expected_result = Mock(text='{"testaccount": ["testrole"]}',
                               status_code=200,
                               reason="Ok")
        with patch.object(self.api_client.session, 'get', return_value=expected_result):
            result = self.api_client.get_account_and_role_list()
            self.assertEqual(
                result, {"testaccount": ["testrole"]}, msg='Should be the same')

    def test_get_correct_aws_credentials(self):
        expected_result = Mock(
            text='{"Code": "Success", '
            '"AccessKeyId": "testAccessKey", '
            '"SecretAccessKey": "testSecretAccessKey", '
            '"Token": "<PASSWORD>", '
            '"Expiration": "2015-01-01T12:34:56Z"}',
            status_code=200,
            reason="Ok")
        with patch.object(self.api_client.session, 'get', return_value=expected_result):
            result = self.api_client.get_aws_credentials("testaccount", "testrole")
            self.assertEqual(result, {
                "AWS_ACCESS_KEY_ID": "testAccessKey",
                "AWS_SECRET_ACCESS_KEY": "testSecretAccessKey",
                "AWS_SESSION_TOKEN": "<PASSWORD>",
                "AWS_SECURITY_TOKEN": "<PASSWORD>",
                "AWS_EXPIRATION_DATE": "2015-01-01T12:34:56Z"},
                msg='Should be the same')
{'fraction_non_alphanumeric': 0.12343215507411631, 'fraction_numerical': 0.020524515393386546, 'mean_word_length': 2.6898002103049423, 'pattern_counts': {'":': 24, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6435915', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1022, 'n_words': 180}