# Path: onedrived/od_hashutils.py
# def hash_match(local_abspath, remote_item):
# def sha1_value(file_path, block_size=2 << 22):


import tempfile
import unittest
from onedrivesdk.model.item import Item
from onedrived import od_hashutils
    def setUp(self):
        self.TEST_FILES = []
        for t in self.TEST_CASES:
            tmpfile = tempfile.NamedTemporaryFile()
            tmpfile.write(t[0])
            tmpfile.flush()
            tmpfile.seek(0)
            self.TEST_FILES.append(tmpfile)

    def tearDown(self):
        for f in self.TEST_FILES:
            f.close()

    def test_hash(self):
        for i, (data, sha1) in enumerate(self.TEST_CASES):
            tmpname = self.TEST_FILES[i].name
            sha1_hash = od_hashutils.sha1_value(tmpname)
            self.assertEqual(sha1, sha1_hash)

    def _mock_item(self, sha1_hash=None):
        prop_dict = dict()
        if sha1_hash:
            prop_dict['sha1Hash'] = sha1_hash
        item = Item(prop_dict={'file': {'hashes': prop_dict}})
        self.assertEqual(sha1_hash, item.file.hashes.sha1_hash)
        return item

    def test_hash_match(self):
        tmpname = self.TEST_FILES[0].name
        self.assertTrue(

# Path: onedrived/od_hashutils.py
# def hash_match(local_abspath, remote_item):
# def sha1_value(file_path, block_size=2 << 22):


# Path: tests/test_hashutils.py
import tempfile
import unittest
from onedrivesdk.model.item import Item
from onedrived import od_hashutils

    def setUp(self):
        self.TEST_FILES = []
        for t in self.TEST_CASES:
            tmpfile = tempfile.NamedTemporaryFile()
            tmpfile.write(t[0])
            tmpfile.flush()
            tmpfile.seek(0)
            self.TEST_FILES.append(tmpfile)

    def tearDown(self):
        for f in self.TEST_FILES:
            f.close()

    def test_hash(self):
        for i, (data, sha1) in enumerate(self.TEST_CASES):
            tmpname = self.TEST_FILES[i].name
            sha1_hash = od_hashutils.sha1_value(tmpname)
            self.assertEqual(sha1, sha1_hash)

    def _mock_item(self, sha1_hash=None):
        prop_dict = dict()
        if sha1_hash:
            prop_dict['sha1Hash'] = sha1_hash
        item = Item(prop_dict={'file': {'hashes': prop_dict}})
        self.assertEqual(sha1_hash, item.file.hashes.sha1_hash)
        return item

    def test_hash_match(self):
        tmpname = self.TEST_FILES[0].name
        self.assertTrue(

            od_hashutils.hash_match(tmpname, self._mock_item(sha1_hash=self.TEST_CASES[0][1])),