'Test a number of bearer token placements'

def test_add_bearer_token(self):

    client = Client(self.client_id, token_type=u'invalid')
    self.assertRaises(ValueError, client.add_token, self.uri)
    client = Client(self.client_id, access_token=self.access_token, token_type=u'bEAreR')
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers)
    self.assertURLEqual(uri, self.uri)
    self.assertFormBodyEqual(body, self.body)
    self.assertEqual(headers, self.bearer_header)
    client = Client(self.client_id)
    self.assertRaises(ValueError, client.add_token, self.uri)
    client = Client(self.client_id, access_token=self.access_token)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers)
    self.assertURLEqual(uri, self.uri)
    self.assertFormBodyEqual(body, self.body)
    self.assertEqual(headers, self.bearer_header)
    client = Client(self.client_id, access_token=self.access_token, default_token_placement=AUTH_HEADER)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers)
    self.assertURLEqual(uri, self.uri)
    self.assertFormBodyEqual(body, self.body)
    self.assertEqual(headers, self.bearer_header)
    client = Client(self.client_id, access_token=self.access_token, default_token_placement=URI_QUERY)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers)
    self.assertURLEqual(uri, self.bearer_query)
    self.assertFormBodyEqual(body, self.body)
    self.assertEqual(headers, self.headers)
    client = Client(self.client_id, access_token=self.access_token, default_token_placement=BODY)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers)
    self.assertURLEqual(uri, self.uri)
    self.assertFormBodyEqual(body, self.bearer_body)
    self.assertEqual(headers, self.headers)
    client = Client(self.client_id, access_token=self.access_token)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers, token_placement=AUTH_HEADER)
    self.assertURLEqual(uri, self.uri)
    self.assertFormBodyEqual(body, self.body)
    self.assertEqual(headers, self.bearer_header)
    client = Client(self.client_id, access_token=self.access_token)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers, token_placement=URI_QUERY)
    self.assertURLEqual(uri, self.bearer_query)
    self.assertFormBodyEqual(body, self.body)
    self.assertEqual(headers, self.headers)
    client = Client(self.client_id, access_token=self.access_token)
    (uri, headers, body) = client.add_token(self.uri, body=self.body, headers=self.headers, token_placement=BODY)
    self.assertURLEqual(uri, self.uri)
    self.assertFormBodyEqual(body, self.bearer_body)
    self.assertEqual(headers, self.headers)
    client = Client(self.client_id, access_token=self.access_token)
    self.assertRaises(ValueError, client.add_token, self.uri, body=self.body, headers=self.headers, token_placement=u'invalid')
    client = Client(self.client_id, access_token=self.access_token, default_token_placement=u'invalid')
    self.assertRaises(ValueError, client.add_token, self.uri, body=self.body, headers=self.headers)
