9
9
10
10
import pytest
11
11
12
- from wolfsoftware .pypi_extractor import PyPIPackageInfo , PyPIPackageInfoError # pylint: disable=unused-import
12
+ from wolfsoftware .pypi_extractor import PyPiExtractor , PyPiExtractorError # pylint: disable=unused-import, no-name-in-module
13
13
from .testconf import ( # noqa: F401 pylint: disable=unused-import
14
14
mock_get_user_packages_success ,
15
15
mock_get_user_packages_error ,
@@ -45,23 +45,23 @@ def test_init_with_empty_username() -> None:
45
45
does not raise an error, and that attempting to fetch packages without setting a username
46
46
raises a PyPIPackageInfoError.
47
47
"""
48
- pypi_info = PyPIPackageInfo ()
48
+ pypi_info = PyPiExtractor ()
49
49
50
- with pytest .raises (PyPIPackageInfoError , match = "Username must be set before fetching packages" ):
50
+ with pytest .raises (PyPiExtractorError , match = "Username must be set before fetching packages" ):
51
51
pypi_info .get_user_packages ()
52
52
53
- with pytest .raises (PyPIPackageInfoError , match = "Username must be set before fetching package details" ):
53
+ with pytest .raises (PyPiExtractorError , match = "Username must be set before fetching package details" ):
54
54
pypi_info .get_all_packages_details ()
55
55
56
56
57
57
def test_set_username () -> None :
58
58
"""
59
59
Test setting the username after initialization.
60
60
61
- This test verifies that the username can be set after initializing the PyPIPackageInfo class,
61
+ This test verifies that the username can be set after initializing the PyPiExtractor class,
62
62
and that it functions correctly with the set username.
63
63
"""
64
- pypi_info = PyPIPackageInfo ()
64
+ pypi_info = PyPiExtractor ()
65
65
pypi_info .set_username ("testuser" )
66
66
assert pypi_info .username == "testuser" # nosec: B101
67
67
@@ -70,11 +70,11 @@ def test_set_username_with_invalid_value() -> None:
70
70
"""
71
71
Test setting the username with an invalid value.
72
72
73
- This test verifies that setting the username to an empty string raises a PyPIPackageInfoError .
73
+ This test verifies that setting the username to an empty string raises a PyPiExtractorError .
74
74
"""
75
- pypi_info = PyPIPackageInfo ()
75
+ pypi_info = PyPiExtractor ()
76
76
77
- with pytest .raises (PyPIPackageInfoError , match = "Username must be provided" ):
77
+ with pytest .raises (PyPiExtractorError , match = "Username must be provided" ):
78
78
pypi_info .set_username ("" )
79
79
80
80
@@ -86,7 +86,7 @@ def test_get_user_packages_success(mock_get_user_packages_success) -> None: # n
86
86
to return a successful response and verifies that the get_user_packages method returns
87
87
the expected list of packages.
88
88
"""
89
- pypi_info = PyPIPackageInfo ("testuser" )
89
+ pypi_info = PyPiExtractor ("testuser" )
90
90
packages : List = pypi_info .get_user_packages ()
91
91
92
92
assert len (packages ) == 2 # nosec: B101
@@ -101,11 +101,11 @@ def test_get_user_packages_error(mock_get_user_packages_error) -> None: # noqa:
101
101
Test get_user_packages method when there is an error.
102
102
103
103
This test uses the mock_get_user_packages_error fixture to mock requests.get method
104
- to raise an exception and verifies that the get_user_packages method raises a PyPIPackageInfoError .
104
+ to raise an exception and verifies that the get_user_packages method raises a PyPiExtractorError .
105
105
"""
106
- pypi_info = PyPIPackageInfo ("testuser" )
106
+ pypi_info = PyPiExtractor ("testuser" )
107
107
108
- with pytest .raises (PyPIPackageInfoError , match = "Error fetching user profile: Request error" ):
108
+ with pytest .raises (PyPiExtractorError , match = "Error fetching user profile: Request error" ):
109
109
pypi_info .get_user_packages ()
110
110
111
111
@@ -117,7 +117,7 @@ def test_get_package_details_success(mock_get_package_details_success) -> None:
117
117
to return a successful response and verifies that the get_package_details method returns
118
118
the expected package details.
119
119
"""
120
- pypi_info = PyPIPackageInfo ("testuser" )
120
+ pypi_info = PyPiExtractor ("testuser" )
121
121
details : Dict [str , Any ] = pypi_info .get_package_details ("Package1" )
122
122
123
123
assert details ['name' ] == "Package1" # nosec: B101
@@ -141,11 +141,11 @@ def test_get_package_details_error(mock_get_package_details_error) -> None: # n
141
141
Test get_package_details method when there is an error.
142
142
143
143
This test uses the mock_get_package_details_error fixture to mock requests.get method
144
- to raise an exception and verifies that the get_package_details method raises a PyPIPackageInfoError .
144
+ to raise an exception and verifies that the get_package_details method raises a PyPiExtractorError .
145
145
"""
146
- pypi_info = PyPIPackageInfo ("testuser" )
146
+ pypi_info = PyPiExtractor ("testuser" )
147
147
148
- with pytest .raises (PyPIPackageInfoError , match = "Error fetching package details: Request error" ):
148
+ with pytest .raises (PyPiExtractorError , match = "Error fetching package details: Request error" ):
149
149
pypi_info .get_package_details ("Package1" )
150
150
151
151
@@ -157,7 +157,7 @@ def test_get_all_packages_details_success(mock_get_all_packages_details_success)
157
157
to return a successful response for both user packages and package details, and verifies that
158
158
the get_all_packages_details method returns the expected list of detailed package information.
159
159
"""
160
- pypi_info = PyPIPackageInfo ("testuser" )
160
+ pypi_info = PyPiExtractor ("testuser" )
161
161
details : List = pypi_info .get_all_packages_details ()
162
162
163
163
assert len (details ) == 2 # nosec: B101
0 commit comments