示例#1
0
    def test_scope(self):
        """
            Test setting scope both on Column initialization and
            after column initialization.
        """
        col = Column(scope='parent').test.field
        self.assertEqual(col._scope, 'parent')
        self.assertEqual(col.get_scope(), 'parent')

        col.set_scope('normal')
        self.assertEqual(col._scope, 'normal')
        self.assertEqual(col.get_scope(), 'normal')
示例#2
0
    def test_copy(self):
        """
            Tests the creation of a copy
        """
        mock_owner = MockOwner()
        col = Column(scope='parent').test.field
        col.set_alias('cheese')
        col.owner = mock_owner

        col_copy = copy.copy(col)

        self.assertNotEqual(id(col), id(col_copy))
        self.assertEqual(id(col._owner), id(col_copy._owner))
示例#3
0
    def test_deepcopy(self):
        """
            Tests the creation of a deep copy (which is the same as
            a copy for column objects, due to the use of weakref.proxy()
            for the owner).
        """
        mock_owner = MockOwner()
        col = Column(scope='parent').test.field
        col.set_alias('cheese')
        col.owner = mock_owner

        col_copy = copy.copy(col)

        self.assertNotEqual(id(col), id(col_copy))
        self.assertEqual(id(col._owner), id(col_copy._owner))
示例#4
0
    def test_hash(self):
        """
            Checks to see if the has of two objects with the same options
            hash to the same value, and that two column objects that do
            not share all of the same objects hash to different values
        """
        mock_owner = MockOwner()
        col = Column(scope='parent').test.field
        col.set_alias('fish')
        col.owner = mock_owner

        mock_owner2 = MockOwner()
        col2 = Column(scope='parent').test.field
        col2.set_alias('fish')
        col2.owner = mock_owner2

        self.assertEqual(hash(col), hash(col2))

        mock_owner3 = MockOwner()
        col3 = Column(scope='parent').test.field
        col3.set_alias('cheese')
        col3.owner = mock_owner

        self.assertNotEqual(hash(col), hash(col3))