Example #1
0
    '/ermrest/catalog/232/schema/S1/table/T1/referencedby/S2:T2',
    '/ermrest/catalog/232/schema/S1/table/T1/referencedby/T2/Cx,Cy,Cz',
    '/ermrest/catalog/232/schema/S1/table/T1/referencedby/T2/Cx,Cy,Cz/key',
    '/ermrest/catalog/232/schema/S1/table/T1/referencedby/T2/Cx,Cy,Cz/key/C1,C2,C3',
    '/ermrest/catalog/232/schema/S1/table/T1/reference',
    '/ermrest/catalog/232/schema/S1/table/T1/reference/S2:T2',
    '/ermrest/catalog/232/schema/S1/table/T1/reference/S2:T2/C1,C2,C3',
    '/ermrest/catalog/232/schema/S1/table/T1/reference/S2:T2/C1,C2,C3/foreignkey',
    '/ermrest/catalog/232/schema/S1/table/T1/reference/S2:T2/C1,C2,C3/foreignkey/Cx,Cy,Cz',
    '/ermrest/catalog/232/entity/S1:T1',
    '/ermrest/catalog/232/entity/S1:T1/C1/alias:=C2/N1,N2/(N1)/alias(C1,C2)=@(Cx,Cy)S2:T2/@=(C3,C4)S3:T3',
    '/ermrest/catalog/232/attribute/S1:T1/C1,C2,C3',
    '/ermrest/catalog/232/query/S1:T1/C1,C2,C3'
    ]:
    try:
        url_parse_func(url)
    except Exception, e:
        sys.stderr.write('got exception for: %s\n' % url)
        raise


# negative tests throwing ValueError

for url in [
    '/ermrest/catalog/232/schema/S1/table/T1/key/C1,C2,C3/referencedby/S2:T2:bad',
    '/ermrest/catalog/232/schema/S1/table/T1/foreignkey/Cx,Cy,Cz/reference/S2:T2:bad',
    '/ermrest/catalog/232/schema/S1/table/T1/referencedby/S2:T2:bad/Cx,Cy,Cz/key/C1,C2,C3',
    '/ermrest/catalog/232/schema/S1/table/T1/reference/S2:T2:bad'
    ]:
    got_error = False
    try:
    '/ermrest/catalog/1/entity/scan/slide',
    '/ermrest/catalog/1/entity/study/slide/scan',
    '/ermrest/catalog/1/entity/scan/slide/study',
    '/ermrest/catalog/1/entity/scan/slide/study/slide/scan',
    '/ermrest/catalog/1/entity/a:=scan/b:=slide/c:=study/d:=slide/e:=scan',
    '/ermrest/catalog/1/entity/a:=scan/b:=slide_id',
    '/ermrest/catalog/1/entity/a:=scan/slide/study/a:slide_id',
    '/ermrest/catalog/1/entity/study/slide:study_id',
    '/ermrest/catalog/1/entity/study/:microscopy:slide:study_id',
    '/ermrest/catalog/1/entity/study/microscopy:slide:study_id',
    '/ermrest/catalog/1/entity/a:=scan/b:=slide_id,slide_id',
    '/ermrest/catalog/1/entity/a:=scan/slide/study/a:slide_id,a:slide_id',
    '/ermrest/catalog/1/entity/a:=scan/slide/study/slide:study_id,:microscopy:slide:study_id',
    '/ermrest/catalog/1/entity/study/id=1/comment=experiment%20A/slide/scan'
    ]:
    
    ast = url_parse_func(url)
    
    epath = ast.resolve(m)
    
    print '----------------------------'
    print url
    print str(epath)
    print epath.sql_get()
    content_type = ['application/json', 'text/csv', dict, tuple][0]
    output_file = [None, sys.stdout][0]
    #epath.get_to_file(conn, sys.stdout, content_type)
    print ''.join([ str(r) + '\n' for r in epath.get(conn, content_type, output_file) ])
    print ''

Example #3
0
        '/ermrest/catalog/1/entity/scan/slide',
        '/ermrest/catalog/1/entity/study/slide/scan',
        '/ermrest/catalog/1/entity/scan/slide/study',
        '/ermrest/catalog/1/entity/scan/slide/study/slide/scan',
        '/ermrest/catalog/1/entity/a:=scan/b:=slide/c:=study/d:=slide/e:=scan',
        '/ermrest/catalog/1/entity/a:=scan/b:=slide_id',
        '/ermrest/catalog/1/entity/a:=scan/slide/study/a:slide_id',
        '/ermrest/catalog/1/entity/study/slide:study_id',
        '/ermrest/catalog/1/entity/study/:microscopy:slide:study_id',
        '/ermrest/catalog/1/entity/study/microscopy:slide:study_id',
        '/ermrest/catalog/1/entity/a:=scan/b:=slide_id,slide_id',
        '/ermrest/catalog/1/entity/a:=scan/slide/study/a:slide_id,a:slide_id',
        '/ermrest/catalog/1/entity/a:=scan/slide/study/slide:study_id,:microscopy:slide:study_id',
        '/ermrest/catalog/1/entity/study/id=1/comment=experiment%20A/slide/scan'
]:

    ast = url_parse_func(url)

    epath = ast.resolve(m)

    print '----------------------------'
    print url
    print str(epath)
    print epath.sql_get()
    content_type = ['application/json', 'text/csv', dict, tuple][0]
    output_file = [None, sys.stdout][0]
    #epath.get_to_file(conn, sys.stdout, content_type)
    print ''.join(
        [str(r) + '\n' for r in epath.get(conn, content_type, output_file)])
    print ''