|
24 | 24 | from mock import patch
|
25 | 25 |
|
26 | 26 | from hpecp import ContainerPlatformClient
|
| 27 | +from hpecp.catalog import CatalogList |
27 | 28 | from hpecp.exceptions import APIItemNotFoundException
|
28 | 29 |
|
29 | 30 |
|
@@ -139,3 +140,75 @@ def test_get_catalog(self, mock_get, mock_post):
|
139 | 140 | "'catalog not found with id: /api/v1/catalog/100'",
|
140 | 141 | ):
|
141 | 142 | get_client().catalog.get("/api/v1/catalog/100")
|
| 143 | + |
| 144 | + |
| 145 | +class TestCatalogList(unittest.TestCase): |
| 146 | + def mocked_requests_get(*args, **kwargs): |
| 147 | + if args[0] == "https://127.0.0.1:8080/api/v1/catalog/": |
| 148 | + return MockResponse( |
| 149 | + json_data={ |
| 150 | + "_links": { |
| 151 | + "self": {"href": "/api/v1/catalog/"}, |
| 152 | + "feedlog": {"href": "/api/v1/catalog/feedlog"}, |
| 153 | + "feed": [ |
| 154 | + { |
| 155 | + "href": "http://127.0.0.1:8080/api/v1/feed/local", |
| 156 | + "name": "Feed generated from local bundles.", |
| 157 | + }, |
| 158 | + { |
| 159 | + "href": "https://s3.amazonaws.com/bluedata-catalog/bundles/catalog/external/docker/EPIC-5.0/feeds/feed.json", |
| 160 | + "name": "BlueData EPIC-5.0 catalog feed for docker", |
| 161 | + }, |
| 162 | + ], |
| 163 | + }, |
| 164 | + "catalog_api_version": 6, |
| 165 | + "feeds_refresh_period_seconds": 86400, |
| 166 | + "feeds_read_counter": 5, |
| 167 | + "catalog_write_counter": 5, |
| 168 | + "_embedded": { |
| 169 | + "independent_catalog_entries": [ |
| 170 | + { |
| 171 | + "_links": { |
| 172 | + "self": {"href": "/api/v1/catalog/29"}, |
| 173 | + "feed": [ |
| 174 | + { |
| 175 | + "href": "https://s3.amazonaws.com/bluedata-catalog/bundles/catalog/external/docker/EPIC-5.0/feeds/feed.json", |
| 176 | + "name": "BlueData EPIC-5.0 catalog feed for docker", |
| 177 | + } |
| 178 | + ], |
| 179 | + }, |
| 180 | + "distro_id": "bluedata/spark240juphub7xssl", |
| 181 | + "label": { |
| 182 | + "name": "Spark240", |
| 183 | + "description": "Spark240 multirole with Jupyter Notebook, Jupyterhub with SSL and gateway node", |
| 184 | + }, |
| 185 | + "version": "2.8", |
| 186 | + "timestamp": 0, |
| 187 | + "isdebug": False, |
| 188 | + "osclass": ["centos"], |
| 189 | + "logo": { |
| 190 | + "checksum": "1471eb59356066ed4a06130566764ea6", |
| 191 | + "url": "http://10.1.0.53/catalog/logos/bluedata-spark240juphub7xssl-2.8", |
| 192 | + }, |
| 193 | + "documentation": { |
| 194 | + "checksum": "52f53f1b2845463b9e370d17fb80bea6", |
| 195 | + "mimetype": "text/markdown", |
| 196 | + "file": "/opt/bluedata/catalog/documentation/bluedata-spark240juphub7xssl-2.8", |
| 197 | + }, |
| 198 | + "state": "initialized", |
| 199 | + "state_info": "", |
| 200 | + } |
| 201 | + ] |
| 202 | + }, |
| 203 | + }, |
| 204 | + status_code=200, |
| 205 | + headers=dict(), |
| 206 | + ) |
| 207 | + raise RuntimeError("Unhandle GET request: " + args[0]) |
| 208 | + |
| 209 | + @patch("requests.get", side_effect=mocked_requests_get) |
| 210 | + @patch("requests.post", side_effect=mocked_requests_post) |
| 211 | + def test_list(self, mock_get, mock_post): |
| 212 | + |
| 213 | + catalogList = get_client().catalog.list() |
| 214 | + self.assertIsInstance(catalogList, CatalogList) |
0 commit comments