Fix build_cog_version_match test to match Python version comparison logic
The test was doing a simple string comparison between SemVer (Docker label)
and PEP440 (Python package) versions, which would incorrectly fail for valid
version pairs like:
- SemVer: 0.17.0-dev+g5e32d47d
- PEP440: 0.17.0a2.dev10+g5e32d47d2
This implements the full assert_versions_match logic from the original Python
test (test-integration/test_integration/util.py), which properly validates and
compares versions according to both SemVer and PEP440 specifications.