def test_cookie(self): element = HTTPCookieManager(cookies=[Cookie(name='var', value='12'),\ Cookie(name='var2', value='22')]) rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) for tag in parsed_doc['result']['CookieManager']['collectionProp'][ 'elementProp']: if tag['@name'] == 'var': assert tag['@testname'] == 'var' assert tag['stringProp'][0]['#text'] == '12'
def test_hashtree_contain(self): element = HTTPCookieManager(cookies=[Cookie(name='var', value='12'),\ Cookie(name='var2', value='22')]) rendered_doc = tag_wrapper(element.to_xml(), 'result') assert '<hashTree />' in rendered_doc
def test_empty(self): element = HTTPCookieManager() rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) assert not 'elementProp' in parsed_doc['result']['CookieManager'][ 'collectionProp']
def test_policy(self): element = HTTPCookieManager(policy=CookiePolicy.DEFAULT) rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) assert parsed_doc['result']['CookieManager']['stringProp'][ '#text'] == 'default'
def test_clear_each_iter(self): element = HTTPCookieManager(clear_each_iter=True) rendered_doc = tag_wrapper(element.to_xml(), 'result') parsed_doc = xmltodict.parse(rendered_doc) assert parsed_doc['result']['CookieManager']['boolProp'][ '#text'] == 'true'