|
6 | 6 | import pytest |
7 | 7 |
|
8 | 8 | from utils.chooser import VersionChooser |
| 9 | +from utils.dockerhub import TagFetcher, TagMetadata |
9 | 10 |
|
10 | 11 | # All test coroutines will be treated as marked. |
11 | 12 | pytestmark = pytest.mark.asyncio |
@@ -236,3 +237,41 @@ async def is_valid_version(image: str) -> Tuple[bool, str]: |
236 | 237 | result = await chooser.set_version("bluerobotics/blueos-core", "master") |
237 | 238 | assert result.status_code == 500 |
238 | 239 | assert len(json_mock.mock_calls) > 0 |
| 240 | + |
| 241 | + |
| 242 | +class TestTagFetcher: |
| 243 | + """Test class for TagFetcher functionality""" |
| 244 | + |
| 245 | + @pytest.mark.asyncio |
| 246 | + async def test_fetch_real_blueos_core_tags(self) -> None: |
| 247 | + """Integration test: Fetch real tags from bluerobotics/blueos-core repository""" |
| 248 | + fetcher = TagFetcher() |
| 249 | + |
| 250 | + try: |
| 251 | + errors, tags = await fetcher.fetch_remote_tags("bluerobotics/blueos-core", []) |
| 252 | + |
| 253 | + # Verify we got some tags back |
| 254 | + assert isinstance(tags, list) |
| 255 | + assert len(tags) > 0, "Should have found some tags for bluerobotics/blueos-core" |
| 256 | + |
| 257 | + # Verify tag structure |
| 258 | + for tag in tags[:3]: # Check first 3 tags |
| 259 | + assert isinstance(tag, TagMetadata) |
| 260 | + assert tag.repository == "bluerobotics/blueos-core" |
| 261 | + assert tag.image == "blueos-core" |
| 262 | + assert tag.tag is not None |
| 263 | + assert len(tag.tag) > 0 |
| 264 | + assert tag.last_modified is not None |
| 265 | + assert tag.digest is not None |
| 266 | + |
| 267 | + # Should find the 'master' tag |
| 268 | + tag_names = [tag.tag for tag in tags] |
| 269 | + assert "master" in tag_names, f"Expected to find 'master' tag in tags: {tag_names[:10]}" |
| 270 | + |
| 271 | + # Errors should be empty string if successful |
| 272 | + if errors: |
| 273 | + print(f"Non-fatal errors during fetch: {errors}") |
| 274 | + |
| 275 | + except Exception as e: |
| 276 | + # If this fails due to network issues, skip the test |
| 277 | + pytest.skip(f"Could not fetch tags from DockerHub, likely network issue: {e}") |
0 commit comments