def test_get_headers(self): # All header params are given client = Client( endpoint='#', login_username='******', login_password='******', content_type='application/xml') headers = client._get_headers() self.assertEqual(headers, { 'Content-type': 'application/xml', 'login.username': '******', 'login.password': '******', 'Authorization': "Basic {0}".format( base64.b64encode("username:password"))}) # Only mandatory params are given client = Client( endpoint='#', login_username='******', login_password='******') headers = client._get_headers() self.assertEqual(headers, { 'Content-type': 'application/json', 'login.username': '******', 'login.password': '******', 'Authorization': "Basic {0}".format( base64.b64encode("username:password"))}) # login.username and login.password are None client = Client( endpoint='#', login_username=None, login_password=None) headers = client._get_headers() self.assertEqual(headers, { 'Content-type': 'application/json', 'login.username': '', 'login.password': '', 'Authorization': "Basic {0}".format(base64.b64encode(':'))})
def setUp(self): self.client = Client( endpoint='http://endpoint', login_username='******', login_password='******')