'Test that we can create a new object of a different type.'

def testObjectUpgrade(self):

    path = 'C.0123456789abcdef'
    with aff4.FACTORY.Create(path, aff4_grr.VFSGRRClient, token=self.token) as fd:
        fd.Set(fd.Schema.HOSTNAME('blah'))
        original_fd = fd
    with aff4.FACTORY.Open(path, aff4_grr.VFSGRRClient, token=self.token) as fd:
        self.assertEqual(fd.Get(fd.Schema.HOSTNAME), 'blah')
        self.assertEqual(fd.Get(fd.Schema.TYPE), 'VFSGRRClient')
    with aff4.FACTORY.Create(path, aff4.AFF4MemoryStream, token=self.token) as fd:
        fd.Write('hello')
    with aff4.FACTORY.Open(path, aff4.AFF4MemoryStream, token=self.token) as fd:
        self.assertEqual(fd.Read(100), 'hello')
        self.assertEqual(fd.Get(fd.Schema.TYPE), 'AFF4MemoryStream')
        self.assertRaises(aff4.BadGetAttributeError, getattr, fd.Schema, 'HOSTNAME')
    with aff4.FACTORY.Open(path, token=self.token) as fd:
        self.assertEqual(fd.Read(100), 'hello')
        self.assertEqual(fd.Get(original_fd.Schema.HOSTNAME), 'blah')
