Skip to content

Commit

Permalink
feat: added tests for Python ErrorEnums
Browse files Browse the repository at this point in the history
- added new test folder in python.
- added test for Python ErrorEnums

Signed-off-by: Jay <[email protected]>
  • Loading branch information
35C4n0r committed Oct 21, 2023
1 parent 812a6e6 commit 061fea8
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/SDK/Language/Python.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ public function getFiles(): array
'destination' => '.travis.yml',
'template' => 'python/.travis.yml.twig',
],
[
'scope' => 'default',
'destination' => 'test/{{ spec.title | caseSnake}}/test_exception.py',
'template' => 'python/test/package/test_exception.py.twig',
],
];
}

Expand Down
143 changes: 143 additions & 0 deletions templates/python/test/package/test_exception.py.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
from ...{{ spec.title | caseSnake}}.exception import ErrorType
import unittest


class TestErrorEnum(unittest.TestCase):

def test_enum_values(self):
self.assertEqual(ErrorType.GeneralMock.value, 'general_mock')
self.assertEqual(ErrorType.GeneralArgumentInvalid.value, 'general_argument_invalid')
self.assertEqual(ErrorType.GeneralQueryLimitExceeded.value, 'general_query_limit_exceeded')
self.assertEqual(ErrorType.GeneralQueryInvalid.value, 'general_query_invalid')
self.assertEqual(ErrorType.GeneralCursorNotFound.value, 'general_cursor_not_found')
self.assertEqual(ErrorType.UserPasswordMismatch.value, 'user_password_mismatch')
self.assertEqual(ErrorType.PasswordRecentlyUsed.value, 'password_recently_used')
self.assertEqual(ErrorType.PasswordPersonalData.value, 'password_personal_data')
self.assertEqual(ErrorType.UserPhoneNotFound.value, 'user_phone_not_found')
self.assertEqual(ErrorType.UserMissingId.value, 'user_missing_id')
self.assertEqual(ErrorType.UserOauth2BadRequest.value, 'user_oauth2_bad_request')
self.assertEqual(ErrorType.StorageDeviceNotFound.value, 'storage_device_not_found')
self.assertEqual(ErrorType.StorageFileEmpty.value, 'storage_file_empty')
self.assertEqual(ErrorType.StorageFileTypeUnsupported.value, 'storage_file_type_unsupported')
self.assertEqual(ErrorType.StorageInvalidFileSize.value, 'storage_invalid_file_size')
self.assertEqual(ErrorType.StorageInvalidContentRange.value, 'storage_invalid_content_range')
self.assertEqual(ErrorType.StorageInvalidAppwriteId.value, 'storage_invalid_appwrite_id')
self.assertEqual(ErrorType.GeneralProviderFailure.value, 'general_provider_failure')
self.assertEqual(ErrorType.BuildNotReady.value, 'build_not_ready')
self.assertEqual(ErrorType.BuildInProgress.value, 'build_in_progress')
self.assertEqual(ErrorType.CollectionLimitExceeded.value, 'collection_limit_exceeded')
self.assertEqual(ErrorType.DocumentInvalidStructure.value, 'document_invalid_structure')
self.assertEqual(ErrorType.DocumentMissingData.value, 'document_missing_data')
self.assertEqual(ErrorType.DocumentMissingPayload.value, 'document_missing_payload')
self.assertEqual(ErrorType.AttributeUnknown.value, 'attribute_unknown')
self.assertEqual(ErrorType.AttributeNotAvailable.value, 'attribute_not_available')
self.assertEqual(ErrorType.AttributeFormatUnsupported.value, 'attribute_format_unsupported')
self.assertEqual(ErrorType.AttributeDefaultUnsupported.value, 'attribute_default_unsupported')
self.assertEqual(ErrorType.AttributeLimitExceeded.value, 'attribute_limit_exceeded')
self.assertEqual(ErrorType.AttributeValueInvalid.value, 'attribute_value_invalid')
self.assertEqual(ErrorType.AttributeTypeInvalid.value, 'attribute_type_invalid')
self.assertEqual(ErrorType.IndexLimitExceeded.value, 'index_limit_exceeded')
self.assertEqual(ErrorType.IndexInvalid.value, 'index_invalid')
self.assertEqual(ErrorType.ProjectUnknown.value, 'project_unknown')
self.assertEqual(ErrorType.ProjectInvalidSuccessUrl.value, 'project_invalid_success_url')
self.assertEqual(ErrorType.ProjectInvalidFailureUrl.value, 'project_invalid_failure_url')
self.assertEqual(ErrorType.ProjectReservedProject.value, 'project_reserved_project')
self.assertEqual(ErrorType.ProjectSmtpConfigInvalid.value, 'project_smtp_config_invalid')
self.assertEqual(ErrorType.GraphqlNoQuery.value, 'graphql_no_query')
self.assertEqual(ErrorType.GraphqlTooManyQueries.value, 'graphql_too_many_queries')
self.assertEqual(ErrorType.GeneralAccessForbidden.value, 'general_access_forbidden')
self.assertEqual(ErrorType.GeneralUnauthorizedScope.value, 'general_unauthorized_scope')
self.assertEqual(ErrorType.UserJwtInvalid.value, 'user_jwt_invalid')
self.assertEqual(ErrorType.UserBlocked.value, 'user_blocked')
self.assertEqual(ErrorType.UserInvalidToken.value, 'user_invalid_token')
self.assertEqual(ErrorType.UserEmailNotWhitelisted.value, 'user_email_not_whitelisted')
self.assertEqual(ErrorType.UserInvalidCode.value, 'user_invalid_code')
self.assertEqual(ErrorType.UserIpNotWhitelisted.value, 'user_ip_not_whitelisted')
self.assertEqual(ErrorType.UserInvalidCredentials.value, 'user_invalid_credentials')
self.assertEqual(ErrorType.UserAnonymousConsoleProhibited.value, 'user_anonymous_console_prohibited')
self.assertEqual(ErrorType.UserSessionAlreadyExists.value, 'user_session_already_exists')
self.assertEqual(ErrorType.UserUnauthorized.value, 'user_unauthorized')
self.assertEqual(ErrorType.UserOauth2Unauthorized.value, 'user_oauth2_unauthorized')
self.assertEqual(ErrorType.TeamInvalidSecret.value, 'team_invalid_secret')
self.assertEqual(ErrorType.TeamInviteMismatch.value, 'team_invite_mismatch')
self.assertEqual(ErrorType.ProjectKeyExpired.value, 'project_key_expired')
self.assertEqual(ErrorType.RuleVerificationFailed.value, 'rule_verification_failed')
self.assertEqual(ErrorType.ProjectTemplateDefaultDeletion.value, 'project_template_default_deletion')
self.assertEqual(ErrorType.GeneralUnknownOrigin.value, 'general_unknown_origin')
self.assertEqual(ErrorType.StorageInvalidFile.value, 'storage_invalid_file')
self.assertEqual(ErrorType.DocumentDeleteRestricted.value, 'document_delete_restricted')
self.assertEqual(ErrorType.GeneralRouteNotFound.value, 'general_route_not_found')
self.assertEqual(ErrorType.UserNotFound.value, 'user_not_found')
self.assertEqual(ErrorType.UserSessionNotFound.value, 'user_session_not_found')
self.assertEqual(ErrorType.UserIdentityNotFound.value, 'user_identity_not_found')
self.assertEqual(ErrorType.TeamNotFound.value, 'team_not_found')
self.assertEqual(ErrorType.TeamInviteNotFound.value, 'team_invite_not_found')
self.assertEqual(ErrorType.TeamMembershipMismatch.value, 'team_membership_mismatch')
self.assertEqual(ErrorType.MembershipNotFound.value, 'membership_not_found')
self.assertEqual(ErrorType.AvatarSetNotFound.value, 'avatar_set_not_found')
self.assertEqual(ErrorType.AvatarNotFound.value, 'avatar_not_found')
self.assertEqual(ErrorType.AvatarImageNotFound.value, 'avatar_image_not_found')
self.assertEqual(ErrorType.AvatarRemoteUrlFailed.value, 'avatar_remote_url_failed')
self.assertEqual(ErrorType.AvatarIconNotFound.value, 'avatar_icon_not_found')
self.assertEqual(ErrorType.StorageFileNotFound.value, 'storage_file_not_found')
self.assertEqual(ErrorType.StorageBucketNotFound.value, 'storage_bucket_not_found')
self.assertEqual(ErrorType.InstallationNotFound.value, 'installation_not_found')
self.assertEqual(ErrorType.ProviderRepositoryNotFound.value, 'provider_repository_not_found')
self.assertEqual(ErrorType.RepositoryNotFound.value, 'repository_not_found')
self.assertEqual(ErrorType.FunctionNotFound.value, 'function_not_found')
self.assertEqual(ErrorType.FunctionRuntimeUnsupported.value, 'function_runtime_unsupported')
self.assertEqual(ErrorType.BuildNotFound.value, 'build_not_found')
self.assertEqual(ErrorType.DeploymentNotFound.value, 'deployment_not_found')
self.assertEqual(ErrorType.ExecutionNotFound.value, 'execution_not_found')
self.assertEqual(ErrorType.DatabaseNotFound.value, 'database_not_found')
self.assertEqual(ErrorType.CollectionNotFound.value, 'collection_not_found')
self.assertEqual(ErrorType.DocumentNotFound.value, 'document_not_found')
self.assertEqual(ErrorType.AttributeNotFound.value, 'attribute_not_found')
self.assertEqual(ErrorType.IndexNotFound.value, 'index_not_found')
self.assertEqual(ErrorType.ProjectNotFound.value, 'project_not_found')
self.assertEqual(ErrorType.RouterHostNotFound.value, 'router_host_not_found')
self.assertEqual(ErrorType.RuleResourceNotFound.value, 'rule_resource_not_found')
self.assertEqual(ErrorType.RuleNotFound.value, 'rule_not_found')
self.assertEqual(ErrorType.WebhookNotFound.value, 'webhook_not_found')
self.assertEqual(ErrorType.KeyNotFound.value, 'key_not_found')
self.assertEqual(ErrorType.PlatformNotFound.value, 'platform_not_found')
self.assertEqual(ErrorType.VariableNotFound.value, 'variable_not_found')
self.assertEqual(ErrorType.MigrationNotFound.value, 'migration_not_found')
self.assertEqual(ErrorType.GeneralNotImplemented.value, 'general_not_implemented')
self.assertEqual(ErrorType.UserAlreadyExists.value, 'user_already_exists')
self.assertEqual(ErrorType.UserEmailAlreadyExists.value, 'user_email_already_exists')
self.assertEqual(ErrorType.UserPhoneAlreadyExists.value, 'user_phone_already_exists')
self.assertEqual(ErrorType.TeamInviteAlreadyExists.value, 'team_invite_already_exists')
self.assertEqual(ErrorType.TeamAlreadyExists.value, 'team_already_exists')
self.assertEqual(ErrorType.MembershipAlreadyConfirmed.value, 'membership_already_confirmed')
self.assertEqual(ErrorType.StorageFileAlreadyExists.value, 'storage_file_already_exists')
self.assertEqual(ErrorType.StorageBucketAlreadyExists.value, 'storage_bucket_already_exists')
self.assertEqual(ErrorType.ProviderContributionConflict.value, 'provider_contribution_conflict')
self.assertEqual(ErrorType.DatabaseAlreadyExists.value, 'database_already_exists')
self.assertEqual(ErrorType.CollectionAlreadyExists.value, 'collection_already_exists')
self.assertEqual(ErrorType.DocumentAlreadyExists.value, 'document_already_exists')
self.assertEqual(ErrorType.DocumentUpdateConflict.value, 'document_update_conflict')
self.assertEqual(ErrorType.AttributeAlreadyExists.value, 'attribute_already_exists')
self.assertEqual(ErrorType.IndexAlreadyExists.value, 'index_already_exists')
self.assertEqual(ErrorType.ProjectAlreadyExists.value, 'project_already_exists')
self.assertEqual(ErrorType.RuleAlreadyExists.value, 'rule_already_exists')
self.assertEqual(ErrorType.VariableAlreadyExists.value, 'variable_already_exists')
self.assertEqual(ErrorType.MigrationAlreadyExists.value, 'migration_already_exists')
self.assertEqual(ErrorType.MigrationInProgress.value, 'migration_in_progress')
self.assertEqual(ErrorType.UserPasswordResetRequired.value, 'user_password_reset_required')
self.assertEqual(ErrorType.ProjectProviderDisabled.value, 'project_provider_disabled')
self.assertEqual(ErrorType.StorageInvalidRange.value, 'storage_invalid_range')
self.assertEqual(ErrorType.UserOAuth2ProviderError.value, 'user_oauth2_provider_error')
self.assertEqual(ErrorType.GeneralRateLimitExceeded.value, 'general_rate_limit_exceeded')
self.assertEqual(ErrorType.GeneralUnknown.value, 'general_unknown')
self.assertEqual(ErrorType.GeneralServerError.value, 'general_server_error')
self.assertEqual(ErrorType.GeneralProtocolUnsupported.value, 'general_protocol_unsupported')
self.assertEqual(ErrorType.GeneralCodesDisabled.value, 'general_codes_disabled')
self.assertEqual(ErrorType.RouterDomainNotConfigured.value, 'router_domain_not_configured')
self.assertEqual(ErrorType.GeneralUsageDisabled.value, 'general_usage_disabled')
self.assertEqual(ErrorType.UserCountExceeded.value, 'user_count_exceeded')
self.assertEqual(ErrorType.UserAuthMethodUnsupported.value, 'user_auth_method_unsupported')
self.assertEqual(ErrorType.ProjectProviderUnsupported.value, 'project_provider_unsupported')
self.assertEqual(ErrorType.GeneralServiceDisabled.value, 'general_service_disabled')
self.assertEqual(ErrorType.GeneralSMTPDisabled.value, 'general_smtp_disabled')
self.assertEqual(ErrorType.GeneralPhoneDisabled.value, 'general_phone_disabled')

0 comments on commit 061fea8

Please sign in to comment.