Exemplo n.º 1
0
def test_validity1():
    data="""
"F.easy_algo_family.yaml": | 
    description: desc
    interface: does.not_exist
"""
    d = dtu.dir_from_data(data)
    sources = [d]
    db = EasyAlgoDB(sources)
    
    # print format_db(db)
    
    family = db.get_family('F')
    assert family.valid == False
Exemplo n.º 2
0
def test_instance():
    data="""
"adder.easy_algo_family.yaml": | 
    description: desc
    interface: easy_algo_tests.validity.MyAdderInterface

"one.adder.yaml": |
    description: desc
    constructor: easy_algo_tests.validity.One
    parameters:

"not_sub.adder.yaml": |
    description: desc
    constructor: easy_algo_tests.validity.Two
    parameters:

"""
    d = dtu.dir_from_data(data)
    sources = [d]
    db = EasyAlgoDB(sources)
     
    print(format_db(db))
    
    family = db.get_family('adder')
    assert family.valid == True
    
    one = db.create_instance('adder', 'one')
    
    assert type(one).__name__ == 'One'

    try:
        db.create_instance('not_found', 'does_not_exist')
        raise Exception()
    except Exception as e:
        assert 'not find' in str(e), e
    
    try:
        db.create_instance('adder', 'does_not_exist')
        raise Exception()
    except Exception as e:
        assert 'not find' in str(e), e
        
    try:
        db.create_instance('adder', 'not_sub')
        raise Exception()
    except Exception as e:
        assert 'MyAdderInterface' in str(e)
Exemplo n.º 3
0
def testh1():
    data = """
    dir1:
       dir2:
           filename: |
                description: desc
                interface: line_detector2.LineDetectorInterface
                tests: {}

    """

    d = dtu.dir_from_data(data)

    #print locate_files(d, '*')

    from os.path import exists, join
    assert exists(join(d, 'dir1'))
    assert exists(join(d, 'dir1', 'dir2'))
    assert exists(join(d, 'dir1', 'dir2', 'filename'))
    f = join(d, 'dir1', 'dir2', 'filename')
    data = open(f).read()
    assert 'description' in data