Exemple #1
0
def test_parse_pes_events(current_actor_context):
    with open(os.path.join(CUR_DIR, 'files/sample01.json')) as f:
        events = parse_pes_events(f.read())
    assert len(events) == 2
    assert events[0].action == Action.SPLIT
    assert events[0].in_pkgs == {'original': 'repo'}
    assert events[0].out_pkgs == {'split01': 'repo', 'split02': 'repo'}
    assert events[1].action == Action.REMOVED
    assert events[1].in_pkgs == {'removed': 'repo'}
    assert events[1].out_pkgs == {}
def test_parse_pes_events(current_actor_context):
    """
    Tests whether all events are correctly parsed from the provided string with the JSON data.
    """
    with open(os.path.join(CUR_DIR, 'files/sample01.json')) as f:
        events = parse_pes_events(f.read())
    assert len(events) == 2
    assert events[0].action == Action.SPLIT
    assert events[0].in_pkgs == {'original': 'repo'}
    assert events[0].out_pkgs == {'split01': 'repo', 'split02': 'repo'}
    assert events[1].action == Action.REMOVED
    assert events[1].in_pkgs == {'removed': 'repo'}
    assert events[1].out_pkgs == {}
def test_parse_pes_events_with_modulestreams(current_actor_context):
    """
    Tests whether all events are correctly parsed from the provided string with the JSON data.
    """
    with open(os.path.join(CUR_DIR, 'files/sample04.json')) as f:
        events = parse_pes_events(f.read())
    assert len(events) == 5
    Expected = namedtuple('Expected', 'action,in_pkgs,out_pkgs')
    expected = [
        Expected(
            action=Action.SPLIT,
            in_pkgs={Package('original', 'repo', ('module', 'stream_in'))},
            out_pkgs={
                Package('split01', 'repo', None),
                Package('split02', 'repo', None)
            }),
        Expected(action=Action.SPLIT,
                 in_pkgs={Package('original', 'repo', None)},
                 out_pkgs={
                     Package('split01', 'repo', ('module', 'stream_out')),
                     Package('split02', 'repo', ('module', 'stream_out'))
                 }),
        Expected(action=Action.REMOVED,
                 in_pkgs={Package('removed', 'repo', None)},
                 out_pkgs=set()),
        Expected(
            action=Action.RENAMED,
            in_pkgs={Package('modularized', 'repo', ('module', 'stream_in'))},
            out_pkgs={Package('demodularized', 'repo', None)}),
        Expected(action=Action.RENAMED,
                 in_pkgs={Package('modularized', 'repo', None)},
                 out_pkgs={Package('demodularized', 'repo', None)}),
    ]

    for event in events:
        for idx, expectation in enumerate(list(expected)):
            if expectation.action == event.action and expectation.in_pkgs == event.in_pkgs:
                assert event.out_pkgs == expectation.out_pkgs
                expected.pop(idx)
                break
        if not expected:
            break
    assert not expected