def test_lookup(): with _setup(TEST_RUN), DB as db: for key, value in dict( path=TEST_RUN, description=DESCRIPTION, command=COMMAND).items(): assert_in(value, lookup.string(runs=db.get([TEST_RUN]), key=key)) with assert_raises(SystemExit): run_main('lookup', 'x', TEST_RUN)
def test_move_dirs(): with _setup('sub/test_run'): move('sub', 'new_dir') # src is dir -> change src to dest and bring children yield check_move, 'sub/test_run', 'new_dir/test_run' with _setup('sub/sub/test_run'): move('sub/sub', 'sub/new_dir') # src is dir -> change src to dest and bring children yield check_move, 'sub/sub/test_run', 'sub/new_dir/test_run' with _setup('sub/test_run'): move('sub', 'new_dir') # src is dir and dest is dir -> move src into dest and bring children yield check_move, 'sub/test_run', 'new_dir/test_run' with _setup('sub/test_run'), _setup('sub2/test_run2'): move('sub', 'sub2') # src is dir and dest is dir -> move src into dest and bring children yield check_move, 'sub/test_run', 'sub2/sub/test_run' with _setup('sub/sub1/test_run'): move('sub/sub1/', '.') # src is dir and dest is dir -> move src into dest and bring children yield check_move, 'sub/sub1/test_run', 'sub1/test_run' with _setup('sub/test_run1'), _setup('sub/test_run2'): move('sub/%', 'new') # src is multi -> for each node match, move head into dest yield check_move, 'sub/test_run1', 'new/test_run1' yield check_move, 'sub/test_run2', 'new/test_run2' with _setup('sub/sub1/test_run1'), _setup('sub/sub2/test_run2'): move('sub/%', 'new') # src is multi -> for each node match, move head into dest yield check_move, 'sub/sub1/test_run1', 'new/sub1/test_run1' yield check_move, 'sub/sub2/test_run2', 'new/sub2/test_run2' with _setup('sub1/test_run1'), _setup('sub2/test_run2'): move('sub1/test_run1', 'sub2') # dest is dir -> move node into dest yield check_move, 'sub1/test_run1', 'sub2/test_run1' with _setup('sub1/sub1/test_run1'), _setup('sub2/test_run2'): move('sub1/sub1', 'sub2') # dest is dir and src is dir -> move node into dest yield check_move, 'sub1/sub1/test_run1', 'sub2/sub1/test_run1' with _setup('test_run1', flags=['--run1']), _setup('test_run2', flags=['run2']): move('test_run1', 'test_run2') # dest is run -> overwrite dest yield check_move, 'test_run1', 'test_run2' with DB as db: assert_in('--run1', lookup.string(runs=db.get(['test_run2']), key='command')) with _setup('test'): move('test', 'test/test2') # move into self; this is a problem for movedir yield check_move, 'test', 'test/test2'
def check_db(path, flags): with DB as db: # check known values runs = db.get(path + '%') assert_in(DESCRIPTION, lookup.string( runs=runs, key='description', )) assert_in(COMMAND, lookup.string( runs=runs, key='command', )) assert_in(path, lookup.string( runs=runs, key='path', )) for flag in flags: assert_in(flag, lookup.string( runs=runs, key='command', ))
def test_chdesc(): with _setup(TEST_RUN), DB as db: description = 'new description' run_main('change-description', TEST_RUN, description) assert_in(description, lookup.string(runs=db.get([TEST_RUN]), key='description'))