Example #1
0
def test_add():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.add(5)

    assert sourcer.value == 7
Example #2
0
def test_subtract():
    sourcer = EventSourcer()

    sourcer.subtract(2)
    sourcer.subtract(5)

    assert sourcer.value == -7
Example #3
0
def test_bulk_undo_overstep():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.subtract(5)
    sourcer.bulk_undo(5)

    assert sourcer.value == 0
Example #4
0
def test_bulk_undo():
    sourcer = EventSourcer()

    sourcer.add(1)
    sourcer.add(2)
    sourcer.add(3)
    sourcer.add(4)
    sourcer.add(5)
    sourcer.bulk_undo(3)

    assert sourcer.value == 3
Example #5
0
def test_undo():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.add(2)
    sourcer.add(2)
    sourcer.add(2)
    sourcer.undo()

    assert sourcer.value == 6
Example #6
0
def test_pow():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.pow(3)
    
    assert sourcer.value == 8
Example #7
0
def test_multiply():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.multiply(2)
    
    assert sourcer.value == 4
Example #8
0
def test_divide_big_divisor():
    sourcer = EventSourcer()

    sourcer.add(2)
    sourcer.divide(3)
    
    assert sourcer.value == 0
Example #9
0
def test_divide_even():
    sourcer = EventSourcer()

    sourcer.add(6)
    sourcer.divide(2)
    
    assert sourcer.value == 3
Example #10
0
def test_divide_odd():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.divide(2)
    
    assert sourcer.value == 2
Example #11
0
def test_pow_float():
    sourcer = EventSourcer()

    sourcer.add(4)
    sourcer.pow(0.5)
    
    assert sourcer.value == 2
    assert isinstance(sourcer.value, int)
Example #12
0
def test_redo_with_no_redo_step():
    sourcer = EventSourcer()

    sourcer.redo()

    assert sourcer.value == 0
Example #13
0
def test_undo_no_actions():
    sourcer = EventSourcer()

    sourcer.undo()

    assert sourcer.value == 0
Example #14
0
def test_bulk_redo():
    sourcer = EventSourcer()

    sourcer.add(1)
    sourcer.add(1)
    sourcer.add(1)
    sourcer.add(1)
    sourcer.add(1)
    sourcer.undo()
    sourcer.undo()
    sourcer.undo()
    sourcer.undo()

    sourcer.bulk_redo(4)

    assert sourcer.value == 5
Example #15
0
def test_redo():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.undo()
    sourcer.undo()
    sourcer.add(1)
    sourcer.redo()

    assert sourcer.value == 11
Example #16
0
def test_bulk_redo_overstep():
    sourcer = EventSourcer()

    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.add(5)
    sourcer.undo()
    sourcer.undo()
    sourcer.undo()
    sourcer.bulk_redo(5)

    assert sourcer.value == 25