Exemplo n.º 1
0
def test_replaceVariables ():
    # Test expandPath with simple custom path variable
    pathvars = {
        'x' : 'test'
    }
    pathname = os.path.join('/' , '${x}', 'ait-orbits')
    expected = [ os.path.join('/', pathvars['x'], 'ait-orbits') ]
    assert cfg.replaceVariables(pathname, pathvars=pathvars) == expected

    # Test expandPath with more complex path variable with multiple
    # permutations
    pathvars = {
        'x' : 'x1',
        'y' : ['y1', 'y2'],
        'z' : ['z1', 'z2']
    }
    pathname = os.path.join('/' , '${x}', '${y}', '${z}','ait-orbits')
    expected = [
        os.path.join('/', pathvars['x'], pathvars['y'][0],
                     pathvars['z'][0], 'ait-orbits'),
        os.path.join('/', pathvars['x'], pathvars['y'][0],
                     pathvars['z'][1], 'ait-orbits'),
        os.path.join('/', pathvars['x'], pathvars['y'][1],
                     pathvars['z'][0], 'ait-orbits'),
        os.path.join('/', pathvars['x'], pathvars['y'][1],
                     pathvars['z'][1], 'ait-orbits')
    ]
    assert sorted(cfg.replaceVariables(pathname, pathvars=pathvars)) == sorted(expected)
Exemplo n.º 2
0
def test_replaceVariables_strftime_addday ():
    # Test replaceVariables with strftime directives
    pathname = os.path.join('/', '%Y', '%Y-%j', 'ait-orbits')

    expected = [ os.path.join('/', 
        time.strftime('%Y', time.gmtime()),
        time.strftime('%Y-%j', time.gmtime()),
        'ait-orbits') ]

    assert sorted(cfg.replaceVariables(pathname)) == sorted(expected)