Beispiel #1
0
class DescribeMissile(unittest.TestCase):

    def setUp(self):
        # doc = FreeCAD.newDocument()
        # self.missile = doc.addObject(
        #     "Part::FeaturePython", "Missile")
        self.missile = DocumentMock()
        self.missile = Missile(self.missile)
        self.fp = FeaturePythonMock()

    def test_should_only_update_if_live_update_property_is_true(self):
        self.fp.live_update = True
        self.missile.execute = Mock(return_value=True)
        self.missile.onChanged(self.fp, 'body_length')
        self.assertTrue(self.missile.execute.called)
        self.fp.live_update = False
        self.missile.execute = Mock(return_value=True)
        self.missile.onChanged(self.fp, 'body_length')
        self.assertFalse(self.missile.execute.called)
Beispiel #2
0
class DescribeMissile(unittest.TestCase):

    def setUp(self):
        self.missile = DocumentMock()
        self.missile = Missile(self.missile)
        self.fp = FeaturePythonMock()

    def test_should_be_init_with_4_children(self):
        children_length = len(self.missile.children)
        self.assertEqual(children_length, 4)

    def test_missile_should_get_properies_from_all_children(self):
        child_properies_list = [
            child.Proxy.properties for child in self.missile.children]
        for child_properies in child_properies_list:
            for prop in child_properies:
                self.assertTrue(prop in self.missile.properties)

    def test_missile_should_update_when_value_ischanged(self):
        self.fp.missile_radius = 5
        self.missile.execute = Mock(return_value=True)
        self.missile.onChanged(self.fp, 'missile_radius')
        self.assertTrue(self.missile.execute.called)