@patch('requests.post')
    def test_initial_constructor(self, r_post):
        r_post.return_value = Mock(
            status_code=200,
            text='oauth_token=token&oauth_token_secret=token_secret'
        )

        credentials = PartnerCredentials(
            consumer_key='key',
            consumer_secret='secret',
            rsa_key='abc',
            client_cert=('/fake/path', '/fake/otherpath'),
            scope='payroll.endpoint'
        )

        # A HTTP request was made
        self.assertTrue(r_post.called)

        state = credentials.state

        # Expiry times should be calculated
        self.assertIsNotNone(state.pop("oauth_authorization_expires_at"))
        self.assertIsNotNone(state.pop("oauth_expires_at"))

        self.assertEqual(state, {
            'consumer_key': 'key',
            'consumer_secret': 'secret',
            'oauth_token': 'token',
            'oauth_token_secret': 'token_secret',
            'verified': False,
            'scope': 'payroll.endpoint'
        })
Initial construction causes a request to get a request token
dataset/ETHPy150Open freakboy3742/pyxero/tests/auth.py/PartnerCredentialsTest.test_initial_constructor