def test_browse_hospitals(pent_context): graphql_schema = create_hcris_schema() line_one = '100002,"100002",10/1/2015,"01-OCT-15",9/30/2016,"30-SEP-16","As Submitted",2,"BETHESDA HOSPITAL INC","2815 SOUTH SEACREST BLVD",,"BOYNTON BEACH","FL","33435","PALM BEACH"' line_two = '100006,"100006",10/1/2015,"01-OCT-15",9/30/2016,"30-SEP-16","As Submitted",2,"ORLANDO HEALTH","1414 KUHL AVENUE",,"ORLANDO","FL","32806","ORANGE"' line_three = '100007,"100007",1/1/2015,"01-JAN-15",12/31/2015,"31-DEC-15","Amended",2,"FLORIDA HOSPITAL","601 EAST ROLLINS STREET",,"ORLANDO","FL","32803","ORANGE"' datas = [ persist_provider_from_csv(line_one, pent_context, graphql_schema), persist_provider_from_csv(line_two, pent_context, graphql_schema), persist_provider_from_csv(line_three, pent_context, graphql_schema), ] ids = [UUID(hex=data['createProvider']['id']) for data in datas] id_first, id_second, id_third = tuple(sorted(ids)) all_hospitals = execute_gen(Provider.gen_all(pent_context, None, None)) all_ids = [hospital.obj_id() for hospital in all_hospitals] assert all_ids == [id_first, id_second, id_third] after_one_hospitals = execute_gen( Provider.gen_all(pent_context, after=id_first, first=None)) after_one_ids = [hospital.obj_id() for hospital in after_one_hospitals] assert after_one_ids == [id_second, id_third] after_one_first_one_hospitals = execute_gen( Provider.gen_all(pent_context, after=id_first, first=1)) after_one_first_one_ids = [ hospital.obj_id() for hospital in after_one_first_one_hospitals ] assert after_one_first_one_ids == [id_second]
def test_get_item(): pent_context = mem_context() user_input = TodoUserInput(name='John Doe') user = execute_gen(create_todo_user(pent_context, user_input)) todo_input_one = TodoItemInput(user_id=user.obj_id(), text='something one') todo_one = execute_gen(create_todo_item(pent_context, todo_input_one)) assert todo_one.text() == 'something one' todo_input_two = TodoItemInput(user_id=user.obj_id(), text='something two') todo_two = execute_gen(create_todo_item(pent_context, todo_input_two)) assert todo_two.text() == 'something two' todo_user_out = execute_gen(todo_one.gen_user()) assert todo_user_out.name() == 'John Doe' query = '{ todoItem(id: "%s") { text } }' % todo_one.obj_id() result = execute_todo_query(query, pent_context) assert result.data['todoItem']['text'] == 'something one' query = '{ user (id: "%s") { todoItems { text } } }' % user.obj_id() result = execute_todo_query(query, pent_context) assert len(result.data['user']['todoItems']) == 2 assert result.data['user']['todoItems'][0]['text'] == 'something one' assert result.data['user']['todoItems'][1]['text'] == 'something two' first_one_todo_items = execute_gen(user.gen_todo_items(first=1)) assert len(first_one_todo_items) == 1 assert first_one_todo_items[0].text() == 'something one' query = '{ user (id: "%s") { todoItems(first: 1) { text } } }' % user.obj_id( ) result = execute_todo_query(query, pent_context) assert result.data['user']['todoItems'][0]['text'] == 'something one'
def test_hcris_little_graph(pent_context): graphql_schema = create_hcris_schema() provider_line = '1111,"1111",10/1/2015,"01-OCT-15",9/30/2016,"30-SEP-16","As Submitted",2,"BETHESDA HOSPITAL INC","2815 SOUTH SEACREST BLVD",,"BOYNTON BEACH","FL","33435","PALM BEACH"' provider_data = persist_provider_from_csv(provider_line, pent_context, graphql_schema) report_one_line = '577257,"2","1111",1,"N","N","G","11001",4,"F",,,10/1/2015,12/31/2015,6/14/2016,6/1/2016,,5/25/2016' report_two_line = '577258,"2","1111",1,"N","N","G","11001",4,"F",,,10/1/2015,12/31/2015,6/14/2016,6/1/2016,,5/25/2016' persist_report_from_csv(report_one_line, pent_context, graphql_schema) persist_report_from_csv(report_two_line, pent_context, graphql_schema) provider_id = UUID(hex=provider_data['createProvider']['id']) assert isinstance(provider_id, UUID) provider = execute_gen(Provider.gen(pent_context, provider_id)) assert isinstance(provider, Provider) reports = execute_gen(provider.gen_reports()) assert len(reports) == 2
def test_get_user(): pent_context = mem_context() user_input = TodoUserInput(name='John Doe') user = execute_gen(create_todo_user(pent_context, user_input)) assert user.name() == 'John Doe' new_id = user.obj_id() result = get_user_name_via_graphql(pent_context, new_id) assert result.data['user']['name'] == 'John Doe'
def test_get_computed_field(): pent_context = mem_context() user_input = TodoUserInput(name='John Doe') user = execute_gen(create_todo_user(pent_context, user_input)) assert user.name() == 'John Doe' new_id = user.obj_id() query = '{ user (id: "%s") { capitalizedName } }' % new_id result = execute_todo_query(query, pent_context) assert result.data['user']['capitalizedName'] == 'JOHN DOE'
def hello(): user_id = execute_gen(gen_main()).obj_id() # query = '{ user(id: "%s") { id, name } }' % user_id # pent_context = create_pent_context() # loop = asyncio.new_event_loop() # result = graphql( # create_todo_schema(), # query, # executor=AsyncioExecutor(loop=loop), # context_value=pent_context # ) return """ Passed param check Another changed Hello World from Flask using Python 3.5 """ + str(user_id)
def browse_objects(self, type_id, limit=100, offset=0): return execute_gen(self.shard.gen_browse_objects(type_id, limit, offset))
def get_objects(self, ids): return execute_gen(self.shard.gen_objects(ids))
def get_object(self, obj_id): return execute_gen(self.shard.gen_object(obj_id))
def update_object(self, obj_id, data): return execute_gen(self.shard.gen_update_object(obj_id, data))
def sync_kv_get_objects(shard, ids): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_objects(ids))
def get_index_entries(self, index, index_value): return execute_gen(self.shard.gen_index_entries(index, index_value))
def get_edge_ids(self, edge_def, from_id, after=None, first=None): return execute_gen(self.shard.gen_edge_ids(edge_def, from_id, after, first))
def sync_kv_update_object(shard, obj_id, data): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_update_object(obj_id, data))
def sync_kv_get_edge_ids(shard, edge_def, from_id, after=None, first=None): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_edge_ids(edge_def, from_id, after, first))
def sync_kv_get_index_entries(shard, index, index_value): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_index_entries(index, index_value))
def sync_kv_insert_edge(shard, edge_def, from_id, to_id, data=None): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_insert_edge(edge_def, from_id, to_id, data))
def insert_object(kvetch, type_id, data): param_check(kvetch, Kvetch, 'kvetch') return execute_gen(kvetch.gen_insert_object(type_id, data))
def sync_kv_insert_index_entry(shard, index_name, index_value, target_id): param_check(shard, KvetchShard, 'shard') return execute_gen( shard.gen_insert_index_entry(index_name, index_value, target_id))
def sync_kv_get_objects_of_type(shard, type_id, after=None, first=None): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_objects_of_type(type_id, after, first))
def get_objects_of_type(self, type_id, after=None, first=None): return execute_gen(self.shard.gen_objects_of_type(type_id, after, first))
def insert_edge(self, edge_def, from_id, to_id, data=None): return execute_gen(self.shard.gen_insert_edge(edge_def, from_id, to_id, data))
def delete_object(self, obj_id): return execute_gen(self.shard.gen_delete_object(obj_id))
def insert_index_entry(self, index_name, index_value, target_id): return execute_gen(self.shard.gen_insert_index_entry(index_name, index_value, target_id))
def insert_object(self, new_id, type_id, data): return execute_gen(self.shard.gen_insert_object(new_id, type_id, data))
def sync_kv_delete_object(shard, obj_id): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_delete_object(obj_id))
def sync_kv_insert_object(shard, new_id, type_id, data): param_check(shard, KvetchShard, 'shard') return execute_gen(shard.gen_insert_object(new_id, type_id, data))
for i in range(0, reps): new_id = uuid4() ids.append(new_id) data = {'num': i, 'str': 'some string' + str(i)} await shard.gen_insert_object(new_id, 1000, data) end = timer() db_insert_microseconds = (end - start) * 1000 * 1000 print('%s microseconds per db insert' % (db_insert_microseconds/reps)) return ids async def gen_time_get_things(ids): conn = MagnusConn.get_unittest_conn() shard = KvetchDbShard( pool=KvetchDbSingleConnectionPool(conn), ) start = timer() for obj_id in ids: obj = await shard.gen_object(obj_id) end = timer() reps = len(ids) db_get_microseconds = (end - start) * 1000 * 1000 print('%s microseconds per db get' % (db_get_microseconds/reps)) time_set(1000) time_get(1000) time_mget(1000) ids = execute_gen(gen_time_insert_things(100)) execute_gen(gen_time_get_things(ids))
async def create_worksheet_entries(): records = process_alpha( '/Users/schrockn/data/hcris/2552-10/2016/hosp_alpha2552_10_2016_long.csv' ) records.extend( process_nmrc( '/Users/schrockn/data/hcris/2552-10/2016/hosp_nmrc2552_10_2016_long.csv' )) await build_worksheets(records) # from timeit import default_timer as timer # start = timer() # end = timer() if __name__ == '__main__': init_kvetch() # ~/data/hcris/providers/addr2552_10.csv execute_gen( create_providers( '/Users/schrockn/data/hcris/providers/addr2552_10.csv')) # ~/data/hcris/2552-10/2016/hosp_rpt2552_10_2016.csv execute_gen( create_reports( '/Users/schrockn/data/hcris/2552-10/2016/hosp_rpt2552_10_2016.csv') ) # /Users/schrockn/data/hcris/2552-10/2016/hosp_nmrc2552_10_2016_long.csv # execute_gen(create_nmrc('/Users/schrockn/data/hcris/2552-10/2016/hosp_nmrc2552_10_2016_long.csv')) execute_gen(create_worksheet_entries())