-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
187 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
python-threatexchange/threatexchange/signal_type/tests/test_md5_hash.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
|
||
import unittest | ||
import pathlib | ||
|
||
import pytest | ||
from threatexchange.signal_type.md5 import VideoMD5Signal | ||
|
||
TEST_FILE = pathlib.Path(__file__).parent.parent.parent.parent.joinpath( | ||
"data", "sample-b.jpg" | ||
) | ||
|
||
|
||
class VideoMD5SignalTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.a_file = open(TEST_FILE, "rb") | ||
|
||
def tearDown(self): | ||
self.a_file.close() | ||
def test_can_hash_simple_files(): | ||
""" | ||
Test that the VideoMD5Signal produces the expected hash. | ||
""" | ||
with open(TEST_FILE, "rb") as f: | ||
file_content = f.read() | ||
|
||
def test_can_hash_simple_files(self): | ||
assert "d35c785545392755e7e4164457657269" == VideoMD5Signal.hash_from_bytes( | ||
self.a_file.read() | ||
), "MD5 hash does not match" | ||
expected_hash = "d35c785545392755e7e4164457657269" | ||
computed_hash = VideoMD5Signal.hash_from_bytes(file_content) | ||
assert computed_hash == expected_hash, "MD5 hash does not match" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.