def test_mdrive():
    # Testing valid drive to tonnage match
    spacecraft = Spacecraft(100)
    spacecraft.add_mdrive(MDrive("A"))
    assert spacecraft.thrust == 2

    # Testing invalid drive to tonnage match
    spacecraft = Spacecraft(100)
    spacecraft.add_mdrive(MDrive("J"))
    assert spacecraft.thrust == 0

    # Testing valid larger drive to tonnage match
    spacecraft = Spacecraft(2000)
    spacecraft.add_mdrive(MDrive("U"))
    assert spacecraft.thrust == 4
def test_jdrive():
    # Testing valid drive to tonnage match
    spacecraft = Spacecraft(200)
    spacecraft.add_jdrive(JDrive("A"))
    assert spacecraft.jump == 1

    # Testing invalid drive to tonnage match
    spacecraft = Spacecraft(100)
    spacecraft.add_jdrive(JDrive("J"))
    assert spacecraft.jump == 0

    # Testing valid larger drive to tonnage match
    spacecraft = Spacecraft(1600)
    spacecraft.add_jdrive(JDrive("Z"))
    assert spacecraft.jump == 5
def test_remove():
    """
    Tests removing a piece of armour from the ship
    """
    ship = Spacecraft(200)

    armour = Armour("Titanium Steel")
    assert armour.tl == 7
    assert armour.protection == 2
    assert armour.hull_amount == 0.05
    assert armour.cost_by_hull_percentage == 0.05

    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 8.4

    ship.remove_armour(armour)
    assert ship.get_remaining_cargo() == 200
    assert ship.armour_total == 0
    assert ship.get_total_cost() == 8

    # testing for removing a non-attached armour piece
    ship.remove_armour(armour)
    assert ship.get_remaining_cargo() == 200
    assert ship.armour_total == 0
    assert ship.get_total_cost() == 8
Beispiel #4
0
def test_lowest_drive():
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100

    drive = ship.get_lowest_drive()
    assert drive == "A"
def test_swap():
    """
    Tests swapping the tonnage on the ship and making sure the ship's values
    translate accordingly
    """
    ship = Spacecraft(200)

    armour = Armour("Titanium Steel")
    assert armour.tl == 7
    assert armour.protection == 2
    assert armour.hull_amount == 0.05
    assert armour.cost_by_hull_percentage == 0.05

    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 8.4

    ship.set_tonnage(100)
    assert ship.get_remaining_cargo() == 95
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 2.1

    ship.remove_armour(armour)
    assert ship.get_remaining_cargo() == 100
    assert ship.armour_total == 0
    assert ship.get_total_cost() == 2
Beispiel #6
0
def test_config_functionality():
    """
    Tests functionality for adding configurations and swapping tonnage values
    :return:
    """
    ship = Spacecraft(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
    assert ship.tonnage == 100
    assert ship.hull_type.type == "Standard"

    config = Config("Streamlined")
    ship.edit_hull_config(config)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.2
    assert ship.tonnage == 100
    assert ship.hull_type.type == "Streamlined"

    config = Config("Standard")
    ship.edit_hull_config(config)
    ship.set_tonnage(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
    assert ship.tonnage == 100
    assert ship.hull_type.type == "Standard"
Beispiel #7
0
def test_adding():
    """
    Tests adding both types of drives to a ship
    """
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2
    assert ship.mdrive is None
    assert ship.jdrive is None

    ship.add_jdrive(JDrive("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 90
    assert ship.get_total_cost() == 12
    assert ship.jdrive is not None

    ship.add_mdrive(MDrive("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 88
    assert ship.get_total_cost() == 16
    assert ship.mdrive is not None

    ship.add_pplant(PPlant("A"))
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 84
    assert ship.get_total_cost() == 24
    assert ship.pplant is not None
Beispiel #8
0
def test_incompatible_drive():
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.mdrive is None

    ship.add_mdrive(MDrive("Z"))
    assert ship.mdrive is None
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
Beispiel #10
0
def test_fuel_scoop():
    ship = Spacecraft(100)
    assert ship.hull_type.type == "Standard"
    assert ship.fuel_scoop is False
    assert ship.get_total_cost() == 2.0

    ship.modify_fuel_scoops()
    assert ship.hull_type.type == "Standard"
    assert ship.fuel_scoop is True
    assert ship.get_total_cost() == 3.0
Beispiel #11
0
def test_fuel_add():
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100
    assert ship.fuel_max == 0

    ship.set_fuel(50)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 50
    assert ship.fuel_max == 50
def test_normal_add():
    ship = Spacecraft(100)

    # Adding and removing a Fuel Processor
    fuel_processor = Misc("Fuel Processors", 1)
    ship.modify_misc(fuel_processor)
    assert ship.get_remaining_cargo() == 99
    assert ship.get_total_cost() == 2.05
    ship.remove_misc("Fuel Processors")
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 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
Beispiel #14
0
def test_spacecraft_init():
    """
    Tests the initialization of a new Spacecraft (hull)
    """
    spacecraft = Spacecraft(1000)
    assert spacecraft.tonnage == 1000
    assert spacecraft.get_remaining_cargo() == 1000
    assert spacecraft.hull_hp == 1000 // 50
    assert spacecraft.structure_hp == 1000 // 50
    assert spacecraft.fuel_max == 0
    assert spacecraft.armour_total == 0
    assert spacecraft.hull_type.type == "Standard"
    assert spacecraft.hull_designation == "B"
def test_repair_drones():
    ship = Spacecraft(100)

    # Adding repair drones and checking dynamic costs
    repair_drones = Misc("Repair Drones", 1)
    ship.modify_misc(repair_drones)
    assert ship.get_remaining_cargo() == 99.0
    assert ship.get_total_cost() == 2.2

    # Removing the drone
    ship.remove_misc("Repair Drones")
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0
def test_escape_pods():
    ship = Spacecraft(100)

    # Adding a stateroom then an escape pod
    stateroom = Misc("Staterooms", 1)
    ship.modify_misc(stateroom)
    assert ship.get_remaining_cargo() == 96
    assert ship.get_total_cost() == 2.5

    escape_pod = Misc("Escape Pods", 1)
    ship.modify_misc(escape_pod)
    assert ship.get_remaining_cargo() == 95.5
    assert ship.get_total_cost() == 2.6
Beispiel #17
0
def test_pplant_validity():
    # Tests 4 cases for pplant validities
    ship = Spacecraft(100)
    assert ship.tonnage == 100
    assert ship.get_remaining_cargo() == 100

    ship.add_jdrive(JDrive("B"))
    ship.add_pplant(PPlant("B"))

    assert ship.check_pplant_validity() == True

    ship.add_pplant(PPlant("A"))
    assert ship.check_pplant_validity() == "Error: PPlant under J-Drive. A < B"

    ship = Spacecraft(100)
    ship.add_mdrive(MDrive("B"))
    ship.add_pplant(PPlant("A"))
    assert ship.check_pplant_validity() == "Error: PPlant under M-Drive. A < B"

    ship.add_jdrive(JDrive("B"))
    assert ship.check_pplant_validity(
    ) == "Error: PPlant under max M/J-Drive. A < B"
def test_swap():
    ship = Spacecraft(100)

    # Adding repair drones and checking dynamic costs
    repair_drones = Misc("Repair Drones", 1)
    ship.modify_misc(repair_drones)
    assert ship.get_remaining_cargo() == 99.0
    assert ship.get_total_cost() == 2.2

    # Swapping for more drones
    repair_drones = Misc("Repair Drones", 2)
    ship.modify_misc(repair_drones)
    assert ship.get_remaining_cargo() == 98.0
    assert ship.get_total_cost() == 2.4
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
Beispiel #20
0
def test_adding():
    # Tests adding hull objects to the ship
    spacecraft = Spacecraft(100)
    reflec = Option("Reflec")
    stealth = Option("Stealth")

    spacecraft.modify_hull_option(reflec)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 12.0
    assert len(spacecraft.hull_options) == 1

    spacecraft.modify_hull_option(stealth)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 22.0
    assert len(spacecraft.hull_options) == 2
Beispiel #21
0
def test_removing():
    # Tests removing a screen object from the ship
    ship = Spacecraft(200)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0

    damper = Screen("Nuclear Damper")
    ship.modify_screen(damper)
    assert ship.get_remaining_cargo() == 150
    assert ship.get_total_cost() == 58.0

    new_damper = Screen("Nuclear Damper")
    ship.modify_screen(new_damper)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0
Beispiel #22
0
def test_removing():
    # Tests removing a hull object from the ship
    spacecraft = Spacecraft(100)
    reflec = Option("Reflec")

    spacecraft.modify_hull_option(reflec)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 12.0
    assert len(spacecraft.hull_options) == 1

    new_reflec = Option("Reflec")
    spacecraft.modify_hull_option(new_reflec)
    assert spacecraft.get_remaining_cargo() == 100
    assert spacecraft.get_total_cost() == 2.0
    assert len(spacecraft.hull_options) == 0
def test_add():
    """
    Tests adding a piece of armour to a ship
    """
    ship = Spacecraft(200)

    armour = Armour("Titanium Steel")
    assert armour.tl == 7
    assert armour.protection == 2
    assert armour.hull_amount == 0.05
    assert armour.cost_by_hull_percentage == 0.05

    ship.add_armour(armour)
    assert ship.get_remaining_cargo() == 190
    assert ship.armour_total == 2
    assert ship.get_total_cost() == 8.4
def test_add_replace():
    # Testing adding and replacing a sensor system
    ship = Spacecraft(100)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 2.0

    sensor = Sensor("Advanced")

    ship.add_sensors(sensor)
    assert ship.get_remaining_cargo() == 97
    assert ship.get_total_cost() == 4.0
    assert ship.sensors is not None

    sensor = Sensor("Basic Civilian")
    ship.add_sensors(sensor)
    assert ship.get_remaining_cargo() == 99
    assert ship.get_total_cost() == 2.05
Beispiel #25
0
def test_adding():
    # Tests adding each screen type
    damper = Screen("Nuclear Damper")
    meson = Screen("Meson Screen")
    extra = Screen("Nuclear Damper")

    ship = Spacecraft(200)
    assert ship.get_remaining_cargo() == 200
    assert ship.get_total_cost() == 8.0

    ship.modify_screen(damper)
    assert ship.get_remaining_cargo() == 150
    assert ship.get_total_cost() == 58.0

    ship.modify_screen(meson)
    assert ship.get_remaining_cargo() == 100
    assert ship.get_total_cost() == 118.0
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
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
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
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
Beispiel #30
0
def test_empty_ship():
    ship = Spacecraft(0)
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.jdrive is None

    ship.add_jdrive(JDrive("A"))
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.jdrive is None

    ship.add_mdrive(MDrive("A"))
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.mdrive is None

    ship.add_pplant(PPlant("A"))
    assert ship.tonnage == 0
    assert ship.get_remaining_cargo() == 0
    assert ship.pplant is None