コード例 #1
0
def test_adding():
    # Initializing a ship and adding a computer system to it, checking for correct values
    ship = Spacecraft(100)
    assert ship.get_total_cost() == 2.0

    computer = Computer("Model 3")
    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0
    assert ship.check_rating_ratio() == 15
コード例 #2
0
def test_adding():
    # Testing adding a single piece of software to a ship
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1
コード例 #3
0
def test_swapping():
    # Test swapping between computer models
    ship = Spacecraft(100)
    assert ship.get_total_cost() == 2.0

    computer = Computer("Model 3")
    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0
    assert ship.check_rating_ratio() == 15

    new = Computer("Model 4")
    ship.add_computer(new)
    assert ship.get_total_cost() == 7.0
    assert ship.check_rating_ratio() == 20
コード例 #4
0
def test_remove():
    # Tests the available rating check
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    # Adding the level 2 jump
    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1

    # Removing
    ship.remove_software("Jump Control")
    assert ship.get_total_cost() == 4.0
    assert len(ship.software) == 0
コード例 #5
0
def test_check_ratio():
    # Tests the available rating check
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    # Check before addition
    assert ship.check_rating_ratio() == 15

    # Adding the level 2 jump
    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1

    # Check after addition
    assert ship.check_rating_ratio() == 5
コード例 #6
0
def test_downgrading():
    # Testing adding a single piece of software to a ship
    ship = Spacecraft(100)
    computer = Computer("Model 3")
    jump = Software("Jump Control", 2)
    downgrade = Software("Jump Control", 1)

    ship.add_computer(computer)
    assert ship.get_total_cost() == 4.0

    # Adding the level 2 jump
    ship.modify_software(jump)
    assert ship.get_total_cost() == 4.2
    assert len(ship.software) == 1

    # Downgrading to the level 1 jump
    ship.modify_software(downgrade)
    assert ship.get_total_cost() == 4.1
    assert len(ship.software) == 1