Esempio n. 1
0
    def test_local_sha_put_1(self, monkeypatch: MonkeyPatch):
        def isfile(path):
            result = False
            if re.search(r".*sha1", path):
                result = True
            return result

        class MockSplitCopyShared2(MockSplitCopyShared):
            def req_sha_binaries(self, sha_hash):
                return "sha1sum", 1

        scput = SplitCopyPut()
        scput.scs = MockSplitCopyShared2()
        monkeypatch.setattr("builtins.open", MockOpen)
        monkeypatch.setattr("os.path.isfile", isfile)
        result = scput.local_sha_put()
        assert result == ("sha1sum", 1, {1: "abcdef0123456789"})
Esempio n. 2
0
    def test_local_sha_put_none(self, monkeypatch: MonkeyPatch):
        def isfile(path):
            return False

        class MockSplitCopyShared2(MockSplitCopyShared):
            def req_sha_binaries(self, sha_hash):
                return "shasum", 1

        class Mock1(MockHash):
            pass

        scput = SplitCopyPut()
        scput.scs = MockSplitCopyShared2()
        monkeypatch.setattr("builtins.open", MockOpen)
        monkeypatch.setattr("os.path.isfile", isfile)
        monkeypatch.setattr("hashlib.sha1", Mock1)
        result = scput.local_sha_put()
        assert result == ("shasum", 1, {1: "abcdef0123456789"})