def test_append(self): orig_agent = 'bar' headers = {'user-agent': orig_agent} user_agent = 'baz' result = transport._apply_user_agent(headers, user_agent) self.assertIs(result, headers) final_agent = user_agent + ' ' + orig_agent self.assertEqual(result, {'user-agent': final_agent})
def test_new_agent(self): headers = {} user_agent = 'foo' result = transport._apply_user_agent(headers, user_agent) self.assertIs(result, headers) self.assertEqual(result, {'user-agent': user_agent})
def test_null(self): headers = object() result = transport._apply_user_agent(headers, None) self.assertIs(result, headers)