def test_load_sample_publishes_case_to_rabbit(self, patch_rabbit): sample_file = ( 'UPRN,ESTAB_UPRN,ADDRESS_TYPE,ESTAB_TYPE,ADDRESS_LEVEL,ABP_CODE,ORGANISATION_NAME,ADDRESS_LINE1,' 'ADDRESS_LINE2,ADDRESS_LINE3,TOWN_NAME,POSTCODE,LATITUDE,LONGITUDE,OA,LSOA,MSOA,LAD,REGION,HTC_WILLINGNESS,' 'HTC_DIGITAL,FIELDCOORDINATOR_ID,FIELDOFFICER_ID,TREATMENT_CODE,CE_EXPECTED_CAPACITY,CE_SECURE,PRINT_BATCH', '10008677190,10008677191,HH,Household,U,RD06,,Flat 56 Francombe House,' 'Commercial Road,,Windleybury,XX1 0XX,51.4463421,-2.5924477,E00073438,E01014540,E02003043,E06000023,' 'E12000009,1,5,1,2,HH_LF3R2E,3,0,2', '10008677193,10008677192,10008677190,HH,Household,U,RD06,,First And Second Floor Flat,' '39 Cranbrook Road,,Windleybury,XX1 0XX,51.4721166,-2.5970579,E00074083,E01014669,E02003031,E06000023,' 'E12000009,2,4,4,5,HH_LF3R3AE,6,0,1') sample_units = load_sample(sample_file, 'test_ce_uuid', 'test_ap_uuid', store_loaded_sample_units=True) self.assertEquals(len(sample_units), 2) patch_rabbit_context = patch_rabbit.return_value.__enter__.return_value self.assertEqual(2, patch_rabbit_context.publish_message.call_count) publish_message_call_args = patch_rabbit_context.publish_message.call_args_list self._check_published_cases_contain_required_data( publish_message_call_args, sample_file)
def upload_sample(action_plan_id): if 'sample' not in request.files: abort(400, 'No sample file selected') sample_file_in_bytes = request.files['sample'].stream sample_file = (line.decode() for line in sample_file_in_bytes) # For convenience use the action plan ID as the collection exercise ID load_sample(sample_file, collection_exercise_id=action_plan_id, action_plan_id=action_plan_id, host=app.config["RABBITMQ_HOST"], port=app.config["RABBITMQ_PORT"], vhost=app.config["RABBITMQ_VHOST"], exchange=app.config["RABBITMQ_EXCHANGE"], user=app.config["RABBITMQ_USER"], password=app.config["RABBITMQ_PASSWORD"], queue_name=app.config["RABBITMQ_QUEUE"]) return redirect( url_for('action_plans.get_action_plan', action_plan_id=action_plan_id))
#print "New output? [y/n]" #choice = sys.stdin.readline() #choice #if choice[0] == 'y': #print "new output filename:" #output_file_name = sys.stdin.readline().replace('\n','') #print colored("Output filename used: %s",'cyan') %output_file_name # print 'Loading map: %s' %map_file # my_map = stomp.Map(map_file) # print colored("Map area: %3.2f deg^2" %my_map.Area() , 'cyan' ) #print "Load foreground data? [1=Yes]" #choice = sys.stdin.readline() #if choice[0] == '1': target_sample, target_map = load_sample.load_sample(target_file,z_min=z_min) #,n_max=20000) #print "Load background data? [1=Yes]" #choice = sys.stdin.readline() #if choice[0] == '1': background_sample, background_map = load_sample.load_sample(background_file,z_min=z_min) #, n_max=20000) print "Median foreground redshift:",numpy.median(target_sample.field('z')) ############################## # A quad tree to store the positions of the background sources -- the things you look for. ## We create the tree background_tree_map = stomp.IndexedTreeMap() for background in background_map: background_tree_map.AddPoint(background)
## here I load the data # print 'Loading map: %s' %map_file # my_map = stomp.Map(map_file) # print colored("Map area: %3.2f deg^2" %my_map.Area() , 'cyan' ) print "Load X data? [1=Yes]" choice = sys.stdin.readline() if choice[0] == '1': #CHANGED TO ASCII LOAD!!!! X_map = load_ascii_sample.load_ascii_sample(X_file,z_min=0.1)#,n_max=1000)#,z_max=1.5) print "Load target data? [1=Yes]" choice = sys.stdin.readline() if choice[0] == '1': target_sample, target_map = load_sample.load_sample(target_file,z_min=0.1) #,n_max=100)#00) #print "Median redshift:",numpy.median(X_sample.field('z')) ############################## ## We create the tree X_tree_map = stomp.IndexedTreeMap() for X in X_map: X_tree_map.AddPoint(X) ############################## ## We find pairs indices = stomp.IndexVector() neighbor_list = []