def setup(self): smf = ShipModelFactory() self.ship = smf.manufacture("ship") self.original_parts = self.ship.parts drydock = Drydock(0, 1, 0, 1, self.ship, FakeFactory()) drydock.save_all() self.parts_after_save = self.ship.parts
def setup(self): self.target = SpacialIndex() smf = ShipModelFactory() self.ship = smf.manufacture('ship') self.target.init_model_into_2d_space_index(self.ship) self.ship2 = smf.manufacture('ship') self.target.init_model_into_2d_space_index(self.ship2) self.pairs = self.target.all_pairs_deduplicated({self.ship, self.ship2})
def setup(self): smf = ShipModelFactory() smf.add_configuration({ "name": "test_ship", "parts": [{ "position": [1.6, 0, 0.4], "rotation": [0, 0, 0], "name": "shield" }, { "position": [0, 0, 0], "rotation": [0, 0, 0], "name": "cockpit" }, { "position": [-1.48, 0, 0.4], "rotation": [0, 0, 0], "name": "shield" }] }) self.ship = smf.manufacture("test_ship") self.drydock = Drydock(0, 1000, 0, 1000, self.ship, view_factory=FakeFactory()) self.ship = self.drydock.ship self.target_item: DockableItem = [ item for item in self.drydock.items if item.model.name == "shield" ][0] self.target_item.held = True self.target_item._highlight = True self.target = self.target_item.model self.ship_rebuild_callback = MagicMock() self.ship.observe(self.ship_rebuild_callback, "rebuild") self.target_callback = MagicMock() self.target.observe(self.target_callback, "move") self.connections = list(self.ship._connections) self.shield_connections = [ c for c in self.connections if all(p.name == "shield" for p in c._ship_parts) ]
def __init__(self, event_loop): Observable.__init__(self) self._event_loop = event_loop self.smf = ShipModelFactory() self.amf = AsteroidModelFactory() self.has_exit = True self.rnd = random.seed() self._new_model_callbacks = set() self._dead_model_callbacks = set() self.models = {} self._time_spent = 0 self._scheduled_taks = {} self._players = {} self._collision_check_models = set() self._spacial_index = SpacialIndex()
class TestConfigControlsMenu(object): smf = ShipModelFactory() def setup(self): self.ship_model = self.smf.manufacture("ship") def cancel_func(): pass from engine.views import meshfactory fake_mesh_factory = FakeFactory() meshfactory.get_factory = lambda: fake_mesh_factory self.target = menus.ControlConfigMenu.manufacture_for_ship_model( self.ship_model, cancel_func, 0, 0) def test_menu_has_two_button(self): assert len(self.target.buttons) >= 2
def setup(self): self.target = SpacialIndex() smf = ShipModelFactory() self.ship = smf.manufacture('ship') self.target.init_model_into_2d_space_index(self.ship)
from engine.models.factories import ShipModelFactory factory = ShipModelFactory() class TestShipModelFactory(object): def setup(self): self.model = factory.manufacture("ship") def test_bounding_box_is_the_sum_of_all_parts(self): assert self.model.bounding_box.left < -0.5 assert self.model.bounding_box.right > 0.5 def test_bouding_box_sub_polygons_are_not_all_the_same(self): assert 1 != len(set([(list(p.lines)[0].x1, list(p.lines)[0].y1) for p in self.model.bounding_box._polygons]))
def setup(self): self.ship = ShipModelFactory().manufacture("ship") self.targets = self.ship._connections
from itertools import chain import pytest from engine.models.factories import ShipModelFactory, AsteroidModelFactory from engine.physics.line import Line factory = ShipModelFactory() amf = AsteroidModelFactory() class TestLine(object): def setup(self): self.target = Line([(0, 0), (10, 10)]) def test_set_position_rotation(self): self.target.set_position_rotation(10, 0, 0) assert self.target.x1 == 10 assert self.target.x2 == 20 assert self.target.y1 == 0 assert self.target.y2 == 10 def test_freeze(self): self.target.set_position_rotation(10, 0, 0) self.target.freeze() assert self.target.x1 == 10 assert self.target.x2 == 20 assert self.target.y1 == 0 assert self.target.y2 == 10