예제 #1
0
def test_add_erosion__level_3__returns_False():
    m = MaterialComponent('PLASTIC', 'MELT')
    m.erosion['MELT'] = 3
    assert m.add_erosion("MELT") is False
    assert m.erosion['MELT'] == 3
예제 #2
0
def test_add_erosion__0_to_1():
    m = MaterialComponent('PLASTIC', 'MELT')
    assert m.erosion['MELT'] == 0
    m.add_erosion("MELT")
    assert m.erosion['MELT'] == 1
예제 #3
0
def test_init__is_Component():
    m = MaterialComponent('PLASTIC', 'MELT')
    assert isinstance(m, Component)
예제 #4
0
def test_melt__meltable_returns_True():
    m = MaterialComponent('PLASTIC', 'MELT')
    assert m.melt()
예제 #5
0
def test_melt__nonmeltable_returns_False():
    m = MaterialComponent('WOOD', 'BURN')
    assert m.melt() is False
예제 #6
0
def test_burn__nonburnable_returns_False():
    m = MaterialComponent('IRON', 'RUST')
    assert m.burn() is False
예제 #7
0
def test_rot__rottable_calls_add_erosion(mocker):
    mocker.patch('components.material.MaterialComponent.add_erosion')
    m = MaterialComponent('WOOD', 'ROT')
    m.rot()
    m.add_erosion.assert_called_once()
예제 #8
0
def test_corrode__noncorrodable_returns_False():
    m = MaterialComponent('WOOD', 'BURN')
    assert m.corrode() is False
예제 #9
0
def test_init__vulnerabilities__tuple():
    m = MaterialComponent('PLASTIC', 'MELT', 'BURN')
    assert m.erosion == {'MELT': 0, 'BURN': 0}
예제 #10
0
def test_corrode__corrodable_returns_True():
    m = MaterialComponent('IRON', 'RUST', 'CORRODE')
    assert m.corrode()
예제 #11
0
def test_corrode__corrodable_calls_add_erosion(mocker):
    mocker.patch('components.material.MaterialComponent.add_erosion')
    m = MaterialComponent('IRON', 'RUST')  # No corrode, means always calls add_erosion
    m.corrode()
    m.add_erosion.assert_called_once()
예제 #12
0
def test_rust__nonrustable_returns_False():
    m = MaterialComponent('WOOD', 'BURN')
    assert m.rust() is False
예제 #13
0
def test_rust__rustable_calls_add_erosion(mocker):
    mocker.patch('components.material.MaterialComponent.add_erosion')
    m = MaterialComponent('IRON', 'RUST')
    m.rust()
    m.add_erosion.assert_called_once()
예제 #14
0
def test_rust__rustable_returns_True():
    m = MaterialComponent('IRON', 'RUST')
    assert m.rust()
예제 #15
0
def test_burn__burnable_returns_True():
    m = MaterialComponent('WOOD', 'BURN')
    assert m.burn()
예제 #16
0
def test_init__invalid_material():
    with pytest.raises(ValueError):
        MaterialComponent('RUG', 'melt')
예제 #17
0
def test_burn__burnable_calls_add_erosion(mocker):
    mocker.patch('components.material.MaterialComponent.add_erosion')
    m = MaterialComponent('WOOD', 'BURN')
    m.burn()
    m.add_erosion.assert_called_once()
예제 #18
0
def test_init__invalid_vulnerabilities():
    with pytest.raises(ValueError):
        MaterialComponent('CLOTH', 'LAUGH')
예제 #19
0
def test_rot__rottable_returns_True():
    m = MaterialComponent('WOOD', 'ROT')
    assert m.rot()
예제 #20
0
def test_add_erosion__success_returns_True():
    m = MaterialComponent('PLASTIC', 'MELT')
    assert m.add_erosion("MELT")
예제 #21
0
def test_rot__nonrottable_returns_False():
    m = MaterialComponent('IRON', 'RUST')
    assert m.rot() is False
예제 #22
0
def test_add_erosion__fail_returns_False():
    m = MaterialComponent('PLASTIC', 'MELT')
    assert m.add_erosion("ROT") is False
예제 #23
0
def test_melt__meltable_calls_add_erosion(mocker):
    mocker.patch('components.material.MaterialComponent.add_erosion')
    m = MaterialComponent('PLASTIC', 'MELT')
    m.melt()
    m.add_erosion.assert_called_once()
예제 #24
0
def test_init__material():
    m = MaterialComponent('PLASTIC', 'MELT')
    assert m.material == 'PLASTIC'