コード例 #1
0
    def test_Clear(self):
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.createPrimWithAttribute('/root')
            self.createPrimWithAttribute('/root/A')
            self.createPrimWithAttribute('/root/A/B')
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [Sdf.Path(x) for x in ['/root']])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self._stage.GetSessionLayer().Clear()
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [Sdf.Path(x) for x in ['/root']])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.createPrimWithAttribute('/root')
            self.createPrimWithAttribute('/root/A')
            self.createPrimWithAttribute('/root/A/B')
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [Sdf.Path(x) for x in ['/root']])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self._stage.GetSessionLayer().Clear()
            self.createPrimWithAttribute('/root')
            self.createPrimWithAttribute('/root/A')
            self.createPrimWithAttribute('/root/A/B')
            ### effectively no change
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [])
コード例 #2
0
 def test_SameScopedTransaction(self):
     self.assertEqual(self._opened, 0)
     self.assertEqual(self._closed, 0)
     ## Open notice should be triggered
     with transaction.ScopedTransaction(self._stage,
                                        self._stage.GetSessionLayer()):
         self.assertEqual(self._opened, 1)
         self.assertEqual(self._closed, 0)
         ## Opening same transaction is allowed, but should not trigger notices
         with transaction.ScopedTransaction(self._stage,
                                            self._stage.GetSessionLayer()):
             self.assertEqual(self._opened, 1)
             self.assertEqual(self._closed, 0)
         ## Close notices should not be emitted until last close
         self.assertEqual(self._opened, 1)
         self.assertEqual(self._closed, 0)
     ## Close notice should be triggered
     self.assertEqual(self._opened, 1)
     self.assertEqual(self._closed, 1)
コード例 #3
0
 def test_DifferentScopedTransaction(self):
     self.assertEqual(self._opened, 0)
     self.assertEqual(self._closed, 0)
     ## Open notice should be triggered
     with transaction.ScopedTransaction(self._stage,
                                        self._stage.GetSessionLayer()):
         self.assertEqual(self._opened, 1)
         self.assertEqual(self._closed, 0)
         ## Open notice should be triggered as it targets different layer
         with transaction.ScopedTransaction(self._stage,
                                            self._stage.GetRootLayer()):
             self.assertEqual(self._opened, 2)
             self.assertEqual(self._closed, 0)
         ## Close notice should be triggered
         self.assertEqual(self._opened, 2)
         self.assertEqual(self._closed, 1)
     ## Close notice should be triggered
     self.assertEqual(self._opened, 2)
     self.assertEqual(self._closed, 2)
コード例 #4
0
    def test_Hierarchy(self):
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.createPrimWithAttribute('/root')
            self.createPrimWithAttribute('/root/A')
            self.createPrimWithAttribute('/root/A/C')
            self.createPrimWithAttribute('/root/A/D')
            self.createPrimWithAttribute('/root/B')
            self.createPrimWithAttribute('/root/B/E')
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [Sdf.Path(x) for x in ['/root']])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.changePrimAttribute('/root', 2)
            self.changePrimAttribute('/root/A/D', 2)
        self.assertItemsEqual(
            self._changed,
            [Sdf.Path(x) for x in ['/root.prop', '/root/A/D.prop']])
        self.assertItemsEqual(self._resynced, [])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.changePrimAttribute('/root/B', 2)
            self.changePrimAttribute('/root/A/C', 2)
            self.changePrimAttribute('/root/A/C', 1)  ## effectively no change
        self.assertItemsEqual(self._changed,
                              [Sdf.Path(x) for x in ['/root/B.prop']])
        self.assertItemsEqual(self._resynced, [])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.createPrimWithAttribute('/root/B/F')
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced,
                              [Sdf.Path(x) for x in ['/root/B/F']])
コード例 #5
0
    def test_Changes(self):
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.createPrimWithAttribute('/A')
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [Sdf.Path(x) for x in ['/A']])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.changePrimAttribute('/A', 2)
        self.assertItemsEqual(self._changed,
                              [Sdf.Path(x) for x in ['/A.prop']])
        self.assertItemsEqual(self._resynced, [])

        with transaction.ScopedTransaction(self._stage,
                                           self._stage.GetSessionLayer()):
            self.changePrimAttribute('/A', 4)
            self.changePrimAttribute('/A', 2)  ## effectively no change
        self.assertItemsEqual(self._changed, [])
        self.assertItemsEqual(self._resynced, [])