Esempio n. 1
0
    def setUp(self):
        """setup the test
        """
        # link type
        self.test_link_type = Type(
            name='Test Link Type',
            code='testlink',
            target_entity_type=Link,
        )

        # create a couple of Link objects
        self.test_link1 = Link(
            name="Test Link 1",
            type=self.test_link_type,
            full_path="test_path",
            filename="test_filename",
        )

        self.test_link2 = Link(
            name="Test Link 2",
            type=self.test_link_type,
            full_path="test_path",
            filename="test_filename",
        )

        self.test_link3 = Link(
            name="Test Link 3",
            type=self.test_link_type,
            full_path="test_path",
            filename="test_filename",
        )

        self.test_link4 = Link(
            name="Test Link 4",
            type=self.test_link_type,
            full_path="test_path",
            filename="test_filename",
        )

        self.test_entity1 = Entity(
            name="Test Entity 1",
        )

        self.test_entity2 = Entity(
            name="Test Entity 2",
        )

        self.test_links = [
            self.test_link1,
            self.test_link2,
            self.test_link3,
            self.test_link4,
        ]

        self.test_foo_obj = RefMixFooClass(name="Ref Mixin Test")
    def test_ReferenceMixin_setup(self):
        """
        """
        a_ins = DeclRefMixA(name="ozgur")
        b_ins = DeclRefMixB(name="bozgur")

        new_link1 = Link(name="test link 1", full_path="none")
        new_link2 = Link(name="test link 2", full_path="no path")

        a_ins.references.append(new_link1)
        b_ins.references.append(new_link2)

        self.assertTrue(new_link1 in a_ins.references)
        self.assertTrue(new_link2 in b_ins.references)
Esempio n. 3
0
    def test_references_application_test(self):
        """testing an example of ReferenceMixin usage
        """
        class GreatEntity(SimpleEntity, ReferenceMixin):
            __tablename__ = 'GreatEntities'
            __mapper_args__ = {"polymorphic_identity": "GreatEntity"}
            ge_id = Column('id',
                           Integer,
                           ForeignKey('SimpleEntities.id'),
                           primary_key=True)

        my_ge = GreatEntity(name="Test")
        # we should have a references attribute right now
        var = my_ge.references

        image_link_type = Type(name='Image',
                               code='image',
                               target_entity_type="Link")
        new_link = Link(name="NewTestLink",
                        full_path="nopath",
                        filename="nofilename",
                        type=image_link_type)

        test_value = [new_link]

        my_ge.references = test_value

        assert my_ge.references == test_value