def test_none_to_item_type_failure(self): fit = Fit() item = Stance(self.mktype().id) # Action with self.assertRaises(TypeError): fit.ship = item # Verification self.assertIsNone(fit.ship) # Check that item which failed to be added can be assigned to other # field fit.stance = item # Cleanup self.assert_item_buffers_empty(item) self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_fit_none_to_non_charge(self): fit = Fit() module = ModuleHigh(self.mktype().id, state=State.active, charge=None) non_charge = Stance(self.mktype().id) fit.modules.high.append(module) # Action with self.assertRaises(TypeError): module.charge = non_charge # Verification self.assertIsNone(module.charge) fit.stance = non_charge # Cleanup self.assert_item_buffers_empty(module) self.assert_item_buffers_empty(non_charge) self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_item_to_item_type_failure(self): fit = Fit() item1 = Ship(self.mktype().id) item2 = Stance(self.mktype().id) fit.ship = item1 # Action with self.assertRaises(TypeError): fit.ship = item2 # Verification self.assertIs(fit.ship, item1) fit.stance = item2 # Cleanup self.assert_item_buffers_empty(item1) self.assert_item_buffers_empty(item2) self.assert_solsys_buffers_empty(fit.solar_system) self.assert_log_entries(0)
def test_detached_module_charge_to_non_charge(self): fit_other = Fit() module = ModuleHigh(self.mktype().id, state=State.active, charge=None) charge = Charge(self.mktype().id) non_charge = Stance(self.mktype().id) module.charge = charge # Action with self.assertRaises(TypeError): module.charge = non_charge # Verification self.assertIs(module.charge, charge) fit_other.stance = non_charge # Cleanup self.assert_item_buffers_empty(module) self.assert_item_buffers_empty(charge) self.assert_item_buffers_empty(non_charge) self.assert_solsys_buffers_empty(fit_other.solar_system) self.assert_log_entries(0)