'Test we can retrieve versions.'

def testGetVersions(self):

    client = aff4.FACTORY.Create(self.client_id, aff4_grr.VFSGRRClient, mode='w', token=self.token)
    client.Set(client.Schema.HOSTNAME('client1'))
    client.Flush()
    client.Set(client.Schema.HOSTNAME('client2'))
    client.Flush()
    vfsfile = aff4.FACTORY.Create(self.client_id, aff4_grr.VFSFile, mode='w', token=self.token)
    vfsfile.Flush()
    for diffs_only in [False, True]:
        ver_list = list(aff4.FACTORY.OpenDiscreteVersions(self.client_id, diffs_only=diffs_only, token=self.token))
        self.assertEqual(len(ver_list), 3)
        (v1, v2, v3) = ver_list
        self.assertTrue(isinstance(v1, aff4_grr.VFSGRRClient))
        self.assertTrue(isinstance(v2, aff4_grr.VFSGRRClient))
        self.assertTrue(isinstance(v3, aff4_grr.VFSFile))
        self.assertTrue((int(v1.Get(v1.Schema.TYPE).age) < int(v2.Get(v2.Schema.TYPE).age)))
        self.assertTrue((int(v2.Get(v1.Schema.TYPE).age) < int(v3.Get(v2.Schema.TYPE).age)))
        self.assertEqual(str(v1.Get(v1.Schema.HOSTNAME)), 'client1')
        self.assertEqual(str(v2.Get(v2.Schema.HOSTNAME)), 'client2')
        self.assertFalse(v3.Schema.HOSTNAME)
