def test_manifest(self): root = Manifest(packages=Packages([Package(**self.package_attr)] * 5), actions=Actions([Action(**self.action_attr)] * 5), **self.manifest_attr) self.assertXmlNode(root, tag='manifest', text=None) self.assertXmlHasAttribute(root, 'version', expected_value=self.manifest_attr['version']) self.assertXpathsExist(root, ('./packages',)) self.assertXpathsExist(root, ('./actions',)) for key, val in self.action_attr.items(): self.assertXpathsExist(root, ('./actions/action[@{0}="{1}"]'.format(key, val),)) for key, val in self.package_attr.items(): self.assertXpathsExist(root, ('./packages/package[@{0}="{1}"]'.format(key, val),))
def test_valid_response_positive(self): updatecheck = Updatecheck_positive( urls=[ 'http://cache.pack.google.com/edgedl/chrome/install/782.112/' ], manifest=Manifest(version='13.0.782.112', packages=Packages([ Package( name='chrome_installer.exe', required='true', size='23963192', hash='VXriGUVI0TNqfLlU02vBel4Q3Zo=', ) ]), actions=Actions([ Action(event='install', arguments='--do-not-launch-chrome', run='chrome_installer.exe'), Action(event='postinstall', version='13.0.782.112', onsuccess='exitsilentlyonlaunchcmd'), ]))) app = App( '{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', status='ok', updatecheck=updatecheck, ping=True, ) response = Response( server='prod', protocol='3.0', date=datetime(2014, 1, 1, hour=15, minute=41, second=48), # 56508 sec apps_list=[ App('{430FD4D0-B729-4F61-AA34-91526481799D}', status='ok', ping=True, updatecheck=Updatecheck_negative()), app, ]) self.assertXmlValidXSchema(response, filename=RESPONSE_XSD_FILE) self.assertXmlEquivalentOutputs( etree.tostring(response), fixtures.response_update_check_positive)
def test_updatecheck_positive(self): root = Updatecheck_positive( urls=[self.url] * 5, manifest=Manifest(packages=Packages([Package(**self.package_attr)] * 5), actions=Actions([Action(**self.action_attr)] * 5), **self.manifest_attr) ) self.assertXmlNode(root, tag='updatecheck', text=None) self.assertXmlHasAttribute(root, 'status', expected_value='ok') self.assertXpathsExist(root, ('./urls',)) self.assertXpathsExist(root, ('./manifest',)) for key, val in self.action_attr.items(): self.assertXpathsExist(root, ('./manifest/actions/action[@{0}="{1}"]'.format(key, val),)) for key, val in self.package_attr.items(): self.assertXpathsExist(root, ('./manifest/packages/package[@{0}="{1}"]'.format(key, val),))
def on_app(apps_list, app, os, userid): app_id = app.get('appid') version = app.get('version') platform = os.get('platform') channel = parser.get_channel(app) ping = bool(app.findall('ping')) events = reduce(on_event, app.findall('event'), []) build_app = partial(App, app_id, status='ok', ping=ping, events=events) updatecheck = app.findall('updatecheck') try: version = get_version(app_id, platform, channel, version, userid) except Version.DoesNotExist: apps_list.append( build_app( updatecheck=Updatecheck_negative() if updatecheck else None)) return apps_list data_list = reduce(partial(on_data, version=version), app.findall('data'), []) build_app = partial(build_app, data_list=data_list) if updatecheck: actions = reduce(on_action, version.actions.all(), []) updatecheck = Updatecheck_positive( urls=[version.file_url], manifest=Manifest( version=str(version.version), packages=Packages([ Package( name=version.file_package_name, required='true', size=str(version.file_size), hash=version.file_hash, ) ]), actions=Actions(actions) if actions else None, )) apps_list.append(build_app(updatecheck=updatecheck)) else: apps_list.append(build_app()) return apps_list