Changeset 1640

Show
Ignore:
Timestamp:
08/14/06 15:22:58 (3 years ago)
Author:
benjamin.ragan-kelley
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ipython/sandbox/minrk/clienttimer.py

    r1586 r1640  
    2222    rc.connect() 
    2323     
    24     n = len(rc.status('all').keys()) 
     24    n = len(rc.getIDs()) 
    2525    if timer is None: 
    2626        timer = max(sqrt(n)/6, 1) 
  • ipython/sandbox/minrk/test_controllerclient.py

    r1632 r1640  
    2626def main(port, host): 
    2727    rc = RemoteController((host, port)) 
    28     id =  rc.statusAll().keys() 
     28    ids = rc.getIDs() 
    2929    hide = StringIO.StringIO('')     
    30     print "Running on %i engines" %len(id
    31     if not id
     30    print "Running on %i engines" %len(ids
     31    if not ids
    3232        print "need some engines!" 
    3333        return 
     
    3535    print "Testing push/pull" 
    3636    try: 
    37         assert rc.push(0, a=5) 
    38         assert rc.pull(0, 'a') == 5 
    39         assert not rc.push(0) 
    40         assert not rc.push([], a=5) 
    41         assert rc.push([0], b='asdf', c=[1,2]) 
    42         assert rc.pull([0], 'b', 'c') == ['asdf', [1,2]] 
    43         assert rc.push([0,1], c=[1,2,3]) 
    44         assert rc.pull([0,1], 'c') == ([1,2,3],[1,2,3]) 
    45         assert rc.push([0,0], a=14) 
    46         assert rc.pull([0,0,0], 'a') == (14,14,14) 
    47         assert rc.push([0,1], a=1, b=2, c=3) 
    48         assert rc.pull([0,1],'a','b','c') == [(1,1),(2,2),(3,3)] 
     37        assert rc.push(0, a=5),"assert rc.push(0, a=5)" 
     38        assert rc.pull(0, 'a') == 5,"assert rc.pull(0, 'a') == 5" 
     39        assert not rc.push(0),"assert not rc.push(0)" 
     40        assert not rc.push([], a=5),"assert not rc.push([], a=5)" 
     41        assert rc.push([0], b='asdf', c=[1,2]),"assert rc.push([0], b='asdf', c=[1,2])" 
     42        assert rc.pull([0], 'b', 'c') == ['asdf', [1,2]],"assert rc.pull([0], 'b', 'c') == ['asdf', [1,2]]" 
     43        assert rc.pushAll(c=[1,2,3]),"assert rc.pushAll(c=[1,2,3])" 
     44        assert rc.pullAll('c') == ([1,2,3],)*len(ids),"assert rc.pullAll('c') == ([1,2,3],)*len(ids)" 
     45        assert rc.push([0,0], a=14),"assert rc.push([0,0], a=14)" 
     46        assert rc.pull([0,0,0], 'a') == (14,14,14),"assert rc.pull([0,0,0], 'a') == (14,14,14)" 
     47        assert rc.pushAll(a=1, b=2, c=3),"assert rc.pushAll(a=1, b=2, c=3)" 
     48        assert rc.pullAll('a','b','c') == [(1,)*len(ids),(2,)*len(ids),(3,)*len(ids)],"assert rc.pullAll('a','b','c') == [(1,1)*len(ids),(2,2)*len(ids),(3,3)*len(ids)]" 
    4949        q={'a':5} 
    50         assert rc.push(id, q=q) 
    51         assert rc.pull(id,'q') == (q,)*len(id) 
     50        assert rc.push(ids, q=q),"assert rc.push(ids, q=q)" 
     51        assert rc.pull(ids,'q') == (q,)*len(ids) or len(ids) is 1,"assert rc.pull(ids,'q') == (q,)*len(ids)" 
    5252        rc['z'] = 'test' 
    5353        rc[1]['t'] = [1,2,3] 
     
    6060       print "push/pull OK" 
    6161     
    62     print "Testing pushAll
     62    print "Testing push/pullNamespace
    6363    try: 
    64         assert rc.pushAll(a=5) 
    65         assert rc.pushAll(a=5, b=6, c='asdf') 
    66         try: 
    67             rc.pushAll(0, a=5) 
    68         except: 
    69             pass 
    70         else: 
    71             raise 'Should have raised' 
     64        ns = {'a':5} 
     65        assert rc.pushAll(**ns),"assert rc.pushAll(a=5)" 
     66        assert rc.pullNamespace(0, 'a') == ns,"assert rc.pullNamespace(0, 'a') == {'a':5}" 
     67        assert rc.pullNamespaceAll('a') == [ns]*len(ids),"assert rc.pullNamespaceAll('a') == [{'a':5}]*len(ids)" 
     68        ns['b'] = 6 
     69        ns['cd'] = 'asdf' 
     70        assert rc.pushAll(**ns),"assert rc.pushAll(a=5, b=6, cd='asdf')" 
     71        assert rc.pullNamespace(0, *ns.keys()) == ns,"assert rc.pullNamespace(0, *ns.keys()) == ns" 
     72        assert rc.pullNamespaceAll(*ns.keys()) == [ns]*len(ids),"assert rc.pullNamespaceAll(*ns.keys) == [ns]*len(ids)" 
    7273    except Exception, e: 
    73         print "pushAll FAIL: ", e 
     74        print "pushAll/pullNamespace FAIL: ", e 
    7475    else: 
    75         print "pushAll OK" 
     76        print "pushAll/pullNamespace OK" 
    7677         
    7778    print "Testing execute" 
    7879    try: 
    79         assert rc.execute(0, 'a') 
    80         assert rc.execute([0,1], 'print a') 
    81         assert rc.execute('all', 'b-3') 
    82         assert not rc.execute(0, '') 
    83         assert not rc.execute([], 'locals') 
     80        assert rc.execute(0, 'a'),"assert rc.execute(0, 'a')" 
     81        assert rc.executeAll('print a'),"assert rc.execute([0,1], 'print a')" 
     82        assert rc.execute('all', 'b-3'),"assert rc.execute('all', 'b-3')" 
     83        assert not rc.execute(0, ''),"assert not rc.execute(0, '')" 
     84        assert not rc.execute([], 'locals'),"assert not rc.execute([], 'locals')" 
    8485        s = sys.stdout 
    8586        sys.stdout = hide 
    86         assert rc.execute(0, 'a', block=True) 
    87         assert rc.execute([0,1], 'print a', block=True) 
    88         assert rc.execute('all', 'b-3', block=True) 
    89         assert not rc.execute(0, '', block=True) 
    90         assert not rc.execute([], 'locals', block=True) 
     87        assert rc.execute(0, 'a', block=True),"assert rc.execute(0, 'a', block=True)" 
     88        assert rc.execute([0,0], 'print a', block=True),"assert rc.execute([0,1], 'print a', block=True)" 
     89        assert rc.execute('all', 'b-3', block=True),"assert rc.execute('all', 'b-3', block=True)" 
     90        assert not rc.execute(0, '', block=True),"assert not rc.execute(0, '', block=True)" 
     91        assert not rc.execute([], 'locals', block=True),"assert not rc.execute([], 'locals', block=True)" 
    9192        sys.stdout = s 
    9293    except Exception, e: 
     
    9596        print "execute OK" 
    9697     
     98    # print "Testing status/reset" 
     99    # try: 
     100    #     pass 
     101    # except Exception, e: 
     102    #     print 'status/reset FAIL: ', e 
     103    # else: 
     104    #     print 'status/reset OK' 
    97105 
    98106