compressedfhir 1.0.2__py3-none-any.whl → 1.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of compressedfhir might be problematic. Click here for more details.
- compressedfhir/fhir/fhir_bundle.py +4 -3
- compressedfhir/fhir/fhir_bundle_entry.py +1 -1
- compressedfhir/fhir/fhir_bundle_entry_response.py +0 -1
- compressedfhir/fhir/fhir_resource.py +37 -27
- compressedfhir/fhir/fhir_resource_list.py +1 -1
- compressedfhir/utilities/compressed_dict/v1/compressed_dict.py +50 -16
- compressedfhir/utilities/compressed_dict/v1/compressed_dict_storage_mode.py +7 -7
- compressedfhir/utilities/compressed_dict/v1/test/test_compressed_dict.py +107 -0
- compressedfhir/utilities/fhir_json_encoder.py +1 -1
- compressedfhir/utilities/json_serializers/__init__.py +0 -0
- compressedfhir/utilities/json_serializers/test/__init__.py +0 -0
- compressedfhir/utilities/json_serializers/test/test_type_preservation_decoder.py +150 -0
- compressedfhir/utilities/json_serializers/test/test_type_preservation_encoder.py +59 -0
- compressedfhir/utilities/json_serializers/test/test_type_preservation_serializer.py +171 -0
- compressedfhir/utilities/json_serializers/type_preservation_decoder.py +110 -0
- compressedfhir/utilities/json_serializers/type_preservation_encoder.py +50 -0
- compressedfhir/utilities/json_serializers/type_preservation_serializer.py +57 -0
- compressedfhir/utilities/ordered_dict_to_dict_converter/__init__.py +0 -0
- compressedfhir/utilities/ordered_dict_to_dict_converter/ordered_dict_to_dict_converter.py +24 -0
- compressedfhir/utilities/string_compressor/__init__.py +0 -0
- compressedfhir/utilities/string_compressor/v1/__init__.py +0 -0
- compressedfhir/utilities/string_compressor/v1/string_compressor.py +99 -0
- compressedfhir/utilities/string_compressor/v1/test/__init__.py +0 -0
- compressedfhir/utilities/string_compressor/v1/test/test_string_compressor.py +189 -0
- {compressedfhir-1.0.2.dist-info → compressedfhir-1.0.4.dist-info}/METADATA +1 -1
- {compressedfhir-1.0.2.dist-info → compressedfhir-1.0.4.dist-info}/RECORD +29 -14
- {compressedfhir-1.0.2.dist-info → compressedfhir-1.0.4.dist-info}/WHEEL +0 -0
- {compressedfhir-1.0.2.dist-info → compressedfhir-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {compressedfhir-1.0.2.dist-info → compressedfhir-1.0.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Basic Compression and Decompression Tests
|
|
2
|
+
from typing import Optional, Union
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
import zlib
|
|
6
|
+
|
|
7
|
+
from compressedfhir.utilities.string_compressor.v1.string_compressor import (
|
|
8
|
+
StringCompressor,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.mark.parametrize(
|
|
13
|
+
"input_text",
|
|
14
|
+
[
|
|
15
|
+
"Hello, World!",
|
|
16
|
+
"Python is awesome",
|
|
17
|
+
"12345",
|
|
18
|
+
"", # Empty string
|
|
19
|
+
"🌍🚀", # Unicode characters
|
|
20
|
+
],
|
|
21
|
+
)
|
|
22
|
+
def test_compress_decompress_basic(input_text: str) -> None:
|
|
23
|
+
"""
|
|
24
|
+
Test basic compression and decompression functionality
|
|
25
|
+
"""
|
|
26
|
+
# Compress
|
|
27
|
+
compressed = StringCompressor.compress(input_text)
|
|
28
|
+
|
|
29
|
+
# Verify compression reduces size
|
|
30
|
+
# assert len(compressed) < len(input_text.encode('utf-8'))
|
|
31
|
+
|
|
32
|
+
# Decompress
|
|
33
|
+
decompressed = StringCompressor.decompress(compressed)
|
|
34
|
+
|
|
35
|
+
# Verify original text is preserved
|
|
36
|
+
assert decompressed == input_text
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# Error Handling Tests
|
|
40
|
+
def test_compress_invalid_input() -> None:
|
|
41
|
+
"""
|
|
42
|
+
Test compression with invalid input type
|
|
43
|
+
"""
|
|
44
|
+
with pytest.raises(TypeError, match="Input must be a string"):
|
|
45
|
+
StringCompressor.compress(123) # type:ignore[arg-type]
|
|
46
|
+
|
|
47
|
+
with pytest.raises(TypeError, match="Input must be a string"):
|
|
48
|
+
StringCompressor.compress(None) # type:ignore[arg-type]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_decompress_invalid_input() -> None:
|
|
52
|
+
"""
|
|
53
|
+
Test decompression with invalid input type
|
|
54
|
+
"""
|
|
55
|
+
with pytest.raises(TypeError, match="Input must be bytes or bytearray"):
|
|
56
|
+
StringCompressor.decompress("not bytes") # type:ignore[arg-type]
|
|
57
|
+
|
|
58
|
+
with pytest.raises(TypeError, match="Input must be bytes or bytearray"):
|
|
59
|
+
StringCompressor.decompress(123) # type:ignore[arg-type]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Safe Method Tests
|
|
63
|
+
@pytest.mark.parametrize("input_text", ["Test string", None, ""])
|
|
64
|
+
def test_compress_safe(input_text: Optional[str]) -> None:
|
|
65
|
+
"""
|
|
66
|
+
Test safe compression method
|
|
67
|
+
"""
|
|
68
|
+
compressed = StringCompressor.compress_safe(input_text)
|
|
69
|
+
|
|
70
|
+
if input_text is None:
|
|
71
|
+
assert compressed is None
|
|
72
|
+
else:
|
|
73
|
+
assert isinstance(compressed, bytes)
|
|
74
|
+
# Verify we can decompress
|
|
75
|
+
decompressed = StringCompressor.decompress_safe(compressed)
|
|
76
|
+
assert decompressed == input_text
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.parametrize(
|
|
80
|
+
"input_data", [b"compressed data", None, bytearray(b"another compressed data")]
|
|
81
|
+
)
|
|
82
|
+
def test_decompress_safe(input_data: Optional[Union[bytes, bytearray]]) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Test safe decompression method
|
|
85
|
+
"""
|
|
86
|
+
if input_data is None:
|
|
87
|
+
decompressed = StringCompressor.decompress_safe(input_data)
|
|
88
|
+
assert decompressed is None
|
|
89
|
+
else:
|
|
90
|
+
# First compress a string
|
|
91
|
+
original = "Test string to compress"
|
|
92
|
+
compressed = StringCompressor.compress(original)
|
|
93
|
+
|
|
94
|
+
# Then decompress
|
|
95
|
+
decompressed = StringCompressor.decompress_safe(compressed)
|
|
96
|
+
assert decompressed == original
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
# Encoding Tests
|
|
100
|
+
@pytest.mark.parametrize("encoding", ["utf-8", "ascii", "latin-1"])
|
|
101
|
+
def test_custom_encoding(encoding: str) -> None:
|
|
102
|
+
"""
|
|
103
|
+
Test compression and decompression with different encodings
|
|
104
|
+
"""
|
|
105
|
+
input_text = "Hello, World!"
|
|
106
|
+
|
|
107
|
+
# Compress with custom encoding
|
|
108
|
+
compressed = StringCompressor.compress(input_text, encoding=encoding)
|
|
109
|
+
|
|
110
|
+
# Decompress with same encoding
|
|
111
|
+
decompressed = StringCompressor.decompress(compressed, encoding=encoding)
|
|
112
|
+
|
|
113
|
+
assert decompressed == input_text
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# Compression Efficiency Tests
|
|
117
|
+
def test_compression_efficiency() -> None:
|
|
118
|
+
"""
|
|
119
|
+
Test that compression actually reduces data size
|
|
120
|
+
"""
|
|
121
|
+
# Long repetitive string for better compression
|
|
122
|
+
input_text = "Hello " * 1000
|
|
123
|
+
|
|
124
|
+
# Compress
|
|
125
|
+
compressed = StringCompressor.compress(input_text)
|
|
126
|
+
|
|
127
|
+
# Check compression ratio
|
|
128
|
+
original_size = len(input_text.encode("utf-8"))
|
|
129
|
+
compressed_size = len(compressed)
|
|
130
|
+
|
|
131
|
+
# Verify significant size reduction
|
|
132
|
+
assert compressed_size < original_size
|
|
133
|
+
|
|
134
|
+
# Verify lossless decompression
|
|
135
|
+
decompressed = StringCompressor.decompress(compressed)
|
|
136
|
+
assert decompressed == input_text
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# Edge Case Tests
|
|
140
|
+
def test_very_large_string() -> None:
|
|
141
|
+
"""
|
|
142
|
+
Test compression and decompression of a very large string
|
|
143
|
+
"""
|
|
144
|
+
# Generate a large string
|
|
145
|
+
large_text = "A" * (1024 * 1024) # 1MB of text
|
|
146
|
+
|
|
147
|
+
# Compress
|
|
148
|
+
compressed = StringCompressor.compress(large_text)
|
|
149
|
+
|
|
150
|
+
# Decompress
|
|
151
|
+
decompressed = StringCompressor.decompress(compressed)
|
|
152
|
+
|
|
153
|
+
assert decompressed == large_text
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# Error Scenario Tests
|
|
157
|
+
def test_decompress_corrupted_data() -> None:
|
|
158
|
+
"""
|
|
159
|
+
Test decompression of corrupted data
|
|
160
|
+
"""
|
|
161
|
+
# Create some corrupted compressed data
|
|
162
|
+
with pytest.raises(zlib.error):
|
|
163
|
+
StringCompressor.decompress(b"corrupted data")
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# Performance Benchmark (optional)
|
|
167
|
+
def test_compression_performance() -> None:
|
|
168
|
+
"""
|
|
169
|
+
Basic performance test for compression and decompression
|
|
170
|
+
"""
|
|
171
|
+
import timeit
|
|
172
|
+
|
|
173
|
+
# Test string
|
|
174
|
+
test_string = "Performance test " * 100
|
|
175
|
+
|
|
176
|
+
# Measure compression time
|
|
177
|
+
compression_time = timeit.timeit(
|
|
178
|
+
lambda: StringCompressor.compress(test_string), number=100
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# Measure decompression time
|
|
182
|
+
compressed = StringCompressor.compress(test_string)
|
|
183
|
+
decompression_time = timeit.timeit(
|
|
184
|
+
lambda: StringCompressor.decompress(compressed), number=100
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# Basic performance assertions (these can be adjusted)
|
|
188
|
+
assert compression_time < 1.0 # 100 compressions in less than 1 second
|
|
189
|
+
assert decompression_time < 1.0 # 100 decompressions in less than 1 second
|
|
@@ -2,17 +2,17 @@ compressedfhir/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
compressedfhir/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
compressedfhir/fhir/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
compressedfhir/fhir/base_resource_list.py,sha256=hhlQLT_HFrLmVPuirTsiXQsiUadxpfSQTPS4CofthTM,4924
|
|
5
|
-
compressedfhir/fhir/fhir_bundle.py,sha256=
|
|
6
|
-
compressedfhir/fhir/fhir_bundle_entry.py,sha256=
|
|
5
|
+
compressedfhir/fhir/fhir_bundle.py,sha256=ec5A5OGgaJGwm6UO7uRaWQxNQaWyW6rH0OoXL9BWzaE,10185
|
|
6
|
+
compressedfhir/fhir/fhir_bundle_entry.py,sha256=g7msoFmRAywS2WsBMqmJGYbEeQFPcBqf0o0vVI8pLkc,8458
|
|
7
7
|
compressedfhir/fhir/fhir_bundle_entry_list.py,sha256=tjZueiviQ4ucSDNGSR9CpN-Kwv3BIBcmal3_0J1HE_E,2655
|
|
8
8
|
compressedfhir/fhir/fhir_bundle_entry_request.py,sha256=8UqJw388aDYgZCz1rvk2kmDa03vOEsmZOaJeb5CLqzw,2841
|
|
9
|
-
compressedfhir/fhir/fhir_bundle_entry_response.py,sha256=
|
|
9
|
+
compressedfhir/fhir/fhir_bundle_entry_response.py,sha256=5u-ycyWVdFyLhIUM4xf-5QioKWAc2kEOFeFcJRrR6_o,2512
|
|
10
10
|
compressedfhir/fhir/fhir_bundle_entry_search.py,sha256=uYVJxuNN3gt3Q6BZ5FhRs47x7l54Lo_H-7JdoOvkx94,2554
|
|
11
11
|
compressedfhir/fhir/fhir_identifier.py,sha256=tA_nmhBaYHu5zjJdE0IWMFEF8lrIPV3_nu-yairiIKw,2711
|
|
12
12
|
compressedfhir/fhir/fhir_link.py,sha256=jf2RrwmsPrKW3saP77y42xVqI0xwHFYXxm6YHQJk7gU,1922
|
|
13
13
|
compressedfhir/fhir/fhir_meta.py,sha256=vNI4O6SoG4hJRHyd-bJ_QnYFTfBHyR3UA6h21ByQmWo,1669
|
|
14
|
-
compressedfhir/fhir/fhir_resource.py,sha256=
|
|
15
|
-
compressedfhir/fhir/fhir_resource_list.py,sha256=
|
|
14
|
+
compressedfhir/fhir/fhir_resource.py,sha256=GIz0g8O-Nw9Av8M5wYRoRY4FS2kEk2Nb03RPSeDYUqo,5588
|
|
15
|
+
compressedfhir/fhir/fhir_resource_list.py,sha256=qlAAwWWphtFicBxPG8iriz2eOHGcrWJk5kGThmvkbPE,4480
|
|
16
16
|
compressedfhir/fhir/fhir_resource_map.py,sha256=6Zt_K8KVolS-lgT_Ztu_6YxNo8BXhweQfWO-QFriInA,6588
|
|
17
17
|
compressedfhir/fhir/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
compressedfhir/fhir/test/test_bundle_entry.py,sha256=Ki2sSu1V1WZkAM6UTCghtzjvjYYI8UcF6AXnx8FWlMI,5115
|
|
@@ -24,21 +24,36 @@ compressedfhir/fhir/test/test_fhir_resource.py,sha256=4Fl6QaqjW4CsYqkxVj2WRXITv_
|
|
|
24
24
|
compressedfhir/fhir/test/test_fhir_resource_list.py,sha256=SrSPJ1yWU4UgMUCht6JwgKh2Y5JeTS4-Wky0kWZOXH8,5664
|
|
25
25
|
compressedfhir/fhir/test/test_fhir_resource_map.py,sha256=jtQ5fq_jhmFfhHGyK5mdiwIQiO-Sfp2eG9mco_Tr9Qk,10995
|
|
26
26
|
compressedfhir/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
compressedfhir/utilities/fhir_json_encoder.py,sha256=
|
|
27
|
+
compressedfhir/utilities/fhir_json_encoder.py,sha256=hn-ZuDrTEdYZmILk_5_k4R72PQB_OHYXo_3eTKTO24c,1856
|
|
28
28
|
compressedfhir/utilities/json_helpers.py,sha256=lEiPapLN0p-kLu6PFm-h971ieXRxwPB2M-8FCZ2Buo8,5642
|
|
29
29
|
compressedfhir/utilities/compressed_dict/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
compressedfhir/utilities/compressed_dict/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
compressedfhir/utilities/compressed_dict/v1/compressed_dict.py,sha256=
|
|
31
|
+
compressedfhir/utilities/compressed_dict/v1/compressed_dict.py,sha256=Ibtg9q1CYL6W7b0kW-Xqr2eUhpPVWnU1D_9Or4cxUbs,21200
|
|
32
32
|
compressedfhir/utilities/compressed_dict/v1/compressed_dict_access_error.py,sha256=xuwED0KGZcQORIcZRfi--5CdXplHJ5vYLBUqpbDi344,132
|
|
33
|
-
compressedfhir/utilities/compressed_dict/v1/compressed_dict_storage_mode.py,sha256=
|
|
33
|
+
compressedfhir/utilities/compressed_dict/v1/compressed_dict_storage_mode.py,sha256=mEdtJjPX2I9DqP0Ly_VsZZWhEMNTI1psqQ8iJtUQ2oE,1412
|
|
34
34
|
compressedfhir/utilities/compressed_dict/v1/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
-
compressedfhir/utilities/compressed_dict/v1/test/test_compressed_dict.py,sha256=
|
|
35
|
+
compressedfhir/utilities/compressed_dict/v1/test/test_compressed_dict.py,sha256=_jiZJCZdXeMAigHLVGz-EhSWXGhrxQFRNGLsrsDYrp0,15824
|
|
36
|
+
compressedfhir/utilities/json_serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
|
+
compressedfhir/utilities/json_serializers/type_preservation_decoder.py,sha256=Af2ZsLZiUF9kUhRvkV7i6Ctf_OtTND_lb5PezHtolJU,4382
|
|
38
|
+
compressedfhir/utilities/json_serializers/type_preservation_encoder.py,sha256=f7RL67l7QtDbijCPq1ki6axrLte1vH--bi1AsN7Y3yk,1646
|
|
39
|
+
compressedfhir/utilities/json_serializers/type_preservation_serializer.py,sha256=cE1ka2RxKy_8P0xhgqvPyWqJ3C0Br-aqIHP9BPkCg7A,1523
|
|
40
|
+
compressedfhir/utilities/json_serializers/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
+
compressedfhir/utilities/json_serializers/test/test_type_preservation_decoder.py,sha256=GQotwYQJe9VZQotvLWmQWMkSIBne53bolmgflBoR7DU,4752
|
|
42
|
+
compressedfhir/utilities/json_serializers/test/test_type_preservation_encoder.py,sha256=O4VczBdsJF35WozZiwSdJ8638qDn01JQsai2wTXu5Vo,1737
|
|
43
|
+
compressedfhir/utilities/json_serializers/test/test_type_preservation_serializer.py,sha256=dTYdgI1wMgWU0DJCNJlbMmsnhr-Q_2SPXeydLsn70rA,6043
|
|
44
|
+
compressedfhir/utilities/ordered_dict_to_dict_converter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
+
compressedfhir/utilities/ordered_dict_to_dict_converter/ordered_dict_to_dict_converter.py,sha256=CMerJQD7O0vMyGtUp1rKSerZA1tDZeY5GTQT3AykL4w,831
|
|
46
|
+
compressedfhir/utilities/string_compressor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
|
+
compressedfhir/utilities/string_compressor/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
|
+
compressedfhir/utilities/string_compressor/v1/string_compressor.py,sha256=28CvEJPQVKS56S9YPdVM1i-xWEuizYeyKiICWEYOV0k,3263
|
|
49
|
+
compressedfhir/utilities/string_compressor/v1/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
50
|
+
compressedfhir/utilities/string_compressor/v1/test/test_string_compressor.py,sha256=ydlJIpp-IDPcLlv4YvxMph19OndLEt3kuNQ9buNwy0Y,5473
|
|
36
51
|
compressedfhir/utilities/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
37
52
|
compressedfhir/utilities/test/test_fhir_json_encoder.py,sha256=6pbNmZp5eBWY66bHjgjm_pZVhs5HDKP8hCGnwNFzpEw,5171
|
|
38
53
|
compressedfhir/utilities/test/test_json_helpers.py,sha256=V0R9oHDQAs0m0012niEz50sHJxMSUQvA3km7kK8HgjE,3860
|
|
39
|
-
compressedfhir-1.0.
|
|
54
|
+
compressedfhir-1.0.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
40
55
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
-
compressedfhir-1.0.
|
|
42
|
-
compressedfhir-1.0.
|
|
43
|
-
compressedfhir-1.0.
|
|
44
|
-
compressedfhir-1.0.
|
|
56
|
+
compressedfhir-1.0.4.dist-info/METADATA,sha256=Qk3xfm70nAzzDsyTiIsWuuvAsuOPuvAuVABV2-Xgrko,3456
|
|
57
|
+
compressedfhir-1.0.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
58
|
+
compressedfhir-1.0.4.dist-info/top_level.txt,sha256=YMKdvBBdiCzFbpI9fG8BUDjaRd-f4R0qAvUoVETpoWw,21
|
|
59
|
+
compressedfhir-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|