Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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})
Exemplo n.º 4
0
 def test_listItems(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEqual(state.listItems(), None)
Exemplo n.º 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)])
Exemplo n.º 6
0
 def test_getParent_with_parent(self):
     parent = Frob()
     state = GenericState(Frob(), {'__parent__': parent}, None)
     self.assertEqual(state.getParent(), parent)
Exemplo n.º 7
0
 def test_getParent_no_parent(self):
     self.assertEqual(GenericState(Frob(), {}, None).getParent(), None)
Exemplo n.º 8
0
 def test_getName_with_name(self):
     state = GenericState(Frob(), {'__name__': 'xyzzy'}, None)
     self.assertEqual(state.getName(), 'xyzzy')
Exemplo n.º 9
0
 def test_listItems(self):
     state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None)
     self.assertEquals(state.listItems(), None)
Exemplo n.º 10
0
 def test_getError(self):
     self.assertEqual(GenericState(Frob(), {}, None).getError(), None)
Exemplo n.º 11
0
 def test_interface_compliance(self):
     verifyObject(IStateInterpreter, GenericState(Frob(), {}, None))
Exemplo n.º 12
0
 def test_getParent_with_parent(self):
     parent = Frob()
     state = GenericState(Frob(), {'__parent__': parent}, None)
     self.assertEquals(state.getParent(), parent)
Exemplo n.º 13
0
 def test_getName_with_name(self):
     state = GenericState(Frob(), {'__name__': 'xyzzy'}, None)
     self.assertEquals(state.getName(), 'xyzzy')
Exemplo n.º 14
0
 def test_getParent_no_tid(self):
     state = GenericState(self.bar, {'__parent__': self.foo}, None)
     self.assertEquals(state.getParent().__name__, 'new')
Exemplo n.º 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})
Exemplo n.º 16
0
 def test_getParent_no_tid(self):
     state = GenericState(self.bar, {'__parent__': self.foo}, None)
     self.assertEqual(state.getParent().__name__, 'new')
Exemplo n.º 17
0
 def test_getName_no_name(self):
     self.assertEqual(GenericState(Frob(), {}, None).getName(), None)
Exemplo n.º 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)])