Exemple #1
0
 def test_other_charge(self):
     influence_source = ChargeHolder(
         self.ch.type_(type_id=1,
                       effects=(self.effect, ),
                       attributes={self.src_attr.id: 20}))
     self.fit.items.add(influence_source)
     item = self.ch.type_(type_id=2, attributes={self.tgt_attr.id: 100})
     influence_target1 = ContainerHolder(item)
     influence_source.container = influence_target1
     influence_target1.charge = influence_source
     self.fit.items.add(influence_target1)
     self.assertNotAlmostEqual(
         influence_target1.attributes[self.tgt_attr.id], 100)
     self.fit.items.remove(influence_target1)
     influence_target2 = ContainerHolder(item)
     influence_target1.charge = None
     influence_source.container = influence_target2
     influence_target2.charge = influence_source
     self.fit.items.add(influence_target2)
     self.assertNotAlmostEqual(
         influence_target2.attributes[self.tgt_attr.id], 100)
     self.fit.items.remove(influence_target2)
     influence_source.container = None
     influence_target2.charge = None
     self.fit.items.remove(influence_source)
     self.assertEqual(len(self.log), 0)
     self.assert_link_buffers_empty(self.fit)
Exemple #2
0
 def test_self(self):
     # Check that source holder isn't modified
     influence_source = ContainerHolder(self.ch.type_(
         type_id=1, effects=(self.effect,), attributes={self.tgt_attr.id: 100, self.src_attr.id: 20}))
     self.fit.items.add(influence_source)
     influence_target = ChargeHolder(self.ch.type_(type_id=2, attributes={self.tgt_attr.id: 100}))
     influence_source.charge = influence_target
     influence_target.container = influence_source
     self.fit.items.add(influence_target)
     self.assertAlmostEqual(influence_source.attributes[self.tgt_attr.id], 100)
     self.fit.items.remove(influence_target)
     influence_source.charge = None
     influence_target.container = None
     self.fit.items.remove(influence_source)
     self.assertEqual(len(self.log), 0)
     self.assert_link_buffers_empty(self.fit)
Exemple #3
0
 def test_other_domain_charge(self):
     influence_source = ChargeHolder(
         self.ch.type_(type_id=1, effects=(self.effect,), attributes={self.src_attr.id: 20}))
     self.fit.items.add(influence_source)
     influence_target = ContainerHolder(self.ch.type_(type_id=2, attributes={self.tgt_attr.id: 100}))
     influence_source.container = influence_target
     influence_target.charge = influence_source
     self.fit.items.add(influence_target)
     self.assertNotAlmostEqual(influence_target.attributes[self.tgt_attr.id], 100)
     self.fit.items.remove(influence_source)
     influence_source.container = None
     influence_target.charge = None
     self.assertAlmostEqual(influence_target.attributes[self.tgt_attr.id], 100)
     self.fit.items.remove(influence_target)
     self.assertEqual(len(self.log), 0)
     self.assert_link_buffers_empty(self.fit)
Exemple #4
0
 def test_self(self):
     # Check that source holder isn't modified
     influence_source = ContainerHolder(
         self.ch.type_(type_id=1,
                       effects=(self.effect, ),
                       attributes={
                           self.tgt_attr.id: 100,
                           self.src_attr.id: 20
                       }))
     self.fit.items.add(influence_source)
     influence_target = ChargeHolder(
         self.ch.type_(type_id=2, attributes={self.tgt_attr.id: 100}))
     influence_source.charge = influence_target
     influence_target.container = influence_source
     self.fit.items.add(influence_target)
     self.assertAlmostEqual(influence_source.attributes[self.tgt_attr.id],
                            100)
     self.fit.items.remove(influence_target)
     influence_source.charge = None
     influence_target.container = None
     self.fit.items.remove(influence_source)
     self.assertEqual(len(self.log), 0)
     self.assert_link_buffers_empty(self.fit)
Exemple #5
0
 def test_other_holder(self):
     # Here we check some "random" holder, w/o linking holders
     influence_source = ContainerHolder(
         self.ch.type_(type_id=1,
                       effects=(self.effect, ),
                       attributes={self.src_attr.id: 20}))
     self.fit.items.add(influence_source)
     influence_target = IndependentItem(
         self.ch.type_(type_id=2, attributes={self.tgt_attr.id: 100}))
     self.fit.items.add(influence_target)
     self.assertAlmostEqual(influence_target.attributes[self.tgt_attr.id],
                            100)
     self.fit.items.remove(influence_source)
     self.fit.items.remove(influence_target)
     self.assertEqual(len(self.log), 0)
     self.assert_link_buffers_empty(self.fit)