def test_close_browser_not_called(self): snapshot.render.browser = None image, location = snapshot.render_snapshot( self.source_location, self.organization_id, self.project_id, self.build_id, self.title, self.width, 'chrome', self.selector, self.hide_selectors) assert not snapshot.render.close_browser.called
def run_task(body): data = json.loads(body, encoding='utf-8') snapshot_id = data['id'] source_location = data['sourceLocation'] organization_id = data['organizationId'] project_id = data['projectId'] build_id = data['buildId'] title = data['title'] width = data['width'] browser = data['browser'] selector = data.get('selector', None) hide_selectors = data.get('hideSelectors', None) compare_snapshot = data.get('compareSnapshot', None) flake_sha_list = data.get('flakeShas', []) save_snapshot = compare_snapshot == None snapshop_image, image_location = render_snapshot( source_location, organization_id, project_id, build_id, title, width, browser, selector, hide_selectors, save_snapshot ) message = { 'id': data['id'], } if data.get('compareSnapshot'): diff_location, difference, image_location, diff_sha, flake_matched = diff_snapshot( snapshop_image, organization_id, project_id, build_id, browser, title, width, compare_snapshot, flake_sha_list, True ) if not flake_matched: message['diffLocation'] = diff_location message['differenceAmount'] = str(difference) message['diffSha'] = diff_sha message['difference'] = not flake_matched and difference > 0.1 message['flakeMatched'] = flake_matched message['imageLocation'] = image_location send_message(message)
def test_close_browser_is_called_when_browser_changes(self): image, location = snapshot.render_snapshot( self.source_location, self.organization_id, self.project_id, self.build_id, self.title, self.width, 'chrome', self.selector, self.hide_selectors ) assert snapshot.render.close_browser.called
def test_render_snapshot(self): image, location = snapshot.render_snapshot( self.source_location, self.organization_id, self.project_id, self.build_id, self.title, self.width, self.browser, self.selector, self.hide_selectors) assert snapshot.render.render.called assert snapshot.render.open_browser.called assert not snapshot.render.close_browser.called assert image.read() == b'' self.assertRegex( location, "/{}/{}/{}/screenshots/firefox/1280/[a-f0-9]+\.html\.png$".format( self.organization_id, self.project_id, self.build_id))
def process_message(body): data = json.loads(body, encoding='utf-8') id = data['id'] source_location = data['sourceLocation'] organization_id = data['organizationId'] project_id = data['projectId'] build_id = data['buildId'] title = data['title'] width = data['width'] browser = data['browser'] selector = data.get('selector', None) hide_selectors = data.get('hideSelectors', None) compare_snapshot = data.get('compareSnapshot', None) flake_sha_list = data.get('flakeShas', []) save_snapshot = compare_snapshot is None try: snapshot_image, image_location = render_snapshot( source_location, organization_id, project_id, build_id, title, width, browser, selector, hide_selectors, save_snapshot) message = { 'id': id, } if compare_snapshot: diff_location, difference, image_location, diff_sha, flake_matched, centers = diff_snapshot( snapshot_image, organization_id, project_id, build_id, browser, title, width, compare_snapshot, flake_sha_list, True) if not flake_matched: message['diffLocation'] = diff_location message['differenceAmount'] = str(difference) message['diffSha'] = diff_sha message['difference'] = not flake_matched and difference > 0.1 message['flakeMatched'] = flake_matched message['centers'] = centers message['imageLocation'] = image_location return message except Exception as ex: print(''.join( traceback.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__))) print('There was an error trying to render the snapshot {}'.format( title)) return None
def run_task(snapshot_id, organization_id, project_id, build_id, source_location, title, width, browser, selector, hide_selectors, compare_snapshot): title = ' '.join(title) snapshop_image, image_location = render_snapshot(source_location, organization_id, project_id, build_id, title, width, browser, selector, hide_selectors) message = {'id': snapshot_id, 'imageLocation': image_location} if compare_snapshot: diff_location, difference, image_location, diff_sha, flake_matched = diff_snapshot( snapshop_image, organization_id, project_id, build_id, browser, width, [], compare_snapshot) message['diffLocation'] = diff_location message['difference'] = 0 if difference == 0 else difference send_message(message)
organization_id = data['organizationId'] project_id = data['projectId'] build_id = data['buildId'] title = data['title'] width = data['width'] browser = data['browser'] selector = data.get('selector', None) hide_selectors = data.get('hideSelector', None) compare_snapshot = data.get('compareSnapshot', None) flake_sha_list = data.get('flakeShas', []) try: save_snapshot = compare_snapshot == None snapshop_image, image_location = render_snapshot( source_location, organization_id, project_id, build_id, title, width, browser, selector, hide_selectors, save_snapshot) message_data = { 'id': snapshot_id, } if compare_snapshot: diff_location, difference, image_location, diff_hash, flake_matched = diff_snapshot( snapshop_image, organization_id, project_id, build_id, browser, title, width, compare_snapshot, flake_sha_list, True) if not flake_matched: message_data['diffLocation'] = diff_location message_data['differenceAmount'] = str(difference)