def make_fake_file_info(platform, version, type): return { 'name': cef_json_builder.get_file_name(version, platform, type) + '.tar.gz', 'size': make_fake_size(), 'lastModified': datetime.datetime.now(), 'sha1': make_fake_sha1() }
def _add_test_file(self, builder, platform='linux32', version='3.2704.1414.g185cd6c', type='standard', channel='stable', attrib_idx=0, shouldfail=False): name = cef_json_builder.get_file_name(version, platform, type, channel) + '.tar.gz' # Some random attribute information. sha1 must be different to trigger replacement. attribs = [{ 'date_str': '2016-05-18T22:42:15.487Z', 'date_val': datetime.datetime(2016, 5, 18, 22, 42, 15, 487000), 'sha1': '2d48ee05ea6385c8fe80879c98c5dd505ad4b100', 'size': 48395610 }, { 'date_str': '2016-05-14T22:42:15.487Z', 'date_val': datetime.datetime(2016, 5, 14, 22, 42, 15, 487000), 'sha1': '2d48ee05ea6385c8fe80879c98c5dd505ad4b200', 'size': 48395620 }] # Populate the Chromium version to avoid queries. chromium_version = '49.0.2705.50' self.assertEqual( chromium_version, builder.set_chromium_version(version, chromium_version)) self.assertEqual(0, builder.get_query_count()) result = builder.add_file(name, attribs[attrib_idx]['size'], attribs[attrib_idx]['date_str'], attribs[attrib_idx]['sha1']) # Failure should be expected when adding the same file multiple times with the same sha1. self.assertEqual(not shouldfail, result) # Return the result expected from get_files(). return { 'chromium_version': chromium_version, 'sha1': attribs[attrib_idx]['sha1'], 'name': name, 'platform': platform, 'last_modified': attribs[attrib_idx]['date_val'], 'cef_version': version, 'channel': channel, 'type': type, 'size': attribs[attrib_idx]['size'] }
def _add_test_file(self, builder, platform='linux32', version='3.2704.1414.g185cd6c', type='standard', attrib_idx=0, shouldfail=False): name = cef_json_builder.get_file_name(version, platform, type) + '.tar.gz' # Some random attribute information. sha1 must be different to trigger replacement. attribs = [{ 'date_str': '2016-05-18T22:42:15.487Z', 'date_val': datetime.datetime(2016, 5, 18, 22, 42, 15, 487000), 'sha1': '2d48ee05ea6385c8fe80879c98c5dd505ad4b100', 'size': 48395610 }, { 'date_str': '2016-05-14T22:42:15.487Z', 'date_val': datetime.datetime(2016, 5, 14, 22, 42, 15, 487000), 'sha1': '2d48ee05ea6385c8fe80879c98c5dd505ad4b200', 'size': 48395620 }] # Populate the Chromium version to avoid queries. chromium_version = '49.0.2705.50' self.assertEqual(chromium_version, builder.set_chromium_version(version, chromium_version)) self.assertEqual(0, builder.get_query_count()) result = builder.add_file(name, attribs[attrib_idx]['size'], attribs[attrib_idx]['date_str'], attribs[attrib_idx]['sha1']) # Failure should be expected when adding the same file multiple times with the same sha1. self.assertEqual(not shouldfail, result) # Return the result expected from get_files(). return { 'chromium_version': chromium_version, 'sha1': attribs[attrib_idx]['sha1'], 'name': name, 'platform': platform, 'last_modified': attribs[attrib_idx]['date_val'], 'cef_version': version, 'type': type, 'size': attribs[attrib_idx]['size'] }