'Test checking of non-existent attributes.'

def testGetBadAttribute(self):

    client = aff4.FACTORY.Create(self.client_id, aff4_grr.VFSGRRClient, mode='w', token=self.token)
    client.Set(client.Schema.HOSTNAME('client1'))
    client.Flush()
    self.assertEqual(client.Get(client.Schema.HOSTNAME), 'client1')
    self.assertRaises(aff4.BadGetAttributeError, getattr, client.Schema, 'DOESNOTEXIST')
    client = aff4.FACTORY.Create(self.client_id, aff4_grr.VFSGRRClient, mode='rw', token=self.token)
    self.assertEqual(client.Get(client.Schema.HOSTNAME), 'client1')
    self.assertRaises(aff4.BadGetAttributeError, getattr, client.Schema, 'DOESNOTEXIST')
    client = aff4.FACTORY.Open(self.client_id, aff4_grr.VFSGRRClient, mode='rw', token=self.token)
    self.assertEqual(client.Get(client.Schema.HOSTNAME), 'client1')
    self.assertRaises(aff4.BadGetAttributeError, getattr, client.Schema, 'DOESNOTEXIST')
    clients = aff4.FACTORY.MultiOpen([self.client_id], aff4_type=aff4_grr.VFSGRRClient, mode='rw', token=self.token)
    for client in clients:
        self.assertEqual(client.Get(client.Schema.HOSTNAME), 'client1')
        self.assertRaises(aff4.BadGetAttributeError, getattr, client.Schema, 'DOESNOTEXIST')
    client = aff4.FACTORY.Open(self.client_id, mode='rw', token=self.token)
    self.assertEqual(client.Get(client.Schema.HOSTNAME), 'client1')
    self.assertEqual(client.Get(client.Schema.DOESNOTEXIST), None)
    clients = aff4.FACTORY.MultiOpen([self.client_id], mode='rw', token=self.token)
    for client in clients:
        self.assertEqual(client.Get(client.Schema.HOSTNAME), 'client1')
        self.assertEqual(client.Get(client.Schema.DOESNOTEXIST), None)
