def test_valid_response_negative(self): 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}', updatecheck=Updatecheck_negative(), ping=True), App('{D0AB2EBC-931B-4013-9FEB-C9C4C2225C8C}', updatecheck=Updatecheck_negative(), ping=True), ] ) self.assertXmlValidXSchema(response, filename=RESPONSE_XSD_FILE) self.assertXmlEquivalentOutputs(etree.tostring(response), fixtures.response_update_check_negative)
def test_app(self): root = App(updatecheck=Updatecheck_negative(), **self.app_attr) self.assertXmlNode(root, tag='app', text=None) self.assertXmlHasAttribute(root, 'status', expected_value='ok') self.assertXmlHasAttribute(root, 'appid', expected_value=self.app_attr['app_id']) self.assertXpathsExist(root, ('./updatecheck', ))
def test_response(self): now = datetime.utcnow() elapsed_seconds = get_sec_since_midnight(now) root = Response( date=now, apps_list=[App(updatecheck=Updatecheck_negative(), **self.app_attr)]) self.assertXmlNode(root, tag='response', text=None) self.assertXpathsExist(root, ('./daystart',)) self.assertXpathsExist(root, ('./app',)) self.assertXpathsExist(root, ('./daystart[@elapsed_seconds="%s"]' % elapsed_seconds,))
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 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
def test_updatecheck_negative(self): root = Updatecheck_negative() self.assertXmlNode(root, tag='updatecheck', text=None) self.assertXmlHasAttribute(root, 'status', expected_value='noupdate')