def test_drop_conflicting_release_events():
    """
    Tests whether correct events are dropped from conflicting release events.
    From conflicting events only the one with highest target release should be kept.
    """

    conflict1a = Event(1, Action.PRESENT, {Package('pkg1', 'repo', None)},
                       set(), (7, 6), (8, 0), [])
    conflict1b = Event(2, Action.REPLACED, {Package('pkg1', 'repo', None)},
                       set(), (7, 6), (8, 2), [])
    conflict1c = Event(3, Action.REMOVED, {Package('pkg1', 'repo', None)},
                       set(), (7, 6), (8, 1), [])
    conflict2a = Event(4, Action.REMOVED, {Package('pkg2a', 'repo', None)},
                       set(), (7, 6), (8, 0), [])
    conflict2b = Event(5, Action.REPLACED, {Package('pkg2a', 'repo', None)},
                       {Package('pkg2b', 'repo', None)}, (7, 6), (8, 1), [])
    # two input packages
    conflict3a = Event(
        6, Action.MERGED,
        {Package('pkg3a', 'repo', None),
         Package('pkg3b', 'repo', None)}, {Package('pkg3c', 'repo', None)},
        (7, 6), (8, 0), [])
    conflict3b = Event(
        7, Action.MERGED,
        {Package('pkg3a', 'repo', None),
         Package('pkg3b', 'repo', None)}, {Package('pkg3d', 'repo', None)},
        (7, 6), (8, 1), [])
    # these two can't be chained, don't remove anything
    okay1a = Event(8, Action.REPLACED, {Package('pkg4a', 'repo', None)},
                   {Package('pkg4b', 'repo', None)}, (7, 6), (8, 0), [])
    okay1b = Event(9, Action.REPLACED, {Package('pkg4b', 'repo', None)},
                   {Package('pkg4c', 'repo', None)}, (8, 0), (8, 1), [])

    events = [
        conflict1a, conflict1b, conflict1c, conflict2a, conflict2b, conflict3a,
        conflict3b, okay1a, okay1b
    ]
    drop_conflicting_release_events(events)

    for event in [conflict1b, conflict2b, conflict3b, okay1a, okay1b]:
        assert event in events
    for event in [conflict1a, conflict1c, conflict2a, conflict3a]:
        assert event not in events
Exemple #2
0
def test_drop_conflicting_release_events():
    conflict1a = Event(1, Action.PRESENT, {'pkg1': 'repo'}, {}, (7, 6), (8, 0), [])
    conflict1b = Event(2, Action.REPLACED, {'pkg1': 'repo'}, {}, (7, 6), (8, 2), [])
    conflict1c = Event(3, Action.REMOVED, {'pkg1': 'repo'}, {}, (7, 6), (8, 1), [])
    conflict2a = Event(4, Action.REMOVED, {'pkg2a': 'repo'}, {}, (7, 6), (8, 0), [])
    conflict2b = Event(5, Action.REPLACED, {'pkg2a': 'repo'}, {'pkg2b': 'repo'}, (7, 6), (8, 1), [])
    # two input packages
    conflict3a = Event(6, Action.MERGED, {'pkg3a': 'repo', 'pkg3b': 'repo'}, {'pkg3c': 'repo'}, (7, 6), (8, 0), [])
    conflict3b = Event(7, Action.MERGED, {'pkg3a': 'repo', 'pkg3b': 'repo'}, {'pkg3d': 'repo'}, (7, 6), (8, 1), [])
    # these two can't be chained, don't remove anything
    okay1a = Event(8, Action.REPLACED, {'pkg4a': 'repo'}, {'pkg4b': 'repo'}, (7, 6), (8, 0), [])
    okay1b = Event(9, Action.REPLACED, {'pkg4b': 'repo'}, {'pkg4c': 'repo'}, (8, 0), (8, 1), [])

    events = [conflict1a, conflict1b, conflict1c, conflict2a, conflict2b, conflict3a, conflict3b, okay1a, okay1b]
    drop_conflicting_release_events(events)

    for event in [conflict1b, conflict2b, conflict3b, okay1a, okay1b]:
        assert event in events
    for event in [conflict1a, conflict1c, conflict2a, conflict3a]:
        assert event not in events