Skip to content

Commit 34de9b8

Browse files
authored
Create test_tokenization.py
1 parent 551e8c9 commit 34de9b8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/test_tokenization.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# tests/test_tokenization.py
2+
3+
import unittest
4+
from tokenization.token_generator import TokenGenerator
5+
6+
class TestTokenGenerator(unittest.TestCase):
7+
def setUp(self):
8+
"""
9+
Set up the test environment before each test.
10+
"""
11+
self.token_generator = TokenGenerator()
12+
13+
def test_generate_token(self):
14+
"""
15+
Test that a token is generated correctly.
16+
"""
17+
biological_data = {
18+
"id": "bio_001",
19+
"type": "DNA",
20+
"sequence": "ATCGTAGCTAGCTAGCTAGC",
21+
"timestamp": 1633072800
22+
}
23+
token = self.token_generator.generate_token(biological_data)
24+
self.assertIsNotNone(token, "Token should not be None.")
25+
self.assertEqual(len(token), 64, "Token length should be 64 characters (SHA-256 hash).")
26+
27+
def test_encrypt_decrypt_data(self):
28+
"""
29+
Test that data can be encrypted and decrypted correctly.
30+
"""
31+
biological_data = {
32+
"id": "bio_001",
33+
"type": "DNA",
34+
"sequence": "ATCGTAGCTAGCTAGCTAGC",
35+
"timestamp": 1633072800
36+
}
37+
encrypted_data = self.token_generator.encrypt_data(biological_data)
38+
decrypted_data = self.token_generator.decrypt_data(encrypted_data)
39+
self.assertEqual(decrypted_data, biological_data, "Decrypted data should match the original data.")
40+
41+
if __name__ == "__main__":
42+
unittest.main()

0 commit comments

Comments
 (0)