Tests
Comprehensive integration test suite for VersionControlManager class.
This module contains end-to-end integration tests for the VersionControlManager class, testing the complete semantic versioning workflow using a real Git repository. Unlike unit tests that mock Git operations, these tests create actual commits and tags to verify the complete functionality in a realistic environment.
Test Strategy
- Uses a real Git repository ('test_dir') for authentic testing
- Creates actual commits and tags to simulate real development workflow
- Tests complete semantic versioning lifecycle from development to production
- Validates error handling and business rule enforcement
- Covers edge cases and version bump scenarios
Workflow Coverage
- Development tag creation and incrementing (X.Y.Z-dev.N)
- Release candidate initialization and management (X.Y.Z-rc.N)
- Production tag creation from RC tags (X.Y.Z)
- Patch tag workflow for hotfixes (X.Y.Z-patch.N)
- Version bumping (minor and major)
- Error conditions and validation rules
Dependencies
- pytest: Testing framework for assertions and exception handling
- GitPython: Real Git operations (not mocked)
- os, sys, shutil: File system operations for test cleanup
Test Environment
- Creates temporary 'test_dir' Git repository
- Automatically cleans up test repository after completion
- Uses sequential test execution that builds upon previous states
Author: Sajin Vachery
InvalidTagCreation
Bases: Exception
Custom exception raised when attempting to create an invalid Git tag.
This exception is used to prevent the creation of tags that would violate the versioning rules enforced by the VersionControlManager class.
Source code in src/vcm/exceptions.py
1 2 3 4 5 6 7 8 9 | |
cli_parser()
Create an argument parser instance for testing CLI argument parsing.
Source code in tests/test_vcm.py
1046 1047 1048 1049 | |
create_parser()
Create and configure the argument parser.
Source code in src/vcm/cli.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
create_tag(tag)
Create a specific tag in the test repository.
This utility function creates a Git tag with the given name in the test repository. It's used to set up test scenarios that require specific tags to exist before testing VersionControlManager functionality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
The tag name to create (should follow semantic versioning) |
required |
Side Effects
- Creates a new Git tag in the test repository
- Tag points to the current HEAD commit
Note
This function bypasses VersionControlManager's validation and directly creates tags via GitPython, allowing test setup that might not be possible through the manager's normal workflow.
Source code in tests/test_vcm.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
create_tags()
Create a sequence of development tags for testing.
This setup function creates a series of development tags (1.0.0-dev.0 through 1.0.0-dev.9) with corresponding commits. This simulates a development workflow where multiple development iterations have occurred.
The function creates both commits and tags to establish a realistic repository state for testing tag management operations.
Side Effects
- Creates 10 empty commits in the repository
- Creates 10 development tags pointing to these commits
- Establishes a baseline for subsequent tag operations
Usage
Typically called once during test setup to create a repository state that allows testing of tag incrementing, RC creation, and other advanced operations.
Source code in tests/test_vcm.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
empty_commit()
Create an empty commit in the test repository.
This utility function creates a commit in the test repository without adding any files. It's used to advance the commit history so that new tags can be created at different commit points, simulating real development progress.
The function operates on the global 'test_dir' repository and is essential for tag creation since Git requires commits to exist before tags can be created.
Side Effects
- Creates a new commit in the test repository
- Advances the repository's commit history
- Enables subsequent tag creation
Source code in tests/test_vcm.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
get_repo_path()
Get the repository path, defaulting to current directory.
Source code in src/vcm/cli.py
20 21 22 | |
handle_create_prod_tag(args)
Handle create_prod_tag command.
Source code in src/vcm/cli.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
handle_get_current_rc_patch(args)
Handle get_current_rc_patch command.
Source code in src/vcm/cli.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
handle_get_current_tag(args)
Handle get_current_tag command.
Source code in src/vcm/cli.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
handle_increment_prerelease(args)
Handle increment_prerelease_tag command.
Source code in src/vcm/cli.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
handle_increment_rc_patch(args)
Handle increment_rc_patch command.
Source code in src/vcm/cli.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
handle_init_new_patch(args)
Handle init_new_patch command.
Source code in src/vcm/cli.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
handle_init_new_rc(args)
Handle init_new_rc command.
Source code in src/vcm/cli.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
main()
Main entry point for the CLI.
Source code in src/vcm/cli.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
mock_vcm()
Create a mock VersionControlManager for testing CLI operations.
Source code in tests/test_vcm.py
1038 1039 1040 1041 1042 1043 | |
test_cli_create_prod_tag_basic(mock_vcm)
Test basic create-prod CLI command functionality.
This test verifies that the create-prod command successfully promotes an RC or patch tag to production, creating a clean production version tag without prerelease identifiers.
Test Scenario
- Mock VCM returns production tag
- Parse command with RC tag to promote
- Verify production tag created and returned
- Confirm VCM called with source tag
Validates
- Production tag creation succeeds
- Prerelease identifier removed (rc.3 -> clean version)
- Source tag parameter parsed correctly
- Output contains only production tag
- Return code indicates success
Business Logic Tested
- handle_create_prod_tag() basic operation
- RC/patch to production promotion
- Prerelease identifier stripping
Source code in tests/test_vcm.py
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 | |
test_cli_create_prod_tag_invalid(mock_vcm)
Test create-prod command with invalid tag format.
This test verifies proper error handling when an invalid tag format is provided for production promotion, preventing corrupt production tags from being created and providing clear user feedback.
Test Scenario
- Mock VCM raises ValueError for invalid tag
- Execute command with malformed tag
- Capture stderr for error message
- Verify non-zero exit code
Validates
- ValueError from VCM caught and handled
- Error message includes validation details
- Error written to stderr (not stdout)
- Non-zero exit code (1) for error condition
- Error message mentions "Invalid tag format"
Business Logic Tested
- handle_create_prod_tag() error handling
- Tag format validation for production promotion
Source code in tests/test_vcm.py
1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 | |
test_cli_custom_prerelease_identifiers(mock_vcm)
Test CLI support for custom prerelease identifiers.
This test verifies that the CLI correctly handles different prerelease tag identifiers beyond the default 'dev', supporting flexible tagging strategies for different development workflows.
Test Scenarios
- Custom 'alpha' prerelease tag
- Custom 'beta' prerelease tag
- Custom 'staging' prerelease tag
- Parameter passing to VCM
Validates
- Flexible prerelease identifier support
- Parameter passing correctness
- Custom workflow support
- Consistent behavior across identifiers
Business Logic Tested
- Prerelease tag parameter handling
- Custom identifier support
- Parameter validation and passing
Source code in tests/test_vcm.py
1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 | |
test_cli_detailed_flag_consistency(mock_vcm)
Test --detailed flag behavior across different commands.
This test verifies that the --detailed flag is consistently implemented across all commands that support it, providing uniform user experience and predictable output formatting.
Test Scenario
- Test detailed output for multiple commands
- Verify descriptive messages are added
- Confirm tag values still present
- Check consistent message formatting
Validates
- Detailed flag adds descriptive context
- Tag values preserved in output
- Consistent message format
- No functionality breakage
Business Logic Tested
- Detailed flag implementation
- Conditional output formatting
- User experience consistency
Source code in tests/test_vcm.py
1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 | |
test_cli_error_handling_comprehensive()
Comprehensive test of CLI error handling scenarios.
This test validates that the CLI properly handles all types of errors that can occur during operation, ensuring users get clear feedback and the CLI never crashes unexpectedly.
Test Scenarios
- ValueError from invalid input
- Missing repository
- Missing required arguments
- Invalid command
- General exceptions
Validates
- All error types handled gracefully
- Clear error messages provided
- Appropriate exit codes
- No uncaught exceptions
- Stderr used for all errors
Business Logic Tested
- Comprehensive error handling
- Error message clarity
- Exit code conventions
- User experience during errors
Source code in tests/test_vcm.py
1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 | |
test_cli_get_current_rc_patch_rc(mock_vcm)
Test get-current-rc-patch command for RC tags.
This test verifies that the get-current-rc-patch command correctly retrieves the highest RC tag for a given base version, useful for determining which RC iteration is current before promoting to production.
Test Scenario
- Mock VCM returns highest RC tag for version
- Parse command with base version and rc type
- Verify correct RC tag returned
- Confirm VCM called with proper parameters
Validates
- RC tag retrieval for specific version
- Base version parameter parsed correctly
- Default prerelease type ('rc') used
- Highest RC number returned when multiple exist
- Return code indicates success
Business Logic Tested
- handle_get_current_rc_patch() RC mode
- Version-specific tag filtering
Source code in tests/test_vcm.py
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 | |
test_cli_get_current_tag_basic(mock_vcm)
Test basic get-current-tag CLI command functionality.
This test verifies that the get-current-tag command correctly calls the VersionControlManager with default parameters and returns the current tag without additional formatting when the --detailed flag is not used.
Test Scenario
- Mock VCM returns a development tag
- Parse get-current-tag command with default options
- Capture stdout to verify output format
- Verify VCM called with correct parameters
- Verify clean output (just the tag, no additional text)
Validates
- Basic command execution without errors
- Correct default parameter values (prerelease_tag='dev', production=False)
- Output contains only the tag value
- Return code indicates success (0)
Business Logic Tested
- handle_get_current_tag() with default arguments
- Simple output format for scripting use cases
Source code in tests/test_vcm.py
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 | |
test_cli_get_current_tag_detailed(mock_vcm)
Test get-current-tag command with detailed output flag.
This test verifies that the --detailed flag produces human-readable output with descriptive context about what tag was found, useful for interactive use cases where users need confirmation of what the command did.
Test Scenario
- Mock VCM returns a development tag
- Parse command with --detailed flag
- Capture and verify output includes descriptive message
- Confirm VCM called correctly
Validates
- Detailed output format includes descriptive prefix
- Tag value still present in output
- --detailed flag properly parsed and handled
- Return code indicates success
Business Logic Tested
- handle_get_current_tag() detailed output mode
- User-friendly messaging for interactive usage
Source code in tests/test_vcm.py
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 | |
test_cli_get_current_tag_no_tags(mock_vcm)
Test get-current-tag command when no matching tags exist.
This test verifies proper error handling when the repository has no tags matching the requested criteria. It ensures the CLI provides a clear error message and returns an appropriate exit code for scripting.
Test Scenario
- Mock VCM returns None (no tags found)
- Execute get-current-tag command
- Capture stderr for error message
- Verify non-zero exit code
Validates
- None return value handled gracefully
- Error message written to stderr (not stdout)
- Non-zero exit code (1) for error condition
- Error message is clear and actionable
Business Logic Tested
- handle_get_current_tag() error handling
- Empty repository scenario
- Proper stderr vs stdout usage
Source code in tests/test_vcm.py
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 | |
test_cli_get_current_tag_production(mock_vcm)
Test get-current-tag command with production flag.
This test verifies that the --production flag correctly requests production tags instead of prerelease tags, allowing users to query the latest production release without prerelease identifiers.
Test Scenario
- Mock VCM returns a production tag
- Parse command with --production flag
- Verify VCM called with production=True
- Confirm output contains production tag
Validates
- --production flag properly parsed
- Production parameter passed to VCM correctly
- Production tags returned without prerelease identifiers
- Return code indicates success
Business Logic Tested
- handle_get_current_tag() production mode
- Production vs prerelease tag filtering
Source code in tests/test_vcm.py
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 | |
test_cli_increment_prerelease_basic(mock_vcm)
Test basic increment-prerelease CLI command functionality.
This test verifies that the increment-prerelease command correctly increments a prerelease tag and returns the new tag value. Tests the most common use case of incrementing from an existing tag.
Test Scenario
- Mock VCM returns incremented tag
- Parse command with base tag
- Verify new tag created and returned
- Confirm VCM called with correct parameters
Validates
- Tag increment operation succeeds
- Prerelease identifier passed correctly
- Output contains only new tag (for scripting)
- Major bump defaulted to False
- Return code indicates success
Business Logic Tested
- handle_increment_prerelease() basic operation
- Tag parameter parsing and passing
- Default prerelease identifier ('dev')
Source code in tests/test_vcm.py
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 | |
test_cli_increment_prerelease_invalid_tag(mock_vcm)
Test increment-prerelease command with invalid tag format.
This test verifies proper error handling when an invalid semantic version tag is provided, ensuring users get clear feedback about tag format requirements and preventing corrupt tags from being created.
Test Scenario
- Mock VCM raises ValueError for invalid tag
- Execute command with malformed tag
- Capture stderr for error message
- Verify non-zero exit code
Validates
- ValueError from VCM caught and handled
- Error message includes validation details
- Error written to stderr (not stdout)
- Non-zero exit code (1) for error condition
- Error message mentions "Invalid tag format"
Business Logic Tested
- handle_increment_prerelease() error handling
- Tag format validation and error reporting
Source code in tests/test_vcm.py
1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 | |
test_cli_increment_prerelease_major_bump(mock_vcm)
Test increment-prerelease command with major version bump.
This test verifies that the --major-bump flag correctly triggers a major version increment instead of the default minor increment, useful for breaking changes or significant new features.
Test Scenario
- Mock VCM returns major-bumped tag
- Parse command with --major-bump flag
- Verify major_bump=True passed to VCM
- Confirm major version incremented in result
Validates
- --major-bump flag properly parsed
- Major bump parameter passed to VCM
- Major version incremented (0.x.x -> 1.x.x)
- Minor version reset in result
- Return code indicates success
Business Logic Tested
- handle_increment_prerelease() major bump mode
- Semantic versioning major increment rules
Source code in tests/test_vcm.py
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 | |
test_cli_increment_rc_patch_rc(mock_vcm)
Test increment-rc-patch command for RC tags.
This test verifies that the increment-rc-patch command successfully increments an RC tag, creating the next RC iteration for a version. Useful when additional release candidate testing cycles are needed.
Test Scenario
- Mock VCM returns incremented RC tag
- Parse command with base version and rc type
- Verify new RC tag created and returned
- Confirm VCM called with correct parameters
Validates
- RC tag increment succeeds
- Base version preserved (1.0.0)
- RC number incremented (rc.3 -> rc.4)
- Default prerelease type used correctly
- Return code indicates success
Business Logic Tested
- handle_increment_rc_patch() RC mode
- RC iteration increment logic
Source code in tests/test_vcm.py
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 | |
test_cli_init_new_patch_basic(mock_vcm)
Test basic init-patch CLI command functionality.
This test verifies that the init-patch command successfully creates a new patch prerelease tag from the latest production tag, enabling hotfix workflows for addressing production issues.
Test Scenario
- Mock VCM returns new patch tag
- Parse init-patch command
- Verify patch tag created and returned
- Confirm VCM called correctly
Validates
- Patch initialization succeeds
- Output contains only new patch tag
- Tag follows patch naming convention (x.y.z-patch.1)
- Return code indicates success
Business Logic Tested
- handle_init_new_patch() basic operation
- Production to patch transition
- Initial patch tag creation
Source code in tests/test_vcm.py
1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 | |
test_cli_init_new_rc_basic(mock_vcm)
Test basic init-rc CLI command functionality.
This test verifies that the init-rc command successfully creates a new release candidate tag from the latest development tag, marking the transition from development to release candidate phase.
Test Scenario
- Mock VCM returns new RC tag
- Parse init-rc command with defaults
- Verify RC tag created and returned
- Confirm VCM called with correct parameters
Validates
- RC initialization succeeds
- Default prerelease identifier ('dev') used
- Output contains only new RC tag
- Tag follows RC naming convention (x.y.z-rc.1)
- Return code indicates success
Business Logic Tested
- handle_init_new_rc() basic operation
- Development to RC transition
- Initial RC tag creation (rc.1)
Source code in tests/test_vcm.py
1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 | |
test_cli_init_new_rc_no_dev_tag(mock_vcm)
Test init-rc command when no development tag exists.
This test verifies proper error handling when attempting to create an RC tag but no development tags exist in the repository, preventing invalid RC creation and providing clear guidance to users.
Test Scenario
- Mock VCM returns None (no dev tag found)
- Execute init-rc command
- Capture stderr for error message
- Verify non-zero exit code
Validates
- None return value handled gracefully
- Error message explains missing dev tag
- Error written to stderr
- Non-zero exit code (1) for error condition
- Error message is actionable
Business Logic Tested
- handle_init_new_rc() error handling
- Prerequisite validation (dev tag must exist)
Source code in tests/test_vcm.py
1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | |
test_cli_output_format_scriptability()
Test that CLI output is easily scriptable and parseable.
This test verifies that the CLI produces clean, parseable output when the --detailed flag is not used, making it suitable for use in scripts and automation.
Test Scenarios
- Basic output contains only tag value
- No extra whitespace or formatting
- Consistent output format
- Easy to parse in shell scripts
Validates
- Clean output for scripting
- No extra formatting characters
- Consistent line endings
- Single-line output for tag values
Business Logic Tested
- Output formatting for automation
- Scriptability considerations
- Clean data extraction
Source code in tests/test_vcm.py
1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 | |
test_cli_parser_structure(cli_parser)
Test CLI argument parser structure and configuration.
This test verifies that the argument parser is properly configured with all expected commands and options, ensuring complete CLI functionality is available.
Test Scenario
- Verify parser description exists
- Check all subcommands are registered
- Validate command structure
Validates
- Parser has help functionality
- All expected commands exist
- Subparser structure is correct
- Command names follow conventions
Business Logic Tested
- create_parser() configuration
- Subcommand registration
- CLI structure completeness
Source code in tests/test_vcm.py
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | |
test_complete_multi_version_workflow()
Test complete multi-version development workflow.
This comprehensive test simulates a realistic multi-version development scenario with overlapping releases, patches, and development cycles. It validates the complete system behavior over an extended period.
Test Workflow
- Complete 2.1.0 release cycle (RC → production)
- Start 2.2.0 development with minor bump
- Create patch for 2.1.0 while 2.2.0 development continues
- Start major 3.0.0 development cycle
- Validate all version families coexist correctly
Validates
- Multi-version workflow management
- Version family independence
- Concurrent development and patch workflows
- Long-term version history integrity
- Complex version state management
Business Logic Tested
- Complete workflow cycles across multiple versions
- Version family separation and coexistence
- Long-term tag management and retrieval
- Complex version state scenarios
Source code in tests/test_vcm.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | |
test_create_prod_from_patch()
Test production tag creation from patch prerelease.
This test verifies the VersionControlManager's ability to promote a tested patch prerelease to a production patch version. This completes the hotfix workflow by creating an official patch release.
Test Scenario
- Promote patch "1.0.0-patch.2" to production "1.0.1"
Validates
- Patch to production tag conversion
- Automatic patch number increment (1.0.0 → 1.0.1)
- Hotfix workflow completion
- Production tag creation with proper commit reference
Business Logic Tested
- create_prod_tag() method with patch prerelease parameter
- Patch version incrementing rules
- Production tag naming for patches
- Hotfix to production workflow transition
Workflow Context
This represents the completion of a hotfix cycle where a thoroughly tested patch is promoted to production, creating an official patch release (1.0.1) that fixes issues in 1.0.0.
Source code in tests/test_vcm.py
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
test_current_tag()
Test current tag retrieval functionality.
This test verifies the VersionControlManager's ability to identify and return the current highest development tag. It tests both empty repository scenarios and repositories with multiple development tags.
Test Scenario
- Start with empty repository (should return None)
- Create first development tag and verify retrieval
- Create multiple development tags and verify highest is returned
Validates
- Empty repository handling (returns None)
- Initial tag creation (0.1.0-dev.1)
- Highest tag identification from multiple options
- Semantic version sorting (1.0.0-dev.9 > 0.1.0-dev.1)
Business Logic Tested
- get_current_tag() with default "dev" prerelease identifier
- increment_prerelease_tag() initial tag creation
- Proper semantic version comparison and sorting
Source code in tests/test_vcm.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
test_edge_cases_and_boundaries()
Test edge cases and boundary conditions.
This test covers various edge cases that might occur in real-world usage, ensuring the VersionControlManager is robust and handles unusual but valid scenarios correctly.
Test Scenarios
- Version number boundaries (0.0.0, high numbers)
- Empty repository initialization
- Tag creation from initial state
- Pattern matching edge cases
Validates
- Robustness with edge case version numbers
- Proper handling of empty repository states
- Initial tag creation workflows
- Pattern matching accuracy with various formats
Business Logic Tested
- Version number parsing and validation
- Initial state handling
- Pattern matching reliability
- Boundary condition handling
Source code in tests/test_vcm.py
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | |
test_find_tag()
Test tag existence checking functionality.
This test verifies the VersionControlManager's ability to check whether specific tags exist in the repository. It tests both positive (tag exists) and negative (tag doesn't exist) cases.
Test Scenarios
- Search for non-existent tag (should return False)
- Search for existing tag (should return True)
Validates
- Accurate tag existence detection
- Case-sensitive tag name matching
- Repository tag collection querying
Business Logic Tested
- find_tag() method with exact tag name matching
- Repository tag enumeration and comparison
- Boolean return values for existence checks
Source code in tests/test_vcm.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
test_get_current_patch()
Test patch tag retrieval for versions without patches.
This test verifies that the VersionControlManager correctly handles queries for patch tags when no patch versions exist. This establishes the baseline before patch tag creation and tests proper None handling.
Test Scenarios
- Query patch for version "1.0.0" (production exists, no patches)
- Query patch for version "1.1.0" (no production, no patches)
Both should return None since no patch tags exist yet.
Validates
- Proper None return for non-existent patch tags
- Patch tag querying for different version states
- Baseline establishment for patch workflow testing
Business Logic Tested
- get_current_rc_patch() method with "patch" prerelease type
- Pattern matching for patch tags
- Handling of non-existent tag scenarios
Source code in tests/test_vcm.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
test_get_current_production_tag()
Test current production tag retrieval.
This test verifies the VersionControlManager's ability to identify and return the current highest production version. This is essential for various operations including patch initialization and version management.
Test Scenario
- Retrieve current production tag (should be "1.0.1" after patch)
Validates
- Production tag identification
- Highest production version selection
- Patch version recognition as production
- Production tag querying functionality
Business Logic Tested
- get_current_tag() method with production=True parameter
- Production tag pattern matching
- Semantic version sorting for production tags
- Production version history tracking
Workflow Context
After creating patch version 1.0.1, it should be recognized as the current production version, taking precedence over 1.0.0.
Source code in tests/test_vcm.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
test_get_current_rc()
Test current release candidate retrieval for specific version.
This test verifies the VersionControlManager's ability to find the current (highest) release candidate tag for a specific base version. This is essential for RC management and incrementing operations.
Test Scenario
- Retrieve current RC for base version "1.0.0"
- Should return "1.0.0-rc.1" (the existing RC tag)
Validates
- Base version to RC tag mapping
- Current RC identification for specific versions
- Proper pattern matching for RC tags
Business Logic Tested
- get_current_rc_patch() method with RC prerelease type
- Version-specific tag pattern matching
- Highest RC tag identification within version family
Source code in tests/test_vcm.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
test_get_init_rc_tag()
Test release candidate tag generation from development tags.
This test verifies the static utility method that converts development tags into their corresponding initial release candidate tags. This is a crucial step in the development → RC → production workflow.
Test Scenario
- Convert development tag "1.0.0-dev.10" to RC tag "1.0.0-rc.1"
Validates
- Proper tag format conversion (dev.N → rc.1)
- Preservation of major.minor.patch version
- Static method functionality (no repository interaction)
- Semantic versioning rule compliance
Business Logic Tested
- get_init_rc_tag() static method
- Development to RC tag transformation logic
- Version number parsing and reconstruction
Source code in tests/test_vcm.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | |
test_increment_dev_after_prod_release()
Test development tag incrementing after production release.
This test verifies the VersionControlManager's ability to continue development work after a production release by automatically bumping to the next minor version for new development work. This ensures clear separation between released and unreleased code.
Test Scenario
- Current dev tag is "1.0.0-dev.10" (same version as production "1.0.0")
- Incrementing should jump to "1.1.0-dev.1" (next minor version)
Validates
- Automatic minor version bump when production version exists
- Prevention of dev tag confusion with released versions
- Proper version increment logic (1.0.x → 1.1.0)
- Development workflow continuation after release
Business Logic Tested
- increment_prerelease_tag() version bump logic
- Production version conflict detection
- Minor version incrementing rules
- Development tag reset to .1 after version bump
Workflow Context
This simulates the common scenario where development continues after a release, requiring a clear version separation between the released code and new development work.
Source code in tests/test_vcm.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
test_increment_patch()
Test patch tag incrementing during hotfix development.
This test verifies the VersionControlManager's ability to increment patch prerelease tags during hotfix development iterations. This allows multiple rounds of fixes and testing before the hotfix is released.
Test Scenario
- Increment patch from "1.0.0-patch.1" to "1.0.0-patch.2"
Validates
- Patch prerelease number incrementing (patch.1 → patch.2)
- Preservation of base production version (1.0.0)
- Hotfix iteration support
- Tag creation in repository
Business Logic Tested
- increment_rc_patch() method with patch prerelease type
- Patch tag incrementing logic
- Hotfix development workflow support
- Prerelease number management for patches
Workflow Context
This simulates additional iterations in hotfix development, where multiple patch versions might be needed before the fix is ready for production deployment.
Source code in tests/test_vcm.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
test_increment_patch_exception()
Test error handling for invalid patch increment attempts.
This test verifies that the VersionControlManager enforces the business rule that patch tags can only be created for versions that have been released to production. This prevents patch creation for unreleased versions, maintaining version integrity.
Test Scenario
- Attempt to create patch for version "1.1.0" (no production version)
- Should raise InvalidTagCreation exception
Validates
- Business rule enforcement (patches require production version)
- Proper exception raising for invalid operations
- Production version prerequisite checking
- Error message clarity for debugging
Business Logic Tested
- increment_rc_patch() validation with patch type
- InvalidTagCreation exception for rule violations
- Production version existence validation
- Patch creation prerequisites
Error Scenario
Documents the rule: "No Production version available" - patches can only be created for versions that have been officially released.
Source code in tests/test_vcm.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
test_increment_prerelease_tag()
Test prerelease tag incrementing functionality.
This test verifies that the VersionControlManager can correctly increment the prerelease number of an existing development tag while maintaining the same major.minor.patch version numbers.
Test Scenario
- Increment from existing tag "1.0.0-dev.9" to "1.0.0-dev.10"
- Verify the new tag becomes the current highest tag
Validates
- Prerelease number incrementing (9 → 10)
- Tag creation in repository
- Updated current tag retrieval
- Preservation of major.minor.patch version
Business Logic Tested
- increment_prerelease_tag() with existing tag parameter
- Proper prerelease number parsing and incrementing
- Tag creation and registration in repository
Source code in tests/test_vcm.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
test_increment_rc()
Test release candidate tag incrementing.
This test verifies the VersionControlManager's ability to create subsequent release candidate versions when additional RC iterations are needed during the testing and stabilization phase.
Test Scenario
- Increment RC from "1.0.0-rc.1" to "1.0.0-rc.2"
- Verify new RC becomes the current RC for the version
Validates
- RC prerelease number incrementing (rc.1 → rc.2)
- Preservation of base version (1.0.0)
- Tag creation in repository
- Updated current RC retrieval
Business Logic Tested
- increment_rc_patch() method with RC prerelease type
- RC tag incrementing logic
- Current RC tag updating after increment
Workflow Context
This simulates the scenario where an RC needs additional iterations due to bugs found during testing, requiring RC.2, RC.3, etc.
Source code in tests/test_vcm.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
test_increment_rc_exception()
Test error handling for invalid RC increment attempts.
This test verifies that the VersionControlManager properly enforces business rules by preventing RC tag creation when a production version already exists for the same version number. This prevents accidental regression or confusion in the versioning workflow.
Test Scenario
- Attempt to increment RC for version "1.0.0" (production exists)
- Should raise InvalidTagCreation exception
Validates
- Business rule enforcement (no RC after production)
- Proper exception raising and type
- Error message clarity and helpfulness
- Repository state validation before tag creation
Business Logic Tested
- increment_rc_patch() validation logic
- InvalidTagCreation exception handling
- Production version existence checking
- Business rule compliance enforcement
Error Scenario
This test documents the rule: "Cannot increment RC version for a version found in Production" - once a version goes to production, no more RCs can be created for that version.
Source code in tests/test_vcm.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
test_init_new_patch()
Test patch tag initialization for hotfix workflow.
This test verifies the VersionControlManager's ability to initialize the patch workflow for production hotfixes. This creates the first patch prerelease tag based on the current production version, enabling hotfix development.
Test Scenario
- Initialize patch from current production (should be "1.0.0")
- Should create "1.0.0-patch.1" for hotfix development
Validates
- Patch initialization from production version
- Proper patch tag naming (version-patch.1)
- Hotfix workflow establishment
- Current production version detection
Business Logic Tested
- init_new_patch() method
- Production to patch workflow transition
- Patch tag creation with proper commit reference
- Hotfix development setup
Workflow Context
This represents the beginning of a hotfix process where a critical bug in production needs to be addressed without waiting for the next major release cycle.
Source code in tests/test_vcm.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
test_init_new_rc()
Test release candidate initialization from current development tag.
This test verifies the VersionControlManager's ability to create the first release candidate tag based on the highest existing development tag. This represents a key milestone in the development workflow where development is considered feature-complete and ready for testing.
Test Scenario
- Initialize RC from current development tag (1.0.0-dev.10)
- Verify RC tag creation (1.0.0-rc.1)
- Confirm RC becomes current RC tag
Validates
- RC initialization from development tag
- Proper RC tag naming (major.minor.patch-rc.1)
- Tag creation in repository with appropriate commit reference
- Current RC tag retrieval functionality
Business Logic Tested
- init_new_rc() method with development prerelease parameter
- Development to RC workflow transition
- Tag creation with commit referencing
- RC tag identification and retrieval
Source code in tests/test_vcm.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
test_invalid_tag_format_handling()
Test handling of invalid tag formats and edge cases.
This test validates that the VersionControlManager properly handles and rejects invalid tag formats, maintaining system integrity and providing clear error messages.
Test Scenarios
- Invalid prerelease tag formats
- Invalid production tag formats
- Malformed version numbers
- Edge case version patterns
Validates
- Proper ValueError raising for invalid formats
- Input validation before tag operations
- Error message clarity and helpfulness
- System protection against malformed inputs
Business Logic Tested
- Tag format validation across all methods
- ValueError exception handling
- Input sanitization and validation
- Format compliance enforcement
Source code in tests/test_vcm.py
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
test_major_bump()
Test complete major version bump workflow.
This comprehensive test verifies the VersionControlManager's ability to handle a complete major version bump scenario, simulating a development cycle that includes breaking changes requiring a major version increment.
Test Workflow
- Start with current dev tag "1.1.0-dev.1"
- Increment to "1.1.0-dev.2" (normal development)
- Create RC "1.1.0-rc.1" and promote to production "1.1.0"
- Perform major bump to "2.0.0-dev.1" (breaking changes)
- Verify new major version becomes current
Validates
- Complete development cycle (dev → RC → production)
- Major version bumping logic (1.x.x → 2.0.0)
- Version reset behavior (minor and patch reset to 0)
- Development tag reset to .1 after major bump
- Production version progression (1.0.1 → 1.1.0 → current)
Business Logic Tested
- increment_prerelease_tag() normal and major bump modes
- init_new_rc() and create_prod_tag() workflow
- Major version bump with major_bump=True parameter
- Version number reset rules for major bumps
- Current tag tracking across version families
Workflow Context
This simulates a complete development cycle where significant breaking changes necessitate a major version increment, following semantic versioning principles where major bumps indicate backward-incompatible changes.
Source code in tests/test_vcm.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 | |
test_multiple_rc_iterations()
Test multiple release candidate iterations before production.
This test simulates a realistic scenario where multiple RC versions are needed due to bugs found during testing. It validates the complete RC iteration workflow and proper version incrementing.
Test Workflow
- Create multiple RC iterations (rc.1 → rc.2 → rc.3)
- Verify each increment is properly tracked
- Promote final RC to production
- Verify production version is correct
Validates
- Multiple RC increments within same version
- RC version tracking and retrieval
- Final RC promotion to production
- Version consistency throughout process
Business Logic Tested
- increment_rc_patch() multiple iterations
- get_current_rc_patch() after each increment
- create_prod_tag() from any RC iteration
- RC workflow resilience with multiple iterations
Source code in tests/test_vcm.py
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 | |
test_parallel_development_after_release()
Test parallel development workflow after production release.
This test simulates a realistic scenario where development continues in parallel with production releases and hotfixes. It validates that development can proceed independently while production versions are being patched.
Test Workflow
- Continue development after 2.0.0 release (should bump to 2.1.0-dev.1)
- Create multiple development iterations
- While dev continues, ensure patch workflow still works
- Create RC from latest development
- Validate version separation and independence
Validates
- Development continuation after production release
- Proper minor version bump for new development
- Independence of dev and patch workflows
- Version family separation (2.0.x patches vs 2.1.x development)
- Multiple concurrent version tracks
Business Logic Tested
- increment_prerelease_tag() with automatic version bump detection
- Parallel workflow support (dev vs patch)
- Version family isolation
- Current tag tracking across different version families
Source code in tests/test_vcm.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 | |
test_patch_workflow_comprehensive()
Test comprehensive patch workflow with multiple iterations.
This test validates the complete patch/hotfix workflow including multiple patch iterations, proper version incrementing, and integration with the existing production version history.
Test Workflow
- Create initial patch from production 2.0.0
- Increment patch multiple times (simulating hotfix development)
- Promote patch to production (creates 2.0.1)
- Create another patch series for 2.0.1
- Validate version progression and current version tracking
Validates
- Patch initialization from any production version
- Multiple patch increments within same base version
- Patch promotion creating proper production increment
- Ability to patch the patched version
- Production version progression (2.0.0 → 2.0.1 → 2.0.2)
Business Logic Tested
- init_new_patch() from latest production
- increment_rc_patch() with patch type multiple times
- create_prod_tag() from patch creating incremented production
- Patch workflow on previously patched versions
Source code in tests/test_vcm.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | |
test_prod_release()
Test production tag creation from release candidate.
This test verifies the final step in the development workflow: promoting a tested and approved release candidate to a production version. This represents the official release of the software version.
Test Scenario
- Promote RC tag "1.0.0-rc.2" to production tag "1.0.0"
Validates
- RC to production tag conversion
- Removal of prerelease suffix (-rc.2 → "")
- Tag creation with proper commit reference
- Production tag format compliance
Business Logic Tested
- create_prod_tag() method with RC tag parameter
- RC to production workflow transition
- Production tag naming rules
- Commit reference preservation during promotion
Workflow Context
This represents the culmination of the development cycle where a thoroughly tested RC is deemed ready for production deployment.
Source code in tests/test_vcm.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
test_repository_state_integrity()
Test repository state integrity throughout complex operations.
This test validates that the VersionControlManager maintains repository integrity and consistency throughout complex operation sequences. It ensures no orphaned tags or inconsistent states are created.
Test Scenarios
- Verify all created tags exist in repository
- Validate tag-commit relationships
- Check version history consistency
- Ensure no duplicate or conflicting tags
Validates
- Repository tag integrity
- Consistent tag-commit relationships
- Version history accuracy
- No duplicate or orphaned tags
Business Logic Tested
- find_tag() accuracy for all created tags
- Repository state consistency
- Tag creation integrity
- Version tracking accuracy
Source code in tests/test_vcm.py
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | |
test_version_conflict_prevention()
Test version conflict prevention and validation rules.
This test validates all the business rules that prevent invalid version states and conflicts in the semantic versioning workflow. It ensures proper error handling and validation.
Test Scenarios
- Try to create RC when production already exists
- Try to create patch when no production exists
- Try to increment patch when higher patch exists in production
- Validate proper exception messages and types
Validates
- Business rule enforcement prevents invalid states
- Proper exception types (InvalidTagCreation)
- Clear error messages for debugging
- Version state validation before tag creation
Business Logic Tested
- increment_rc_patch() validation rules
- InvalidTagCreation exception handling
- Production version conflict detection
- Patch prerequisite validation
Source code in tests/test_vcm.py
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
test_zzz_cleanup()
Final test to cleanup test repository.
This test runs last (due to zzz_ prefix) and ensures the test directory is cleaned up after all tests complete. This prevents accumulation of test artifacts and ensures clean test runs.
Cleanup Process
- Checks if test_dir exists
- Removes entire directory tree
- Ensures no test artifacts remain
Note
This test must run last, hence the zzz_ prefix which sorts alphabetically after all other tests.
Source code in tests/test_vcm.py
1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 | |