示例#1
0
 def test_getParent_old_tid(self):
     self.bar._p_activate()
     tid = self.bar._p_serial
     state = GenericState(self.bar, {'__parent__': self.foo}, tid)
     # previously we mistakenly thought we ought to rewind the parent
     # object to the old state, but that's (a) unnecessary --
     # ZodbObjectState.getParentState() takes care of that -- and (b)
     # very very dangerous: https://launchpad.net/zodbbrowser/+bug/487243
     self.assertEquals(state.getParent().__name__, 'new')
示例#2
0
 def test_getParent_old_tid(self):
     self.bar._p_activate()
     tid = self.bar._p_serial
     state = GenericState(self.bar, {'__parent__': self.foo}, tid)
     # previously we mistakenly thought we ought to rewind the parent
     # object to the old state, but that's (a) unnecessary --
     # ZodbObjectState.getParentState() takes care of that -- and (b)
     # very very dangerous: https://launchpad.net/zodbbrowser/+bug/487243
     self.assertEqual(state.getParent().__name__, 'new')
示例#3
0
 def test_asDict(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEqual(state.asDict(), {'foo': 1, 'bar': 2, 'baz': 3})
示例#4
0
 def test_listItems(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEqual(state.listItems(), None)
示例#5
0
 def test_listAttributes(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEqual(sorted(state.listAttributes()),
                      [('bar', 2), ('baz', 3), ('foo', 1)])
示例#6
0
 def test_getParent_with_parent(self):
     parent = Frob()
     state = GenericState(Frob(), {'__parent__': parent}, None)
     self.assertEqual(state.getParent(), parent)
示例#7
0
 def test_getParent_no_parent(self):
     self.assertEqual(GenericState(Frob(), {}, None).getParent(), None)
示例#8
0
 def test_getName_with_name(self):
     state = GenericState(Frob(), {'__name__': 'xyzzy'}, None)
     self.assertEqual(state.getName(), 'xyzzy')
示例#9
0
 def test_listItems(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEquals(state.listItems(), None)
示例#10
0
 def test_getError(self):
     self.assertEqual(GenericState(Frob(), {}, None).getError(), None)
示例#11
0
 def test_interface_compliance(self):
     verifyObject(IStateInterpreter, GenericState(Frob(), {}, None))
示例#12
0
 def test_getParent_with_parent(self):
     parent = Frob()
     state = GenericState(Frob(), {'__parent__': parent}, None)
     self.assertEquals(state.getParent(), parent)
示例#13
0
 def test_getName_with_name(self):
     state = GenericState(Frob(), {'__name__': 'xyzzy'}, None)
     self.assertEquals(state.getName(), 'xyzzy')
示例#14
0
 def test_getParent_no_tid(self):
     state = GenericState(self.bar, {'__parent__': self.foo}, None)
     self.assertEquals(state.getParent().__name__, 'new')
示例#15
0
 def test_asDict(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEquals(state.asDict(), {'foo': 1, 'bar': 2, 'baz': 3})
示例#16
0
 def test_getParent_no_tid(self):
     state = GenericState(self.bar, {'__parent__': self.foo}, None)
     self.assertEqual(state.getParent().__name__, 'new')
示例#17
0
 def test_getName_no_name(self):
     self.assertEqual(GenericState(Frob(), {}, None).getName(), None)
示例#18
0
 def test_listAttributes(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEquals(sorted(state.listAttributes()),
                       [('bar', 2), ('baz', 3), ('foo', 1)])