예제 #1
0
def test_equivalent(next_component, library):
    '''
    Assert a true refinement relation and verifies it
    '''
    library.add(next_component)

    mapping = LibraryPortMapping(
        [next_component.contract, next_component.contract])
    mapping.add(next_component.contract.a, next_component.contract.a)
    mapping.add(next_component.contract.b, next_component.contract.b)

    with pytest.raises(EquivalentComponentError):
        next_component.add_refinement_assertion(next_component, mapping)
예제 #2
0
def test_not_in_lib(future_component, next_component, library):
    '''
    Assert a true refinement relation and verifies it
    '''
    library.add(next_component)

    mapping = LibraryPortMapping(
        [next_component.contract, future_component.contract])
    mapping.add(next_component.contract.a, future_component.contract.a)
    mapping.add(next_component.contract.b, future_component.contract.x)

    with pytest.raises(ValueError):
        next_component.add_refinement_assertion(future_component, mapping)
예제 #3
0
def test_false_refinement(future_component, next_component, library):
    '''
    Assert a true refinement relation and verifies it
    '''
    library.add(future_component)
    library.add(next_component)

    mapping = LibraryPortMapping(
        [next_component.contract, future_component.contract])
    mapping.add(next_component.contract.a, future_component.contract.a)
    mapping.add(next_component.contract.b, future_component.contract.x)

    with pytest.raises(NotARefinementError):
        future_component.add_refinement_assertion(next_component, mapping)
예제 #4
0
def test_refinement(future_component, next_component, library):
    '''
    Assert a true refinement relation and verifies it
    '''
    library.add(future_component)
    library.add(next_component)

    mapping = LibraryPortMapping(
        [next_component.contract, future_component.contract])
    mapping.add(next_component.contract.a, future_component.contract.a)
    mapping.add(next_component.contract.b, future_component.contract.x)

    try:
        next_component.add_refinement_assertion(future_component, mapping)
    except:
        assert False
    else:
        assert True
예제 #5
0
def populated_library(comp_a, comp_b, comp_ab, comp_meta, library):
    '''
    returns a populated library
    '''
    library.add(comp_a)
    library.add(comp_b)
    library.add(comp_ab)
    library.add(comp_meta)

    #add refinement assertion
    mapping = LibraryPortMapping([comp_ab, comp_meta])
    mapping.add(comp_ab.a, comp_meta.a)
    mapping.add(comp_ab.b, comp_meta.b)

    #comp_ab.add_refinement_assertion(comp_meta, mapping)

    library.verify_library()

    return library
예제 #6
0
def test_populate(comp_a, comp_b, comp_ab, comp_meta, library):
    '''
    test library population as of fixture 'populate_library'
    '''
    library.add(comp_a)
    library.add(comp_b)
    library.add(comp_ab)
    library.add(comp_meta)

    #add refinement assertion
    mapping = LibraryPortMapping([comp_ab, comp_meta])
    mapping.add(comp_ab.a, comp_meta.a)
    mapping.add(comp_ab.b1, comp_meta.b)

    LOG.debug(comp_ab.contract)

    comp_ab.add_refinement_assertion(comp_meta, mapping)

    library.verify_library()
    assert True
예제 #7
0
def minimal_library(library, library_component, false_component,
                    next_component, future_component):
    '''
    Returns a library with 4 elements, already in a hierarchy.
    Elements are TrueContract, FalseContract, FutureContract, NextContract
    '''

    library.add(library_component)
    library.add(false_component)
    library.add(next_component)
    library.add(future_component)

    mapping = LibraryPortMapping(
        [next_component.contract, future_component.contract])
    mapping.add(next_component.contract.a, future_component.contract.a)
    mapping.add(next_component.contract.b, future_component.contract.x)

    next_component.add_refinement_assertion(future_component, mapping)

    #everything refines the TrueContract
    mapping_1 = LibraryPortMapping([false_component, library_component])
    mapping_1.add(library_component.a, false_component.c)
    mapping_1.add(library_component.b, false_component.d)
    false_component.add_refinement_assertion(library_component, mapping_1)

    mapping_2 = LibraryPortMapping([next_component, library_component])
    mapping_2.add(next_component.a, library_component.a)
    mapping_2.add(next_component.b, library_component.b)
    next_component.add_refinement_assertion(library_component, mapping_2)

    mapping_3 = LibraryPortMapping([future_component, library_component])
    mapping_3.add(future_component.a, library_component.a)
    mapping_3.add(future_component.x, library_component.b)
    future_component.add_refinement_assertion(library_component, mapping_3)

    #FalseContract refines everything
    mapping_4 = LibraryPortMapping([false_component, next_component])
    mapping_4.add(false_component.c, next_component.a)
    mapping_4.add(false_component.d, next_component.b)
    false_component.add_refinement_assertion(next_component, mapping_4)

    mapping_5 = LibraryPortMapping([false_component, future_component])
    mapping_5.add(false_component.c, future_component.a)
    mapping_5.add(false_component.d, future_component.x)
    false_component.add_refinement_assertion(future_component, mapping_5)

    return library