def test_sha256_gets_sha_hexdigest(self, unhexlify, hashlib_sha256): unhexlify.return_value = self._bytes hashlib_sha256.return_value.hexdigest.return_value = self._sha256_result sha256(self._hex_str) hashlib_sha256.return_value.hexdigest.assert_called_once()
def test_sha256_returns_the_sha_hexdigest(self, unhexlify, hashlib_sha256): unhexlify.return_value = self._bytes sha256_result = MagicMock hashlib_sha256.return_value.hexdigest.return_value = sha256_result result = sha256(self._hex_str) self.assertEqual(result, sha256_result)
def _calculate_hash(self, hex_str: str) -> str: return sha256(sha256(hex_str))
def test_sha256_calls_hashlib_sha256(self, unhexlify, hashlib_sha256): unhexlify.return_value = self._bytes sha256(self._hex_str) hashlib_sha256.assert_any_call(self._bytes)
def test_sha256_calls_unhexlify(self, unhexlify): unhexlify.return_value = self._bytes sha256(self._hex_str) unhexlify.assert_called_once_with(self._hex_str)
def test_sha256_returns_the_correct_hash(self): result = sha256(self._hex_str) self.assertEqual(result, self._sha256_result)