-
Notifications
You must be signed in to change notification settings - Fork 32
♻️✅ invitations service: small refactoring and cleanup #7945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pcrespov
merged 6 commits into
ITISFoundation:master
from
pcrespov:is7932/credits-invitation-link
Jun 23, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4dd6556
adds test
pcrespov 5423f04
enhances tests by adding extra credits handling and updating validati…
pcrespov e44d70e
adapt test
pcrespov e0305f0
minor
pcrespov 56c9701
Extends CLI
pcrespov 696a661
increased converage and dropped serve CLI
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,19 +45,24 @@ def test_invite_user_and_check_invitation( | |
| "INVITATIONS_DEFAULT_PRODUCT": default_product, | ||
| } | ||
|
|
||
| expected = { | ||
| expected_invitation = { | ||
| **invitation_data.model_dump(exclude={"product"}), | ||
| "product": environs["INVITATIONS_DEFAULT_PRODUCT"], | ||
| } | ||
|
|
||
| # invitations-maker invite [email protected] --issuer=me --trial-account-days=3 | ||
| trial_account = "" | ||
| other_options = "" | ||
| if invitation_data.trial_account_days: | ||
| trial_account = f"--trial-account-days={invitation_data.trial_account_days}" | ||
| other_options = f"--trial-account-days={invitation_data.trial_account_days}" | ||
|
|
||
| if invitation_data.extra_credits_in_usd: | ||
| other_options += ( | ||
| f" --extra-credits-in-usd={invitation_data.extra_credits_in_usd}" | ||
| ) | ||
|
|
||
| result = cli_runner.invoke( | ||
| main, | ||
| f"invite {invitation_data.guest} --issuer={invitation_data.issuer} {trial_account}", | ||
| f"invite {invitation_data.guest} --issuer={invitation_data.issuer} {other_options}", | ||
| env=environs, | ||
| ) | ||
| assert result.exit_code == os.EX_OK, result.output | ||
|
|
@@ -73,7 +78,7 @@ def test_invite_user_and_check_invitation( | |
| ) | ||
| assert result.exit_code == os.EX_OK, result.output | ||
| assert ( | ||
| expected | ||
| expected_invitation | ||
| == TypeAdapter(InvitationInputs).validate_json(result.stdout).model_dump() | ||
| ) | ||
|
|
||
|
|
@@ -99,3 +104,24 @@ def test_list_settings(cli_runner: CliRunner, app_environment: EnvVarsDict): | |
| print(result.output) | ||
| settings = ApplicationSettings.model_validate_json(result.output) | ||
| assert settings == ApplicationSettings.create_from_envs() | ||
|
|
||
|
|
||
| def test_extract_invalid_invitation_code( | ||
| cli_runner: CliRunner, faker: Faker, app_environment: EnvVarsDict | ||
| ): | ||
| """Test that extract command handles invalid invitation codes properly""" | ||
| # Create an invalid invitation URL | ||
| invalid_invitation_url = f"{faker.url()}#invitation=invalid_code_123" | ||
|
|
||
| # Run extract command with invalid invitation URL | ||
| result = cli_runner.invoke( | ||
| main, | ||
| f'extract "{invalid_invitation_url}"', | ||
| env=app_environment, | ||
| ) | ||
|
|
||
| # Verify command exits with correct error code | ||
| assert result.exit_code == os.EX_DATAERR | ||
|
|
||
| # Verify error message is displayed via stderr | ||
| assert "Invalid code" in result.stdout | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.