'Can we hash a file?'

def testHashFile(self):

    path = os.path.join(self.base_path, 'numbers.txt')
    p = rdf_paths.PathSpec(path=path, pathtype=rdf_paths.PathSpec.PathType.OS)
    result = self.RunAction(file_fingerprint.FingerprintFile, rdf_client.FingerprintRequest(pathspec=p))
    types = result[0].matching_types
    fingers = {}
    for f in result[0].results:
        fingers[f['name']] = f
    generic_sha256 = fingers['generic']['sha256']
    self.assertEqual(generic_sha256, hashlib.sha256(open(path, 'rb').read()).digest())
    t_map = {rdf_client.FingerprintTuple.Type.FPT_GENERIC: 'generic', rdf_client.FingerprintTuple.Type.FPT_PE_COFF: 'pecoff'}
    ti_map = dict(((v, k) for (k, v) in t_map.iteritems()))
    for t in types:
        self.assertTrue((t_map[t] in fingers))
    for f in fingers:
        self.assertTrue((ti_map[f] in types))
    self.assertEqual(result[0].pathspec.path, path)
