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')
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')
def test_asDict(self): state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None) self.assertEqual(state.asDict(), {'foo': 1, 'bar': 2, 'baz': 3})
def test_listItems(self): state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None) self.assertEqual(state.listItems(), None)
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)])
def test_getParent_with_parent(self): parent = Frob() state = GenericState(Frob(), {'__parent__': parent}, None) self.assertEqual(state.getParent(), parent)
def test_getParent_no_parent(self): self.assertEqual(GenericState(Frob(), {}, None).getParent(), None)
def test_getName_with_name(self): state = GenericState(Frob(), {'__name__': 'xyzzy'}, None) self.assertEqual(state.getName(), 'xyzzy')
def test_listItems(self): state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None) self.assertEquals(state.listItems(), None)
def test_getError(self): self.assertEqual(GenericState(Frob(), {}, None).getError(), None)
def test_interface_compliance(self): verifyObject(IStateInterpreter, GenericState(Frob(), {}, None))
def test_getParent_with_parent(self): parent = Frob() state = GenericState(Frob(), {'__parent__': parent}, None) self.assertEquals(state.getParent(), parent)
def test_getName_with_name(self): state = GenericState(Frob(), {'__name__': 'xyzzy'}, None) self.assertEquals(state.getName(), 'xyzzy')
def test_getParent_no_tid(self): state = GenericState(self.bar, {'__parent__': self.foo}, None) self.assertEquals(state.getParent().__name__, 'new')
def test_asDict(self): state = GenericState(Frob(), {'foo': 1, 'bar': 2, 'baz': 3}, None) self.assertEquals(state.asDict(), {'foo': 1, 'bar': 2, 'baz': 3})
def test_getParent_no_tid(self): state = GenericState(self.bar, {'__parent__': self.foo}, None) self.assertEqual(state.getParent().__name__, 'new')
def test_getName_no_name(self): self.assertEqual(GenericState(Frob(), {}, None).getName(), None)
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)])