def test_verify_filepath_hash(self):
    'Test _verify_filepath_hash raises exception:\n            1) When there is an empty hash dict.\n            2) When a filename is expected to contain hash but does not.\n            3) When there is a hash in filename that cannot be found in\n                hash dict.\n        '
    file_hashes = dict()
    base_filename = 'base.html'
    with self.assertRaisesRegexp(ValueError, 'Hash dict is empty'):
        build._verify_filepath_hash(base_filename, file_hashes)
    file_hashes = {base_filename: random.getrandbits(128)}
    with self.assertRaisesRegexp(ValueError, ('%s is expected to contain MD5 hash' % base_filename)):
        build._verify_filepath_hash(base_filename, file_hashes)
    bad_filepath = 'README'
    with self.assertRaisesRegexp(ValueError, 'Filepath has less than 2 partitions after splitting'):
        build._verify_filepath_hash(bad_filepath, file_hashes)
    hashed_base_filename = build._insert_hash(base_filename, random.getrandbits(128))
    with self.assertRaisesRegexp(KeyError, ('Hash from file named %s does not match hash dict values' % hashed_base_filename)):
        build._verify_filepath_hash(hashed_base_filename, file_hashes)
Test _verify_filepath_hash raises exception:
1) When there is an empty hash dict.
2) When a filename is expected to contain hash but does not.
3) When there is a hash in filename that cannot be found in
    hash dict.
def test_verify_filepath_hash(self):
    'Test _verify_filepath_hash raises exception:\n            1) When there is an empty hash dict.\n            2) When a filename is expected to contain hash but does not.\n            3) When there is a hash in filename that cannot be found in\n                hash dict.\n        '
    file_hashes = dict()
    base_filename = 'base.html'
    with self.assertRaisesRegexp(ValueError, 'Hash dict is empty'):
        build._verify_filepath_hash(base_filename, file_hashes)
    file_hashes = {base_filename: random.getrandbits(128)}
    with self.assertRaisesRegexp(ValueError, ('%s is expected to contain MD5 hash' % base_filename)):
        build._verify_filepath_hash(base_filename, file_hashes)
    bad_filepath = 'README'
    with self.assertRaisesRegexp(ValueError, 'Filepath has less than 2 partitions after splitting'):
        build._verify_filepath_hash(bad_filepath, file_hashes)
    hashed_base_filename = build._insert_hash(base_filename, random.getrandbits(128))
    with self.assertRaisesRegexp(KeyError, ('Hash from file named %s does not match hash dict values' % hashed_base_filename)):
        build._verify_filepath_hash(hashed_base_filename, file_hashes)