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
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
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
def test_init(): # Test ship rating check before computer addition ship = Spacecraft(100) assert ship.check_rating_ratio() == 0 # Initializing a computer and adding a mod to it, testing the end values computer = Computer("Model 5") assert computer.rating == 25 assert computer.tl == 13 assert computer.get_cost() == 10.0 computer.modify_addon("Jump Control Spec") assert computer.rating == 25 assert computer.get_cost() == 15.0 computer.modify_addon("Hardened System") assert computer.get_cost() == 20.0