def test_md5_query(syn, project, schedule_for_cleanup): # Add the same Entity several times path = utils.make_bogus_data_file() schedule_for_cleanup(path) repeated = File(path, parent=project['id'], description='Same data over and over again') # Retrieve the data via MD5 num = 5 stored = [] for i in range(num): repeated.name = 'Repeated data %d.dat' % i stored.append(syn.store(repeated).id) # Although we expect num results, it is possible for the MD5 to be non-unique results = syn.md5Query(utils.md5_for_file(path).hexdigest()) assert str(sorted(stored)) == str(sorted([res['id'] for res in results])) assert len(results) == num
def test_download_file_false(): RENAME_SUFFIX = 'blah' # Upload a file filepath = utils.make_bogus_binary_file() schedule_for_cleanup(filepath) schedule_for_cleanup(filepath + RENAME_SUFFIX) file = File(filepath, name='SYNR 619', parent=project) file = syn.store(file) # Now hide the file from the cache and download with downloadFile=False os.rename(filepath, filepath + RENAME_SUFFIX) file = syn.get(file.id, downloadFile=False) # Change something and reupload the file's metadata file.name = "Only change the name, not the file" reupload = syn.store(file) assert reupload.path is None, "Path field should be null: %s" % reupload.path # This should still get the correct file reupload = syn.get(reupload.id) assert filecmp.cmp(filepath + RENAME_SUFFIX, reupload.path) assert reupload.name == file.name