Skip to content

Commit fabbc8a

Browse files
committed
test: added expected structure to ensure correctness
Signed-off-by: Carl Flottmann <[email protected]>
1 parent ab18101 commit fabbc8a

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

tests/malware_analyzer/pypi/test_similar_projects.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,62 @@ def test_get_normalized_structure(
8282
mock_send_get_http_raw: Callable
8383
A mocked send_get_http_raw function to return inspector html.
8484
"""
85+
# This structure is all files in the PyPI inspector HTML page that are python files, minus setup.py
86+
# and the package name, so this structure is now comparable to some other project that would have these
87+
# same files, but with a different name
88+
expected_structure: set[str] = {
89+
"/__init__.py",
90+
"/ai/__init__.py",
91+
"/ai/anthropic/__init__.py",
92+
"/ai/anthropic/anthropic.py",
93+
"/ai/anthropic/anthropic_async.py",
94+
"/ai/anthropic/anthropic_converter.py",
95+
"/ai/anthropic/anthropic_providers.py",
96+
"/ai/gemini/__init__.py",
97+
"/ai/gemini/gemini.py",
98+
"/ai/gemini/gemini_converter.py",
99+
"/ai/langchain/__init__.py",
100+
"/ai/langchain/callbacks.py",
101+
"/ai/openai/__init__.py",
102+
"/ai/openai/openai.py",
103+
"/ai/openai/openai_async.py",
104+
"/ai/openai/openai_converter.py",
105+
"/ai/openai/openai_providers.py",
106+
"/ai/sanitization.py",
107+
"/ai/types.py",
108+
"/ai/utils.py",
109+
"/args.py",
110+
"/client.py",
111+
"/consumer.py",
112+
"/contexts.py",
113+
"/exception_capture.py",
114+
"/exception_utils.py",
115+
"/feature_flags.py",
116+
"/integrations/__init__.py",
117+
"/integrations/django.py",
118+
"/poller.py",
119+
"/request.py",
120+
"/test/__init__.py",
121+
"/test/test_before_send.py",
122+
"/test/test_client.py",
123+
"/test/test_consumer.py",
124+
"/test/test_contexts.py",
125+
"/test/test_exception_capture.py",
126+
"/test/test_feature_flag.py",
127+
"/test/test_feature_flag_result.py",
128+
"/test/test_feature_flags.py",
129+
"/test/test_module.py",
130+
"/test/test_request.py",
131+
"/test/test_size_limited_dict.py",
132+
"/test/test_types.py",
133+
"/test/test_utils.py",
134+
"/types.py",
135+
"/utils.py",
136+
"/version.py",
137+
}
138+
85139
pypi_package_json.component_version = "6.7.4"
86140
pypi_package_json.component_name = "posthog"
87-
88141
pypi_package_json.inspector_asset.package_sdist_link = TEST_SDIST_LINK
89142
pypi_package_json.inspector_asset.package_link_reachability = {TEST_SDIST_LINK: True}
90143
pypi_package_json.inspector_asset.package_whl_links = []
@@ -96,3 +149,6 @@ def test_get_normalized_structure(
96149
wheel_structure = analyzer.get_normalized_structure(pypi_package_json)
97150

98151
assert sdist_structure == wheel_structure
152+
assert sdist_structure == expected_structure
153+
# sdist == wheel_structure, sdist == expected_structure, so don't quite need this, but just for completeness
154+
assert wheel_structure == expected_structure

0 commit comments

Comments
 (0)