|
17 | 17 | from codemagic.google.services.firebase import ReleasesService |
18 | 18 | from codemagic.tools.firebase_app_distribution import FirebaseAppDistribution |
19 | 19 | from codemagic.tools.firebase_app_distribution.argument_types import CredentialsArgument |
| 20 | +from codemagic.tools.firebase_app_distribution.argument_types import ReleasesOrderByArgument |
20 | 21 | from codemagic.tools.firebase_app_distribution.arguments import FirebaseArgument |
21 | 22 | from codemagic.tools.firebase_app_distribution.errors import FirebaseAppDistributionError |
22 | 23 |
|
|
26 | 27 | json_output_argument = FirebaseArgument.JSON_OUTPUT |
27 | 28 |
|
28 | 29 |
|
| 30 | +@pytest.mark.parametrize( |
| 31 | + ("argument", "expected_order_by", "expected_cli_token"), |
| 32 | + ( |
| 33 | + (ReleasesOrderByArgument.CREATE_TIME_DESC, OrderBy.CREATE_TIME_DESC, "createTimeDesc"), |
| 34 | + (ReleasesOrderByArgument.CREATE_TIME_ASC, OrderBy.CREATE_TIME_ASC, "createTime"), |
| 35 | + ), |
| 36 | +) |
| 37 | +def test_releases_order_by_argument(argument, expected_order_by, expected_cli_token): |
| 38 | + # CLI parameter value stays a single, backwards-compatible token and maps to the API-facing OrderBy. |
| 39 | + assert argument.value == expected_cli_token |
| 40 | + assert argument.order_by is expected_order_by |
| 41 | + |
| 42 | + |
| 43 | +def test_every_releases_order_by_argument_maps_to_order_by(): |
| 44 | + # Guards against adding a CLI ordering choice without a matching API-facing OrderBy member. |
| 45 | + for argument in ReleasesOrderByArgument: |
| 46 | + assert isinstance(argument.order_by, OrderBy) |
| 47 | + |
| 48 | + |
29 | 49 | @pytest.fixture |
30 | 50 | def releases() -> List[Release]: |
31 | 51 | mock_response_path = pathlib.Path(__file__).parent / "mocks" / "firebase_releases.json" |
|
0 commit comments