From c734bbd95d19bc1fa2b0dba690278e29b85ab319 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 9 Apr 2020 12:51:58 -0700 Subject: [PATCH] python: Modernize legacy Python 2 syntax with pyupgrade. Generated by `pyupgrade --py3-plus --keep-percent-format` on all our Python code except `zthumbor` and `zulip-ec2-configure-interfaces`, followed by manual indentation fixes. Signed-off-by: Anders Kaseorg --- analytics/migrations/0001_initial.py | 11 +- .../migrations/0002_remove_huddlecount.py | 3 +- analytics/migrations/0003_fillstate.py | 1 - analytics/migrations/0004_add_subgroup.py | 1 - analytics/migrations/0005_alter_field_size.py | 1 - ...0006_add_subgroup_to_unique_constraints.py | 9 +- analytics/migrations/0007_remove_interval.py | 9 +- .../migrations/0008_add_count_indexes.py | 7 +- .../0009_remove_messages_to_stream_stat.py | 1 - .../0010_clear_messages_sent_values.py | 1 - .../migrations/0011_clear_analytics_tables.py | 1 - analytics/migrations/0012_add_on_delete.py | 2 - analytics/migrations/0013_remove_anomaly.py | 2 - .../0014_remove_fillstate_last_modified.py | 2 - .../migrations/0015_clear_duplicate_counts.py | 1 - analytics/views.py | 2 +- confirmation/__init__.py | 2 - confirmation/migrations/0001_initial.py | 1 - .../migrations/0002_realmcreationkey.py | 1 - .../0003_emailchangeconfirmation.py | 1 - .../0004_remove_confirmationmanager.py | 1 - .../migrations/0005_confirmation_realm.py | 2 - ...06_realmcreationkey_presume_email_valid.py | 2 - confirmation/models.py | 2 - confirmation/settings.py | 2 - corporate/migrations/0001_initial.py | 2 - .../0002_customer_default_discount.py | 2 - corporate/migrations/0003_customerplan.py | 2 - corporate/migrations/0004_licenseledger.py | 2 - .../migrations/0005_customerplan_invoicing.py | 2 - .../0006_nullable_stripe_customer_id.py | 2 - .../0007_remove_deprecated_fields.py | 2 - .../0008_nullable_next_invoice_date.py | 2 - corporate/tests/test_stripe.py | 12 +- docs/conf.py | 1 - manage.py | 1 - pgroonga/migrations/0001_enable.py | 1 - .../migrations/0002_html_escape_subject.py | 1 - pgroonga/migrations/0003_v2_api_upgrade.py | 1 - .../zulip_app_frontend/check_cron_file | 2 +- .../check_send_receive_time | 2 +- .../check_postgres_backup | 4 +- .../check_personal_zephyr_mirrors | 2 +- .../zulip_zephyr_mirror/check_zephyr_mirror | 2 +- scripts/lib/clean_emoji_cache.py | 2 +- scripts/lib/clean_node_cache.py | 2 +- scripts/lib/clean_venv_cache.py | 2 +- scripts/lib/node_cache.py | 2 +- scripts/lib/setup_venv.py | 4 +- scripts/lib/upgrade-zulip-stage-2 | 2 +- scripts/lib/zulip_tools.py | 6 +- scripts/purge-old-deployments | 4 +- .../documentation_crawler/settings.py | 2 - tools/droplets/create.py | 46 ++-- tools/fetch-contributor-data | 4 +- tools/get-handlebar-vars | 2 +- tools/i18n/tagmessages | 2 - tools/lib/gitlint-rules.py | 2 +- tools/lib/graph.py | 4 +- tools/lib/html_branches.py | 2 +- tools/lib/html_grep.py | 4 +- tools/lib/pretty_print.py | 2 +- tools/lib/provision_inner.py | 4 +- tools/lib/template_parser.py | 2 +- tools/lib/test_script.py | 2 +- tools/lint | 2 - tools/linter_lib/custom_check.py | 167 ++++++------ tools/linter_lib/pep8.py | 3 - tools/linter_lib/pyflakes.py | 3 - tools/pretty-print-html | 2 +- tools/stop-run-dev | 2 +- tools/test-backend | 4 +- tools/test-js-with-node | 4 +- tools/update-zuliprc-api-field | 4 +- tools/zulip-export/zulip-export | 1 - zerver/data_import/gitter.py | 2 +- zerver/data_import/hipchat.py | 4 +- zerver/data_import/mattermost.py | 2 +- zerver/data_import/slack.py | 11 +- zerver/forms.py | 14 +- zerver/lib/actions.py | 16 +- zerver/lib/alert_words.py | 6 +- zerver/lib/bugdown/__init__.py | 14 +- .../bugdown/api_arguments_table_generator.py | 4 +- zerver/lib/bugdown/api_code_examples.py | 2 +- zerver/lib/bugdown/include.py | 3 +- zerver/lib/bugdown/nested_code_blocks.py | 2 +- zerver/lib/bugdown/tabbed_sections.py | 2 +- zerver/lib/bugdown/testing_mocks.py | 2 - zerver/lib/bulk_create.py | 2 +- zerver/lib/cache.py | 14 +- zerver/lib/display_recipient.py | 4 +- zerver/lib/email_notifications.py | 10 +- zerver/lib/emoji.py | 4 +- zerver/lib/export.py | 28 +- zerver/lib/generate_test_data.py | 4 +- zerver/lib/i18n.py | 5 +- zerver/lib/management.py | 2 +- zerver/lib/message.py | 4 +- zerver/lib/narrow.py | 2 +- zerver/lib/parallel.py | 2 +- zerver/lib/push_notifications.py | 4 +- zerver/lib/statistics.py | 2 - zerver/lib/streams.py | 4 +- zerver/lib/subdomains.py | 2 - zerver/lib/test_classes.py | 4 +- zerver/lib/test_fixtures.py | 3 +- zerver/lib/test_helpers.py | 2 +- zerver/lib/test_runner.py | 3 +- zerver/lib/thumbnail.py | 1 - zerver/lib/upload.py | 8 +- zerver/lib/user_groups.py | 2 - zerver/lib/utils.py | 4 +- zerver/lib/validator.py | 4 +- zerver/logging_handlers.py | 2 +- .../commands/add_users_to_streams.py | 2 +- .../management/commands/archive_messages.py | 2 - .../commands/bulk_change_user_name.py | 2 +- zerver/management/commands/compilemessages.py | 4 +- .../commands/create_default_stream_groups.py | 2 +- zerver/management/commands/create_user.py | 2 +- .../commands/generate_multiuse_invite_link.py | 2 +- .../commands/get_migration_status.py | 1 - zerver/management/commands/makemessages.py | 8 +- zerver/management/commands/merge_streams.py | 2 +- .../management/commands/send_custom_email.py | 4 +- .../commands/sync_ldap_user_data.py | 2 +- zerver/middleware.py | 12 +- zerver/migrations/0001_initial.py | 19 +- zerver/migrations/0029_realm_subdomain.py | 1 - zerver/migrations/0030_realm_org_type.py | 1 - .../0031_remove_system_avatar_source.py | 1 - .../0032_verify_all_medium_avatar_images.py | 1 - .../0033_migrate_domain_to_realmalias.py | 1 - ...rofile_enable_online_push_notifications.py | 1 - ...035_realm_message_retention_period_days.py | 1 - .../0036_rename_subdomain_to_string_id.py | 1 - .../0037_disallow_null_string_id.py | 1 - ...0038_realm_change_to_community_defaults.py | 1 - .../0039_realmalias_drop_uniqueness.py | 1 - .../0040_realm_authentication_methods.py | 1 - ...041_create_attachments_for_old_messages.py | 1 - .../0042_attachment_file_name_length.py | 1 - .../0043_realm_filter_validators.py | 1 - zerver/migrations/0044_reaction.py | 3 +- .../0045_realm_waiting_period_threshold.py | 1 - zerver/migrations/0046_realmemoji_author.py | 1 - .../0047_realm_add_emoji_by_admins_only.py | 1 - .../0048_enter_sends_default_to_false.py | 1 - ...ile_pm_content_in_desktop_notifications.py | 1 - .../0050_userprofile_avatar_version.py | 1 - .../0051_realmalias_add_allow_subdomains.py | 3 +- ...0052_auto_fix_realmalias_realm_nullable.py | 1 - zerver/migrations/0053_emailchangestatus.py | 1 - zerver/migrations/0054_realm_icon.py | 1 - zerver/migrations/0055_attachment_size.py | 1 - .../0056_userprofile_emoji_alt_code.py | 1 - zerver/migrations/0057_realmauditlog.py | 1 - .../0058_realm_email_changes_disabled.py | 1 - zerver/migrations/0059_userprofile_quota.py | 1 - .../0060_move_avatars_to_be_uid_based.py | 1 - .../migrations/0061_userprofile_timezone.py | 1 - zerver/migrations/0062_default_timezone.py | 1 - zerver/migrations/0063_realm_description.py | 1 - .../0064_sync_uploads_filesize_with_db.py | 1 - .../0065_realm_inline_image_preview.py | 1 - .../0066_realm_inline_url_embed_preview.py | 1 - zerver/migrations/0067_archived_models.py | 3 +- zerver/migrations/0068_remove_realm_domain.py | 1 - .../0069_realmauditlog_extra_data.py | 1 - zerver/migrations/0070_userhotspot.py | 3 +- .../0071_rename_realmalias_to_realmdomain.py | 1 - ...0072_realmauditlog_add_index_event_time.py | 1 - .../migrations/0073_custom_profile_fields.py | 5 +- .../0074_fix_duplicate_attachments.py | 1 - .../0075_attachment_path_id_unique.py | 1 - .../migrations/0076_userprofile_emojiset.py | 1 - ...0077_add_file_name_field_to_realm_emoji.py | 5 +- zerver/migrations/0078_service.py | 1 - .../0079_remove_old_scheduled_jobs.py | 1 - .../0080_realm_description_length.py | 1 - .../migrations/0081_make_emoji_lowercase.py | 1 - .../0082_index_starred_user_messages.py | 1 - .../0083_index_mentioned_user_messages.py | 1 - .../migrations/0084_realmemoji_deactivated.py | 1 - .../0085_fix_bots_with_none_bot_type.py | 1 - .../0086_realm_alter_default_org_type.py | 1 - .../0087_remove_old_scheduled_jobs.py | 1 - .../0088_remove_referral_and_invites.py | 1 - zerver/migrations/0089_auto_20170710_1353.py | 1 - .../0090_userprofile_high_contrast_mode.py | 1 - .../0091_realm_allow_edit_history.py | 1 - .../migrations/0092_create_scheduledemail.py | 1 - .../0093_subscription_event_log_backfill.py | 1 - .../0094_realm_filter_url_validator.py | 1 - .../0095_index_unread_user_messages.py | 1 - .../migrations/0096_add_password_required.py | 1 - .../migrations/0097_reactions_emoji_code.py | 1 - ...0098_index_has_alert_word_user_messages.py | 1 - ..._index_wildcard_mentioned_user_messages.py | 1 - .../0100_usermessage_remove_is_me_message.py | 1 - zerver/migrations/0101_muted_topic.py | 3 +- zerver/migrations/0102_convert_muted_topic.py | 1 - .../0103_remove_userprofile_muted_topics.py | 1 - zerver/migrations/0104_fix_unreads.py | 1 - ...rofile_enable_stream_push_notifications.py | 1 - .../0106_subscription_push_notifications.py | 1 - zerver/migrations/0107_multiuseinvite.py | 1 - .../migrations/0108_fix_default_string_id.py | 1 - .../0109_mark_tutorial_status_finished.py | 1 - .../0110_stream_is_in_zephyr_realm.py | 1 - zerver/migrations/0111_botuserstatedata.py | 4 +- zerver/migrations/0112_index_muted_topics.py | 1 - .../migrations/0113_default_stream_group.py | 4 +- ...14_preregistrationuser_invited_as_admin.py | 2 - zerver/migrations/0115_user_groups.py | 6 +- .../0116_realm_allow_message_deleting.py | 2 - .../migrations/0117_add_desc_to_user_group.py | 2 - .../0118_defaultstreamgroup_description.py | 2 - .../migrations/0119_userprofile_night_mode.py | 2 - zerver/migrations/0120_botuserconfigdata.py | 4 +- .../0121_realm_signup_notifications_stream.py | 2 - ..._rename_botuserstatedata_botstoragedata.py | 2 - ...serprofile_make_realm_email_pair_unique.py | 4 +- .../0124_stream_enable_notifications.py | 2 - zerver/migrations/0125_realm_max_invites.py | 2 - .../0126_prereg_remove_users_without_realm.py | 2 - ..._disallow_chars_in_stream_and_user_name.py | 1 - .../migrations/0128_scheduledemail_realm.py | 2 - ...9_remove_userprofile_autoscroll_forever.py | 2 - ...realm_create_generic_bot_by_admins_only.py | 2 - .../0132_realm_message_visibility_limit.py | 2 - ..._rename_botuserconfigdata_botconfigdata.py | 2 - zerver/migrations/0134_scheduledmessage.py | 2 - .../0135_scheduledmessage_delivery_type.py | 2 - .../0136_remove_userprofile_quota.py | 2 - .../migrations/0137_realm_upload_quota_gb.py | 2 - ...userprofile_realm_name_in_notifications.py | 2 - ...ll_last_message_id_in_subscription_logs.py | 3 - .../0140_realm_send_welcome_emails.py | 2 - ...ange_usergroup_description_to_textfield.py | 2 - .../0142_userprofile_translate_emoticons.py | 2 - .../0143_realm_bot_creation_policy.py | 2 - ...realm_create_generic_bot_by_admins_only.py | 2 - .../0145_reactions_realm_emoji_name_to_id.py | 1 - ..._message_content_in_email_notifications.py | 2 - ...alm_disallow_disposable_email_addresses.py | 2 - .../0148_max_invites_forget_default.py | 2 - ...0149_realm_emoji_drop_unique_constraint.py | 3 +- ...150_realm_allow_community_topic_editing.py | 2 - .../0151_last_reminder_default_none.py | 2 - ...152_realm_default_twenty_four_hour_time.py | 2 - .../0153_remove_int_float_custom_fields.py | 2 - .../migrations/0154_fix_invalid_bot_owner.py | 2 - .../0155_change_default_realm_description.py | 2 - .../0156_add_hint_to_profile_field.py | 2 - .../migrations/0157_userprofile_is_guest.py | 2 - .../0158_realm_video_chat_provider.py | 2 - .../0159_realm_google_hangouts_domain.py | 2 - zerver/migrations/0160_add_choice_field.py | 2 - ...lm_message_content_delete_limit_seconds.py | 2 - ..._change_default_community_topic_editing.py | 2 - ...erprofile_default_desktop_notifications.py | 2 - ...64_stream_history_public_to_subscribers.py | 2 - .../0165_add_date_to_profile_field.py | 2 - .../0166_add_url_to_profile_field.py | 2 - .../0167_custom_profile_fields_sort_order.py | 2 - .../migrations/0168_stream_is_web_public.py | 2 - .../0169_stream_is_announcement_only.py | 2 - zerver/migrations/0170_submessage.py | 2 - .../migrations/0171_userprofile_dense_mode.py | 2 - ...2_add_user_type_of_custom_profile_field.py | 2 - .../0173_support_seat_based_plans.py | 2 - .../0174_userprofile_delivery_email.py | 2 - ...change_realm_audit_log_event_type_tense.py | 3 - .../0176_remove_subscription_notifications.py | 2 - ...r_message_add_and_index_is_private_flag.py | 2 - ..._rename_to_emails_restricted_to_domains.py | 2 - .../0179_rename_to_digest_emails_enabled.py | 2 - ...age_add_active_mobile_push_notification.py | 2 - .../0181_userprofile_change_emojiset.py | 1 - .../0182_set_initial_value_is_private_flag.py | 1 - ...183_change_custom_field_name_max_length.py | 2 - .../0184_rename_custom_field_types.py | 2 - zerver/migrations/0185_realm_plan_type.py | 2 - ...0186_userprofile_starred_message_counts.py | 2 - .../0187_userprofile_is_billing_admin.py | 2 - .../0188_userprofile_enable_login_emails.py | 2 - .../0189_userprofile_add_some_emojisets.py | 2 - .../0190_cleanup_pushdevicetoken.py | 4 +- zerver/migrations/0191_realm_seat_limit.py | 2 - ..._customprofilefieldvalue_rendered_value.py | 2 - .../0193_realm_email_address_visibility.py | 2 - .../0194_userprofile_notification_sound.py | 2 - .../0195_realm_first_visible_message_id.py | 2 - .../migrations/0196_add_realm_logo_fields.py | 2 - .../0197_azure_active_directory_auth.py | 2 - .../0198_preregistrationuser_invited_as.py | 2 - zerver/migrations/0199_userstatus.py | 2 - ...ve_preregistrationuser_invited_as_admin.py | 2 - zerver/migrations/0201_zoom_video_chat.py | 2 - .../migrations/0202_add_user_status_info.py | 2 - ..._content_allowed_in_email_notifications.py | 2 - .../0204_remove_realm_billing_fields.py | 2 - ...e_realmauditlog_requires_billing_update.py | 2 - .../0206_stream_rendered_description.py | 3 - .../0207_multiuseinvite_invited_as.py | 2 - .../0208_add_realm_night_logo_fields.py | 2 - .../0209_stream_first_message_id.py | 2 - .../0209_user_profile_no_empty_password.py | 2 - .../0210_stream_first_message_id.py | 2 - ...0211_add_users_field_to_scheduled_email.py | 2 - .../0212_make_stream_email_token_unique.py | 2 - .../migrations/0213_realm_digest_weekday.py | 2 - .../0214_realm_invite_to_stream_policy.py | 2 - .../0215_realm_avatar_changes_disabled.py | 2 - .../0216_add_create_stream_policy.py | 2 - .../0217_migrate_create_stream_policy.py | 2 - ...218_remove_create_stream_by_admins_only.py | 2 - ...gle_realm_digest_emails_enabled_default.py | 2 - ...0220_subscription_notification_settings.py | 2 - ...bscription_notifications_data_migration.py | 2 - .../0222_userprofile_fluid_layout_width.py | 2 - zerver/migrations/0223_rename_to_is_muted.py | 2 - ...4_alter_field_realm_video_chat_provider.py | 8 +- .../0225_archived_reaction_model.py | 4 +- .../0226_archived_submessage_model.py | 2 - ...27_inline_url_embed_preview_default_off.py | 2 - ...228_userprofile_demote_inactive_streams.py | 2 - .../0229_stream_message_retention_days.py | 2 - ..._to_enable_stream_audible_notifications.py | 2 - .../0231_add_archive_transaction_model.py | 2 - ..._archive_transaction_field_not_nullable.py | 3 - .../0233_userprofile_avatar_hash.py | 2 - ...d_external_account_custom_profile_field.py | 2 - ..._userprofile_desktop_icon_count_display.py | 2 - ...36_remove_illegal_characters_email_full.py | 2 - ...237_rename_zulip_realm_to_zulipinternal.py | 1 - .../migrations/0238_usermessage_bigint_id.py | 2 - .../0239_usermessage_copy_id_to_bigint_id.py | 2 - ...0_usermessage_migrate_bigint_id_into_id.py | 2 - ...sermessage_bigint_id_migration_finalize.py | 2 - .../migrations/0242_fix_bot_email_property.py | 2 - .../0243_message_add_date_sent_column.py | 2 - ...0244_message_copy_pub_date_to_date_sent.py | 3 - .../0245_message_date_sent_finalize_part1.py | 2 - .../0246_message_date_sent_finalize_part2.py | 2 - .../0247_realmauditlog_event_type_to_int.py | 2 - .../migrations/0248_userprofile_role_start.py | 2 - .../0249_userprofile_role_finish.py | 2 - zerver/migrations/0250_saml_auth.py | 2 - .../0251_prereg_user_add_full_name.py | 2 - .../0252_realm_user_group_edit_policy.py | 2 - ...53_userprofile_wildcard_mentions_notify.py | 2 - zerver/migrations/0254_merge_0209_0253.py | 2 - ...userprofile_stream_add_recipient_column.py | 2 - ...file_stream_set_recipient_column_values.py | 1 - .../migrations/0257_fix_has_link_attribute.py | 2 - ...nable_online_push_notifications_default.py | 2 - .../0259_missedmessageemailaddress.py | 2 - ...ssed_message_addresses_from_redis_to_db.py | 1 - .../0261_realm_private_message_policy.py | 2 - .../migrations/0262_mutedtopic_date_muted.py | 2 - .../0263_stream_stream_post_policy.py | 2 - .../0264_migrate_is_announcement_only.py | 2 - ...0265_remove_stream_is_announcement_only.py | 2 - zerver/migrations/0266_userpresence_realm.py | 2 - .../0267_backfill_userpresence_realm_id.py | 1 - ..._add_userpresence_realm_timestamp_index.py | 4 +- zerver/migrations/0269_gitlab_auth.py | 2 - ...0271_huddle_set_recipient_column_values.py | 1 - zerver/models.py | 78 +++--- zerver/openapi/test_curl_examples.py | 2 +- zerver/tests/test_alert_words.py | 4 +- zerver/tests/test_archive.py | 1 - zerver/tests/test_attachments.py | 2 - zerver/tests/test_audit_log.py | 2 +- zerver/tests/test_auth_backends.py | 11 +- zerver/tests/test_bots.py | 22 +- zerver/tests/test_bugdown.py | 93 ++++--- zerver/tests/test_camo.py | 1 - zerver/tests/test_custom_profile_data.py | 48 ++-- zerver/tests/test_decorators.py | 11 +- zerver/tests/test_digest.py | 2 - zerver/tests/test_docs.py | 6 +- zerver/tests/test_email_change.py | 2 - zerver/tests/test_email_mirror.py | 2 - zerver/tests/test_embedded_bot_system.py | 2 - zerver/tests/test_events.py | 41 ++- zerver/tests/test_external.py | 1 - zerver/tests/test_gitter_importer.py | 5 +- zerver/tests/test_hotspots.py | 2 - zerver/tests/test_i18n.py | 28 +- zerver/tests/test_import_export.py | 26 +- zerver/tests/test_integrations_dev_panel.py | 6 +- zerver/tests/test_link_embed.py | 20 +- zerver/tests/test_logging_handlers.py | 2 - zerver/tests/test_management_commands.py | 4 +- zerver/tests/test_mattermost_importer.py | 36 +-- .../tests/test_message_edit_notifications.py | 2 - zerver/tests/test_messages.py | 33 ++- zerver/tests/test_muting.py | 6 +- zerver/tests/test_narrow.py | 87 +++---- zerver/tests/test_onboarding.py | 2 - zerver/tests/test_openapi.py | 12 +- .../tests/test_outgoing_webhook_interfaces.py | 27 +- zerver/tests/test_outgoing_webhook_system.py | 2 - zerver/tests/test_presence.py | 2 - zerver/tests/test_push_notifications.py | 42 +-- zerver/tests/test_queue_worker.py | 10 +- zerver/tests/test_reactions.py | 10 +- zerver/tests/test_realm.py | 30 +-- zerver/tests/test_realm_domains.py | 2 - zerver/tests/test_realm_emoji.py | 2 - zerver/tests/test_realm_filters.py | 6 +- zerver/tests/test_redis_utils.py | 2 - zerver/tests/test_report.py | 4 +- zerver/tests/test_retention.py | 1 - zerver/tests/test_service_bot_system.py | 8 +- zerver/tests/test_signup.py | 11 +- zerver/tests/test_slack_importer.py | 3 +- zerver/tests/test_slack_message_conversion.py | 5 +- zerver/tests/test_soft_deactivation.py | 2 - zerver/tests/test_subs.py | 64 +++-- zerver/tests/test_templates.py | 2 - zerver/tests/test_thumbnail.py | 1 - zerver/tests/test_tornado.py | 2 - zerver/tests/test_transfer.py | 4 +- zerver/tests/test_tutorial.py | 1 - zerver/tests/test_typing.py | 58 ++--- zerver/tests/test_unread.py | 2 - zerver/tests/test_upload.py | 39 ++- zerver/tests/test_urls.py | 2 - zerver/tests/test_user_groups.py | 5 +- zerver/tests/test_users.py | 6 +- zerver/tests/test_webhooks_common.py | 1 - zerver/tests/test_zcommand.py | 2 - zerver/tornado/autoreload.py | 1 - zerver/tornado/event_queue.py | 2 +- zerver/tornado/handlers.py | 2 +- zerver/views/development/integrations.py | 4 +- zerver/views/messages.py | 2 +- zerver/views/portico.py | 1 - zerver/views/realm.py | 2 +- zerver/views/registration.py | 1 - zerver/views/streams.py | 14 +- zerver/views/thumbnail.py | 1 - zerver/views/user_settings.py | 2 +- zerver/webhooks/airbrake/tests.py | 7 +- zerver/webhooks/alertmanager/tests.py | 1 - zerver/webhooks/ansibletower/tests.py | 1 - zerver/webhooks/appfollow/tests.py | 9 +- zerver/webhooks/appveyor/tests.py | 1 - zerver/webhooks/basecamp/tests.py | 63 +++-- zerver/webhooks/beanstalk/tests.py | 3 +- zerver/webhooks/beanstalk/view.py | 2 +- zerver/webhooks/beeminder/tests.py | 7 +- zerver/webhooks/beeminder/view.py | 2 +- zerver/webhooks/bitbucket/tests.py | 29 +-- zerver/webhooks/bitbucket/view.py | 4 +- zerver/webhooks/bitbucket2/tests.py | 111 ++++---- zerver/webhooks/bitbucket2/view.py | 2 +- zerver/webhooks/bitbucket3/tests.py | 1 - zerver/webhooks/buildbot/tests.py | 2 +- zerver/webhooks/circleci/tests.py | 19 +- zerver/webhooks/circleci/view.py | 8 +- zerver/webhooks/clubhouse/tests.py | 74 +++--- zerver/webhooks/codeship/tests.py | 13 +- zerver/webhooks/crashlytics/tests.py | 11 +- zerver/webhooks/delighted/tests.py | 1 - zerver/webhooks/deskdotcom/tests.py | 29 +-- zerver/webhooks/dialogflow/tests.py | 13 +- zerver/webhooks/dialogflow/view.py | 4 +- zerver/webhooks/dropbox/tests.py | 5 +- zerver/webhooks/errbit/tests.py | 7 +- zerver/webhooks/flock/tests.py | 43 ++-- zerver/webhooks/flock/view.py | 2 +- zerver/webhooks/freshdesk/tests.py | 13 +- zerver/webhooks/gci/tests.py | 41 ++- zerver/webhooks/gci/view.py | 8 +- zerver/webhooks/gitea/tests.py | 65 +++-- zerver/webhooks/gitea/view.py | 1 - zerver/webhooks/github/tests.py | 168 ++++++------ zerver/webhooks/github/view.py | 40 +-- zerver/webhooks/gitlab/tests.py | 239 +++++++++--------- zerver/webhooks/gitlab/view.py | 34 +-- zerver/webhooks/gocd/tests.py | 21 +- zerver/webhooks/gocd/view.py | 10 +- zerver/webhooks/gogs/tests.py | 93 ++++--- zerver/webhooks/gogs/view.py | 1 - zerver/webhooks/gosquared/tests.py | 3 +- zerver/webhooks/greenhouse/tests.py | 1 - zerver/webhooks/groove/tests.py | 15 +- zerver/webhooks/harbor/tests.py | 3 +- zerver/webhooks/harbor/view.py | 10 +- zerver/webhooks/hellosign/tests.py | 1 - zerver/webhooks/helloworld/tests.py | 15 +- zerver/webhooks/heroku/tests.py | 5 +- zerver/webhooks/ifttt/tests.py | 9 +- zerver/webhooks/insping/tests.py | 5 +- zerver/webhooks/jira/tests.py | 5 +- zerver/webhooks/jira/view.py | 30 +-- zerver/webhooks/librato/tests.py | 3 +- zerver/webhooks/librato/view.py | 16 +- zerver/webhooks/mention/tests.py | 3 +- zerver/webhooks/netlify/tests.py | 29 +-- zerver/webhooks/netlify/view.py | 2 +- zerver/webhooks/newrelic/tests.py | 3 +- zerver/webhooks/opbeat/tests.py | 3 +- zerver/webhooks/opsgenie/tests.py | 29 +-- zerver/webhooks/pagerduty/tests.py | 23 +- zerver/webhooks/pagerduty/view.py | 4 +- zerver/webhooks/papertrail/tests.py | 4 +- zerver/webhooks/pingdom/tests.py | 19 +- zerver/webhooks/pivotal/tests.py | 5 +- zerver/webhooks/raygun/tests.py | 15 +- zerver/webhooks/reviewboard/tests.py | 1 - zerver/webhooks/semaphore/tests.py | 19 +- zerver/webhooks/sentry/tests.py | 3 +- zerver/webhooks/slack/tests.py | 9 +- zerver/webhooks/slack/view.py | 2 +- zerver/webhooks/solano/tests.py | 11 +- zerver/webhooks/splunk/tests.py | 29 +-- zerver/webhooks/statuspage/tests.py | 11 +- zerver/webhooks/statuspage/view.py | 2 +- zerver/webhooks/stripe/tests.py | 63 +++-- zerver/webhooks/stripe/view.py | 2 +- zerver/webhooks/taiga/tests.py | 143 ++++++----- zerver/webhooks/taiga/view.py | 150 +++++------ zerver/webhooks/teamcity/tests.py | 19 +- zerver/webhooks/transifex/tests.py | 3 +- zerver/webhooks/travis/tests.py | 19 +- zerver/webhooks/travis/view.py | 6 +- zerver/webhooks/trello/tests.py | 99 ++++---- zerver/webhooks/trello/view/board_actions.py | 30 +-- zerver/webhooks/trello/view/card_actions.py | 102 ++++---- zerver/webhooks/updown/tests.py | 23 +- zerver/webhooks/wordpress/tests.py | 25 +- zerver/webhooks/yo/tests.py | 5 +- zerver/webhooks/zabbix/tests.py | 7 +- zerver/webhooks/zapier/tests.py | 13 +- zerver/webhooks/zendesk/tests.py | 3 +- .../commands/add_mock_conversation.py | 1 - .../management/commands/compare_messages.py | 2 +- zilencer/management/commands/populate_db.py | 4 +- zilencer/management/commands/sync_api_key.py | 2 +- zilencer/migrations/0001_initial.py | 1 - .../migrations/0002_remote_zulip_server.py | 1 - ...or_remotezulipserver_last_updated_field.py | 1 - .../0004_remove_deployment_model.py | 1 - ...05_remotepushdevicetoken_fix_uniqueness.py | 4 +- zilencer/migrations/0006_customer.py | 2 - .../0007_remotezulipserver_fix_uniqueness.py | 2 - .../migrations/0008_customer_billing_user.py | 2 - zilencer/migrations/0009_plan.py | 2 - zilencer/migrations/0010_billingprocessor.py | 2 - .../0011_customer_has_billing_relationship.py | 2 - zilencer/migrations/0012_coupon.py | 2 - .../0013_remove_customer_billing_user.py | 2 - .../0014_cleanup_pushdevicetoken.py | 4 +- zilencer/migrations/0015_delete_billing.py | 2 - zilencer/migrations/0016_remote_counts.py | 8 +- .../0017_installationcount_indexes.py | 6 +- .../migrations/0018_remoterealmauditlog.py | 2 - zproject/backends.py | 2 +- zproject/config.py | 2 +- zproject/email_backends.py | 2 +- 567 files changed, 1877 insertions(+), 2564 deletions(-) diff --git a/analytics/migrations/0001_initial.py b/analytics/migrations/0001_initial.py index 3d528988e0..f9ace30741 100644 --- a/analytics/migrations/0001_initial.py +++ b/analytics/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import django.db.models.deletion from django.conf import settings from django.db import migrations, models @@ -90,22 +89,22 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='usercount', - unique_together=set([('user', 'property', 'end_time', 'interval')]), + unique_together={('user', 'property', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='streamcount', - unique_together=set([('stream', 'property', 'end_time', 'interval')]), + unique_together={('stream', 'property', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='realmcount', - unique_together=set([('realm', 'property', 'end_time', 'interval')]), + unique_together={('realm', 'property', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='installationcount', - unique_together=set([('property', 'end_time', 'interval')]), + unique_together={('property', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='huddlecount', - unique_together=set([('huddle', 'property', 'end_time', 'interval')]), + unique_together={('huddle', 'property', 'end_time', 'interval')}, ), ] diff --git a/analytics/migrations/0002_remove_huddlecount.py b/analytics/migrations/0002_remove_huddlecount.py index 9bc8e28c27..ee46bd7869 100644 --- a/analytics/migrations/0002_remove_huddlecount.py +++ b/analytics/migrations/0002_remove_huddlecount.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations @@ -11,7 +10,7 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='huddlecount', - unique_together=set([]), + unique_together=set(), ), migrations.RemoveField( model_name='huddlecount', diff --git a/analytics/migrations/0003_fillstate.py b/analytics/migrations/0003_fillstate.py index da49772d6e..a89132aa40 100644 --- a/analytics/migrations/0003_fillstate.py +++ b/analytics/migrations/0003_fillstate.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/analytics/migrations/0004_add_subgroup.py b/analytics/migrations/0004_add_subgroup.py index e16e7733f0..4af323a22d 100644 --- a/analytics/migrations/0004_add_subgroup.py +++ b/analytics/migrations/0004_add_subgroup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/analytics/migrations/0005_alter_field_size.py b/analytics/migrations/0005_alter_field_size.py index eed94b35db..fbc103b1a0 100644 --- a/analytics/migrations/0005_alter_field_size.py +++ b/analytics/migrations/0005_alter_field_size.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/analytics/migrations/0006_add_subgroup_to_unique_constraints.py b/analytics/migrations/0006_add_subgroup_to_unique_constraints.py index aa2e105e5e..fa14250e91 100644 --- a/analytics/migrations/0006_add_subgroup_to_unique_constraints.py +++ b/analytics/migrations/0006_add_subgroup_to_unique_constraints.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations @@ -11,18 +10,18 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='installationcount', - unique_together=set([('property', 'subgroup', 'end_time', 'interval')]), + unique_together={('property', 'subgroup', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='realmcount', - unique_together=set([('realm', 'property', 'subgroup', 'end_time', 'interval')]), + unique_together={('realm', 'property', 'subgroup', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='streamcount', - unique_together=set([('stream', 'property', 'subgroup', 'end_time', 'interval')]), + unique_together={('stream', 'property', 'subgroup', 'end_time', 'interval')}, ), migrations.AlterUniqueTogether( name='usercount', - unique_together=set([('user', 'property', 'subgroup', 'end_time', 'interval')]), + unique_together={('user', 'property', 'subgroup', 'end_time', 'interval')}, ), ] diff --git a/analytics/migrations/0007_remove_interval.py b/analytics/migrations/0007_remove_interval.py index 9fceb71042..3d76d72c8a 100644 --- a/analytics/migrations/0007_remove_interval.py +++ b/analytics/migrations/0007_remove_interval.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2017-01-16 20:50 from django.db import migrations @@ -12,7 +11,7 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='installationcount', - unique_together=set([('property', 'subgroup', 'end_time')]), + unique_together={('property', 'subgroup', 'end_time')}, ), migrations.RemoveField( model_name='installationcount', @@ -20,7 +19,7 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='realmcount', - unique_together=set([('realm', 'property', 'subgroup', 'end_time')]), + unique_together={('realm', 'property', 'subgroup', 'end_time')}, ), migrations.RemoveField( model_name='realmcount', @@ -28,7 +27,7 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='streamcount', - unique_together=set([('stream', 'property', 'subgroup', 'end_time')]), + unique_together={('stream', 'property', 'subgroup', 'end_time')}, ), migrations.RemoveField( model_name='streamcount', @@ -36,7 +35,7 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='usercount', - unique_together=set([('user', 'property', 'subgroup', 'end_time')]), + unique_together={('user', 'property', 'subgroup', 'end_time')}, ), migrations.RemoveField( model_name='usercount', diff --git a/analytics/migrations/0008_add_count_indexes.py b/analytics/migrations/0008_add_count_indexes.py index 7d95671840..f84fbef79c 100644 --- a/analytics/migrations/0008_add_count_indexes.py +++ b/analytics/migrations/0008_add_count_indexes.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-01 22:28 from django.db import migrations @@ -13,14 +12,14 @@ class Migration(migrations.Migration): operations = [ migrations.AlterIndexTogether( name='realmcount', - index_together=set([('property', 'end_time')]), + index_together={('property', 'end_time')}, ), migrations.AlterIndexTogether( name='streamcount', - index_together=set([('property', 'realm', 'end_time')]), + index_together={('property', 'realm', 'end_time')}, ), migrations.AlterIndexTogether( name='usercount', - index_together=set([('property', 'realm', 'end_time')]), + index_together={('property', 'realm', 'end_time')}, ), ] diff --git a/analytics/migrations/0009_remove_messages_to_stream_stat.py b/analytics/migrations/0009_remove_messages_to_stream_stat.py index 67bb4ba7e2..98c032ce21 100644 --- a/analytics/migrations/0009_remove_messages_to_stream_stat.py +++ b/analytics/migrations/0009_remove_messages_to_stream_stat.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/analytics/migrations/0010_clear_messages_sent_values.py b/analytics/migrations/0010_clear_messages_sent_values.py index 7a3da15b26..340a639944 100644 --- a/analytics/migrations/0010_clear_messages_sent_values.py +++ b/analytics/migrations/0010_clear_messages_sent_values.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/analytics/migrations/0011_clear_analytics_tables.py b/analytics/migrations/0011_clear_analytics_tables.py index e493274802..fe4e2f0fd8 100644 --- a/analytics/migrations/0011_clear_analytics_tables.py +++ b/analytics/migrations/0011_clear_analytics_tables.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/analytics/migrations/0012_add_on_delete.py b/analytics/migrations/0012_add_on_delete.py index 32b7d61b1f..0d0a5c22b8 100644 --- a/analytics/migrations/0012_add_on_delete.py +++ b/analytics/migrations/0012_add_on_delete.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-29 08:14 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/analytics/migrations/0013_remove_anomaly.py b/analytics/migrations/0013_remove_anomaly.py index 1a30325f5d..5a5c53858c 100644 --- a/analytics/migrations/0013_remove_anomaly.py +++ b/analytics/migrations/0013_remove_anomaly.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-02 02:47 -from __future__ import unicode_literals from django.db import migrations diff --git a/analytics/migrations/0014_remove_fillstate_last_modified.py b/analytics/migrations/0014_remove_fillstate_last_modified.py index 81e293cc16..80bcdcdbc7 100644 --- a/analytics/migrations/0014_remove_fillstate_last_modified.py +++ b/analytics/migrations/0014_remove_fillstate_last_modified.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-27 04:32 -from __future__ import unicode_literals from django.db import migrations diff --git a/analytics/migrations/0015_clear_duplicate_counts.py b/analytics/migrations/0015_clear_duplicate_counts.py index 89454faaf3..2e78a1df35 100644 --- a/analytics/migrations/0015_clear_duplicate_counts.py +++ b/analytics/migrations/0015_clear_duplicate_counts.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/analytics/views.py b/analytics/views.py index 6ec7c30e46..2d00dcb13e 100644 --- a/analytics/views.py +++ b/analytics/views.py @@ -261,7 +261,7 @@ def get_chart_data(request: HttpRequest, user_profile: UserProfile, chart_name: "analytics cron job running?" % (realm.string_id, start, end)) raise JsonableError(_("No analytics data available. Please contact your server administrator.")) - assert len(set([stat.frequency for stat in stats])) == 1 + assert len({stat.frequency for stat in stats}) == 1 end_times = time_range(start, end, stats[0].frequency, min_length) data = {'end_times': end_times, 'frequency': stats[0].frequency} # type: Dict[str, Any] diff --git a/confirmation/__init__.py b/confirmation/__init__.py index ed0db53caa..48db8f7076 100644 --- a/confirmation/__init__.py +++ b/confirmation/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # Copyright: (c) 2008, Jarek Zgoda # Permission is hereby granted, free of charge, to any person obtaining a diff --git a/confirmation/migrations/0001_initial.py b/confirmation/migrations/0001_initial.py index ca6d1951b4..af6fed33e7 100644 --- a/confirmation/migrations/0001_initial.py +++ b/confirmation/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import models, migrations import django.db.models.deletion diff --git a/confirmation/migrations/0002_realmcreationkey.py b/confirmation/migrations/0002_realmcreationkey.py index 75d3b9d244..2053e28340 100644 --- a/confirmation/migrations/0002_realmcreationkey.py +++ b/confirmation/migrations/0002_realmcreationkey.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import models, migrations import django.utils.timezone diff --git a/confirmation/migrations/0003_emailchangeconfirmation.py b/confirmation/migrations/0003_emailchangeconfirmation.py index c64b3d6f67..cc04f0de83 100644 --- a/confirmation/migrations/0003_emailchangeconfirmation.py +++ b/confirmation/migrations/0003_emailchangeconfirmation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2017-01-17 09:16 from django.db import migrations diff --git a/confirmation/migrations/0004_remove_confirmationmanager.py b/confirmation/migrations/0004_remove_confirmationmanager.py index 06469ff52b..d53ff6edd8 100644 --- a/confirmation/migrations/0004_remove_confirmationmanager.py +++ b/confirmation/migrations/0004_remove_confirmationmanager.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-08 04:23 from django.db import migrations, models diff --git a/confirmation/migrations/0005_confirmation_realm.py b/confirmation/migrations/0005_confirmation_realm.py index 2e43a0de25..2dc1088e9d 100644 --- a/confirmation/migrations/0005_confirmation_realm.py +++ b/confirmation/migrations/0005_confirmation_realm.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-30 00:13 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/confirmation/migrations/0006_realmcreationkey_presume_email_valid.py b/confirmation/migrations/0006_realmcreationkey_presume_email_valid.py index 0205f2d37a..899581f715 100644 --- a/confirmation/migrations/0006_realmcreationkey_presume_email_valid.py +++ b/confirmation/migrations/0006_realmcreationkey_presume_email_valid.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-29 18:39 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/confirmation/models.py b/confirmation/models.py index 2ab4fcb9a5..d597d9e14a 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # Copyright: (c) 2008, Jarek Zgoda __revision__ = '$Id: models.py 28 2009-10-22 15:03:02Z jarek.zgoda $' diff --git a/confirmation/settings.py b/confirmation/settings.py index 5cd4d0bd2b..f141d4055b 100644 --- a/confirmation/settings.py +++ b/confirmation/settings.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # Copyright: (c) 2008, Jarek Zgoda __revision__ = '$Id: settings.py 12 2008-11-23 19:38:52Z jarek.zgoda $' diff --git a/corporate/migrations/0001_initial.py b/corporate/migrations/0001_initial.py index 6995460dde..968b3f230a 100644 --- a/corporate/migrations/0001_initial.py +++ b/corporate/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-09-25 12:02 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/corporate/migrations/0002_customer_default_discount.py b/corporate/migrations/0002_customer_default_discount.py index 6708498504..f4ff47f9a9 100644 --- a/corporate/migrations/0002_customer_default_discount.py +++ b/corporate/migrations/0002_customer_default_discount.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-12 20:19 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/corporate/migrations/0003_customerplan.py b/corporate/migrations/0003_customerplan.py index ecbc6bf6ef..50457b446d 100644 --- a/corporate/migrations/0003_customerplan.py +++ b/corporate/migrations/0003_customerplan.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-22 21:05 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/corporate/migrations/0004_licenseledger.py b/corporate/migrations/0004_licenseledger.py index 691671edb6..ed7d01f7eb 100644 --- a/corporate/migrations/0004_licenseledger.py +++ b/corporate/migrations/0004_licenseledger.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-19 05:01 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/corporate/migrations/0005_customerplan_invoicing.py b/corporate/migrations/0005_customerplan_invoicing.py index ef2a7a444f..09fbee94cb 100644 --- a/corporate/migrations/0005_customerplan_invoicing.py +++ b/corporate/migrations/0005_customerplan_invoicing.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-28 13:04 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/corporate/migrations/0006_nullable_stripe_customer_id.py b/corporate/migrations/0006_nullable_stripe_customer_id.py index 7b0348f1f6..3fe367520a 100644 --- a/corporate/migrations/0006_nullable_stripe_customer_id.py +++ b/corporate/migrations/0006_nullable_stripe_customer_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-29 01:46 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/corporate/migrations/0007_remove_deprecated_fields.py b/corporate/migrations/0007_remove_deprecated_fields.py index 9d19f85aea..e8976956d4 100644 --- a/corporate/migrations/0007_remove_deprecated_fields.py +++ b/corporate/migrations/0007_remove_deprecated_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-31 22:16 -from __future__ import unicode_literals from django.db import migrations diff --git a/corporate/migrations/0008_nullable_next_invoice_date.py b/corporate/migrations/0008_nullable_next_invoice_date.py index 729705d3d8..e9bf1c1486 100644 --- a/corporate/migrations/0008_nullable_next_invoice_date.py +++ b/corporate/migrations/0008_nullable_next_invoice_date.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-04-11 00:45 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 625a0506ad..7719306dfd 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -105,7 +105,7 @@ def read_stripe_fixture(decorated_function_name: str, def _read_stripe_fixture(*args: Any, **kwargs: Any) -> Any: mock = operator.attrgetter(mocked_function_name)(sys.modules[__name__]) fixture_path = stripe_fixture_path(decorated_function_name, mocked_function_name, mock.call_count) - fixture = ujson.load(open(fixture_path, 'r')) + fixture = ujson.load(open(fixture_path)) # Check for StripeError fixtures if "json_body" in fixture: requestor = stripe.api_requestor.APIRequestor() @@ -151,7 +151,7 @@ def normalize_fixture_data(decorated_function: CallableT, normalized_values = {pattern: {} for pattern in pattern_translations.keys()} # type: Dict[str, Dict[str, str]] for fixture_file in fixture_files_for_function(decorated_function): - with open(fixture_file, "r") as f: + with open(fixture_file) as f: file_content = f.read() for pattern, translation in pattern_translations.items(): for match in re.findall(pattern, file_content): @@ -214,7 +214,7 @@ def mock_stripe(tested_timestamp_fields: List[str]=[], # A Kandra is a fictional character that can become anything. Used as a # wildcard when testing for equality. -class Kandra(object): # nocoverage: TODO +class Kandra: # nocoverage: TODO def __eq__(self, other: Any) -> bool: return True @@ -288,7 +288,7 @@ class StripeTestCase(ZulipTestCase): # Upgrade without talking to Stripe def local_upgrade(self, *args: Any) -> None: - class StripeMock(object): + class StripeMock: def __init__(self, depth: int=1): self.id = 'id' self.created = '1000' @@ -1045,8 +1045,8 @@ class RequiresBillingAccessTest(ZulipTestCase): # Make sure that we are testing all the JSON endpoints # Quite a hack, but probably fine for now string_with_all_endpoints = str(get_resolver('corporate.urls').reverse_dict) - json_endpoints = set([word.strip("\"'()[],$") for word in string_with_all_endpoints.split() - if 'json' in word]) + json_endpoints = {word.strip("\"'()[],$") for word in string_with_all_endpoints.split() + if 'json' in word} # No need to test upgrade endpoint as it only requires user to be logged in. json_endpoints.remove("json/billing/upgrade") diff --git a/docs/conf.py b/docs/conf.py index 7ff84ba170..931510f2e7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # zulip-contributor-docs documentation build configuration file, created by # sphinx-quickstart on Mon Aug 17 16:24:04 2015. diff --git a/manage.py b/manage.py index b36eb1abcf..ce8204c393 100755 --- a/manage.py +++ b/manage.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from __future__ import (print_function) import os import sys import configparser diff --git a/pgroonga/migrations/0001_enable.py b/pgroonga/migrations/0001_enable.py index 50ac86fff6..9c0797e1ef 100644 --- a/pgroonga/migrations/0001_enable.py +++ b/pgroonga/migrations/0001_enable.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.db import migrations diff --git a/pgroonga/migrations/0002_html_escape_subject.py b/pgroonga/migrations/0002_html_escape_subject.py index 144023f7c4..9791451456 100644 --- a/pgroonga/migrations/0002_html_escape_subject.py +++ b/pgroonga/migrations/0002_html_escape_subject.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import connection, migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/pgroonga/migrations/0003_v2_api_upgrade.py b/pgroonga/migrations/0003_v2_api_upgrade.py index f52c4b1daf..1c3aa2b66d 100644 --- a/pgroonga/migrations/0003_v2_api_upgrade.py +++ b/pgroonga/migrations/0003_v2_api_upgrade.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.db import migrations diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_cron_file b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_cron_file index b0f165f10d..416be339a2 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_cron_file +++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_cron_file @@ -15,7 +15,7 @@ def nagios_from_file(results_file: str, max_time_diff: int=60 * 2) -> 'Tuple[int This file is created by various nagios checking cron jobs such as check-rabbitmq-queues and check-rabbitmq-consumers""" - with open(results_file, 'r') as f: + with open(results_file) as f: data = f.read().strip() pieces = data.split('|') diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time index e4cb514fe1..ca7fed8e62 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time +++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time @@ -113,7 +113,7 @@ def get_zulips(): last_event_id = max(last_event_id, int(event['id'])) # If we get a heartbeat event, that means we've been hanging for # 40s, and we should bail. - if 'heartbeat' in set(event['type'] for event in res['events']): + if 'heartbeat' in {event['type'] for event in res['events']}: report("CRITICAL", msg="Got heartbeat waiting for Zulip, which means get_events is hanging") return [event['message'] for event in res['events']] diff --git a/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup b/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup index be2425f1e6..8724caea7f 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup +++ b/puppet/zulip/files/nagios_plugins/zulip_postgres_common/check_postgres_backup @@ -24,9 +24,9 @@ if subprocess.check_output(['psql', '-v', 'ON_ERROR_STOP=1', report('OK', 'this is not the primary') try: - with open('/var/lib/nagios_state/last_postgres_backup', 'r') as f: + with open('/var/lib/nagios_state/last_postgres_backup') as f: last_backup = dateutil.parser.parse(f.read()) -except IOError: +except OSError: report('UNKNOWN', 'could not determine completion time of last Postgres backup') if datetime.now(tz=pytz.utc) - last_backup > timedelta(hours=25): diff --git a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors index dd5c6481d3..1c2b82da26 100755 --- a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors +++ b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_personal_zephyr_mirrors @@ -31,7 +31,7 @@ down_count = 0 for results_file_name in os.listdir(RESULTS_DIR): this_state = "OK" results_file = os.path.join(RESULTS_DIR, results_file_name) - with open(results_file, 'r') as f: + with open(results_file) as f: data = f.read().strip() last_check = os.stat(results_file).st_mtime time_since_last_check = time.time() - last_check diff --git a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror index ea9a9adea6..e55d83c5e5 100755 --- a/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror +++ b/puppet/zulip_ops/files/nagios_plugins/zulip_zephyr_mirror/check_zephyr_mirror @@ -29,7 +29,7 @@ def report(state, data, last_check): data)) exit(states[state]) -with open(RESULTS_FILE, 'r') as f: +with open(RESULTS_FILE) as f: data = f.read().strip() if data.split("\n")[-1].strip() == "0": state = "OK" diff --git a/scripts/lib/clean_emoji_cache.py b/scripts/lib/clean_emoji_cache.py index 74285f32a3..80402e5594 100755 --- a/scripts/lib/clean_emoji_cache.py +++ b/scripts/lib/clean_emoji_cache.py @@ -18,7 +18,7 @@ if ENV == "travis": def get_caches_in_use(threshold_days): # type: (int) -> Set[str] - setups_to_check = set([ZULIP_PATH, ]) + setups_to_check = {ZULIP_PATH} caches_in_use = set() if ENV == "prod": diff --git a/scripts/lib/clean_node_cache.py b/scripts/lib/clean_node_cache.py index c7446ed770..208caef7d5 100755 --- a/scripts/lib/clean_node_cache.py +++ b/scripts/lib/clean_node_cache.py @@ -25,7 +25,7 @@ if ENV == "travis": def get_caches_in_use(threshold_days): # type: (int) -> Set[str] - setups_to_check = set([ZULIP_PATH, ]) + setups_to_check = {ZULIP_PATH} caches_in_use = set() if ENV == "prod": diff --git a/scripts/lib/clean_venv_cache.py b/scripts/lib/clean_venv_cache.py index c7c7e73c03..3238bc0615 100755 --- a/scripts/lib/clean_venv_cache.py +++ b/scripts/lib/clean_venv_cache.py @@ -20,7 +20,7 @@ if ENV == "travis": def get_caches_in_use(threshold_days): # type: (int) -> Set[str] - setups_to_check = set([ZULIP_PATH, ]) + setups_to_check = {ZULIP_PATH} caches_in_use = set() def add_current_venv_cache(venv_name: str) -> None: diff --git a/scripts/lib/node_cache.py b/scripts/lib/node_cache.py index 7a712f2ade..74db364dcf 100644 --- a/scripts/lib/node_cache.py +++ b/scripts/lib/node_cache.py @@ -39,7 +39,7 @@ def generate_sha1sum_node_modules(setup_dir=None, production=DEFAULT_PRODUCTION) if os.path.exists(YARN_LOCK_FILE_PATH): # For backwards compatibility, we can't assume yarn.lock exists sha1sum.update(subprocess_text_output(['cat', YARN_LOCK_FILE_PATH]).encode('utf8')) - with open(YARN_PACKAGE_JSON, "r") as f: + with open(YARN_PACKAGE_JSON) as f: yarn_version = json.load(f)['version'] sha1sum.update(yarn_version.encode("utf8")) sha1sum.update(subprocess_text_output(['node', '--version']).encode('utf8')) diff --git a/scripts/lib/setup_venv.py b/scripts/lib/setup_venv.py index 0aa58e3338..235ba75d55 100644 --- a/scripts/lib/setup_venv.py +++ b/scripts/lib/setup_venv.py @@ -171,7 +171,7 @@ def get_venv_packages(venv_path): package index file. """ with open(get_index_filename(venv_path)) as reader: - return set(p.strip() for p in reader.read().split('\n') if p.strip()) + return {p.strip() for p in reader.read().split('\n') if p.strip()} def try_to_copy_venv(venv_path, new_packages): # type: (str, Set[str]) -> bool @@ -281,7 +281,7 @@ def do_patch_activate_script(venv_path): # venv_path should be what we want to have in VIRTUAL_ENV after patching script_path = os.path.join(venv_path, "bin", "activate") - with open(script_path, 'r') as f: + with open(script_path) as f: lines = f.readlines() for i, line in enumerate(lines): if line.startswith('VIRTUAL_ENV='): diff --git a/scripts/lib/upgrade-zulip-stage-2 b/scripts/lib/upgrade-zulip-stage-2 index 36a7e3cffa..3b984e2e46 100755 --- a/scripts/lib/upgrade-zulip-stage-2 +++ b/scripts/lib/upgrade-zulip-stage-2 @@ -65,7 +65,7 @@ if not args.skip_puppet: subprocess.check_call(["apt-get", "update"]) subprocess.check_call(["apt-get", "-y", "upgrade"]) -if not os.path.exists((os.path.join(deploy_path, "zproject/prod_settings.py"))): +if not os.path.exists(os.path.join(deploy_path, "zproject/prod_settings.py")): # This is normally done in unpack-zulip, but for upgrading from # zulip<1.4.0, we need to do it. See discussion in commit 586b23637. os.symlink("/etc/zulip/settings.py", diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 96a55ecfd4..7ccb661074 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -289,7 +289,7 @@ def get_caches_to_be_purged(caches_dir, caches_in_use, threshold_days): def purge_unused_caches(caches_dir, caches_in_use, cache_type, args): # type: (str, Set[str], str, argparse.Namespace) -> None - all_caches = set([os.path.join(caches_dir, cache) for cache in os.listdir(caches_dir)]) + all_caches = {os.path.join(caches_dir, cache) for cache in os.listdir(caches_dir)} caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, args.threshold_days) caches_to_keep = all_caches - caches_to_purge @@ -313,7 +313,7 @@ def generate_sha1sum_emoji(zulip_path): # Take into account the version of `emoji-datasource-google` package # while generating success stamp. PACKAGE_FILE_PATH = os.path.join(zulip_path, 'package.json') - with open(PACKAGE_FILE_PATH, 'r') as fp: + with open(PACKAGE_FILE_PATH) as fp: parsed_package_file = json.load(fp) dependency_data = parsed_package_file['dependencies'] @@ -366,7 +366,7 @@ def parse_os_release(): we avoid using it, as it is not available on RHEL-based platforms. """ distro_info = {} # type: Dict[str, str] - with open('/etc/os-release', 'r') as fp: + with open('/etc/os-release') as fp: for line in fp: line = line.strip() if not line or line.startswith('#'): diff --git a/scripts/purge-old-deployments b/scripts/purge-old-deployments index 155d87d235..b003eaa8d4 100755 --- a/scripts/purge-old-deployments +++ b/scripts/purge-old-deployments @@ -36,8 +36,8 @@ def parse_args(): def get_deployments_to_be_purged(recent_deployments): # type: (Set[str]) -> Set[str] - all_deployments = set([os.path.join(DEPLOYMENTS_DIR, deployment) - for deployment in os.listdir(DEPLOYMENTS_DIR)]) + all_deployments = {os.path.join(DEPLOYMENTS_DIR, deployment) + for deployment in os.listdir(DEPLOYMENTS_DIR)} deployments_to_purge = set() for deployment in all_deployments: # Deployments whose name is not in the format of a timestamp are diff --git a/tools/documentation_crawler/documentation_crawler/settings.py b/tools/documentation_crawler/documentation_crawler/settings.py index f484f88798..da821f8a97 100644 --- a/tools/documentation_crawler/documentation_crawler/settings.py +++ b/tools/documentation_crawler/documentation_crawler/settings.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # Scrapy settings for documentation_crawler project # # For simplicity, this file contains only settings considered important or diff --git a/tools/droplets/create.py b/tools/droplets/create.py index 5387aab8e8..3473b5b37b 100644 --- a/tools/droplets/create.py +++ b/tools/droplets/create.py @@ -41,8 +41,8 @@ def get_config(): def user_exists(username): # type: (str) -> bool - print("Checking to see if GitHub user {0} exists...".format(username)) - user_api_url = "https://api.github.com/users/{0}".format(username) + print("Checking to see if GitHub user {} exists...".format(username)) + user_api_url = "https://api.github.com/users/{}".format(username) try: response = urllib.request.urlopen(user_api_url) json.load(response) @@ -50,30 +50,30 @@ def user_exists(username): return True except urllib.error.HTTPError as err: print(err) - print("Does the github user {0} exist?".format(username)) + print("Does the github user {} exist?".format(username)) sys.exit(1) def get_keys(username): # type: (str) -> List[Dict[str, Any]] print("Checking to see that GitHub user has available public keys...") - apiurl_keys = "https://api.github.com/users/{0}/keys".format(username) + apiurl_keys = "https://api.github.com/users/{}/keys".format(username) try: response = urllib.request.urlopen(apiurl_keys) userkeys = json.load(response) if not userkeys: - print("No keys found. Has user {0} added ssh keys to their github account?".format(username)) + print("No keys found. Has user {} added ssh keys to their github account?".format(username)) sys.exit(1) print("...public keys found!") return userkeys except urllib.error.HTTPError as err: print(err) - print("Has user {0} added ssh keys to their github account?".format(username)) + print("Has user {} added ssh keys to their github account?".format(username)) sys.exit(1) def fork_exists(username): # type: (str) -> bool print("Checking to see GitHub user has forked zulip/zulip...") - apiurl_fork = "https://api.github.com/repos/{0}/zulip".format(username) + apiurl_fork = "https://api.github.com/repos/{}/zulip".format(username) try: response = urllib.request.urlopen(apiurl_fork) json.load(response) @@ -81,21 +81,21 @@ def fork_exists(username): return True except urllib.error.HTTPError as err: print(err) - print("Has user {0} forked zulip/zulip?".format(username)) + print("Has user {} forked zulip/zulip?".format(username)) sys.exit(1) def exit_if_droplet_exists(my_token: str, username: str, recreate: bool) -> None: - print("Checking to see if droplet for {0} already exists...".format(username)) + print("Checking to see if droplet for {} already exists...".format(username)) manager = digitalocean.Manager(token=my_token) my_droplets = manager.get_all_droplets() for droplet in my_droplets: - if droplet.name == "{0}.zulipdev.org".format(username): + if droplet.name == "{}.zulipdev.org".format(username): if not recreate: - print("Droplet for user {0} already exists. Pass --recreate if you " + print("Droplet for user {} already exists. Pass --recreate if you " "need to recreate the droplet.".format(username)) sys.exit(1) else: - print("Deleting existing droplet for {0}.".format(username)) + print("Deleting existing droplet for {}.".format(username)) droplet.destroy() return print("...No droplet found...proceeding.") @@ -108,7 +108,7 @@ def set_user_data(username, userkeys): # spaces here are important here - these need to be properly indented under # ssh_authorized_keys: for key in userkeys: - ssh_authorized_keys += "\n - {0}".format(key['key']) + ssh_authorized_keys += "\n - {}".format(key['key']) # print(ssh_authorized_keys) setup_repo = """\ @@ -121,11 +121,11 @@ cd /home/zulipdev/{1} && git remote add origin https://github.com/{0}/{1}.git && #cloud-config users: - name: zulipdev - ssh_authorized_keys:{0} + ssh_authorized_keys:{} runcmd: - - su -c '{1}' zulipdev + - su -c '{}' zulipdev - su -c 'git clean -f' zulipdev - - su -c '{2}' zulipdev + - su -c '{}' zulipdev - su -c 'git clean -f' zulipdev - su -c 'git config --global core.editor nano' zulipdev - su -c 'git config --global pull.rebase true' zulipdev @@ -141,7 +141,7 @@ def create_droplet(my_token, template_id, username, tags, user_data): # type: (str, str, str, List[str], str) -> str droplet = digitalocean.Droplet( token=my_token, - name='{0}.zulipdev.org'.format(username), + name='{}.zulipdev.org'.format(username), region='nyc3', image=template_id, size_slug='2gb', @@ -157,7 +157,7 @@ def create_droplet(my_token, template_id, username, tags, user_data): actions = droplet.get_actions() for action in actions: action.load() - print("...[{0}]: {1}".format(action.type, action.status)) + print("...[{}]: {}".format(action.type, action.status)) if action.type == 'create' and action.status == 'completed': incomplete = False break @@ -165,7 +165,7 @@ def create_droplet(my_token, template_id, username, tags, user_data): time.sleep(15) print("...droplet created!") droplet.load() - print("...ip address for new droplet is: {0}.".format(droplet.ip_address)) + print("...ip address for new droplet is: {}.".format(droplet.ip_address)) return droplet.ip_address def delete_existing_records(records: List[digitalocean.Record], record_name: str) -> None: @@ -175,7 +175,7 @@ def delete_existing_records(records: List[digitalocean.Record], record_name: str record.destroy() count = count + 1 if count: - print("Deleted {0} existing A records for {1}.zulipdev.org.".format(count, record_name)) + print("Deleted {} existing A records for {}.zulipdev.org.".format(count, record_name)) def create_dns_record(my_token, username, ip_address): # type: (str, str, str) -> None @@ -187,9 +187,9 @@ def create_dns_record(my_token, username, ip_address): wildcard_name = "*." + username delete_existing_records(records, wildcard_name) - print("Creating new A record for {0}.zulipdev.org that points to {1}.".format(username, ip_address)) + print("Creating new A record for {}.zulipdev.org that points to {}.".format(username, ip_address)) domain.create_new_domain_record(type='A', name=username, data=ip_address) - print("Creating new A record for *.{0}.zulipdev.org that points to {1}.".format(username, ip_address)) + print("Creating new A record for *.{}.zulipdev.org that points to {}.".format(username, ip_address)) domain.create_new_domain_record(type='A', name=wildcard_name, data=ip_address) def print_completion(username): @@ -231,7 +231,7 @@ if __name__ == '__main__': # get command line arguments args = parser.parse_args() - print("Creating Zulip developer environment for GitHub user {0}...".format(args.username)) + print("Creating Zulip developer environment for GitHub user {}...".format(args.username)) # get config details config = get_config() diff --git a/tools/fetch-contributor-data b/tools/fetch-contributor-data index 4f9e6a91c3..f1d8702b99 100755 --- a/tools/fetch-contributor-data +++ b/tools/fetch-contributor-data @@ -54,7 +54,7 @@ def write_to_disk(json_data: ContributorsJSON, out_file: str) -> None: with open(out_file, 'w') as f: try: f.write("{}\n".format(json.dumps(json_data, indent=2, sort_keys=True))) - except IOError as e: + except OSError as e: logger.warning(e) sys.exit(1) @@ -126,7 +126,7 @@ def update_contributor_data_file() -> None: # remove duplicate contributions count # find commits at the time of split and subtract from zulip-server - with open(duplicate_commits_file, 'r') as f: + with open(duplicate_commits_file) as f: duplicate_commits = json.load(f) for committer in duplicate_commits: if committer in contribs_list and contribs_list[committer].get('server'): diff --git a/tools/get-handlebar-vars b/tools/get-handlebar-vars index 75a64093ea..8d711a8c27 100755 --- a/tools/get-handlebar-vars +++ b/tools/get-handlebar-vars @@ -15,7 +15,7 @@ def debug(obj): def parse_file(fn): # type: (str) -> Dict[str, Any] - with open(fn, 'r') as f: + with open(fn) as f: text = f.read() tags = re.findall(r'{+\s*(.*?)\s*}+', text) root = {} # type: Dict[str, Any] diff --git a/tools/i18n/tagmessages b/tools/i18n/tagmessages index 98265b4263..853a4d2044 100755 --- a/tools/i18n/tagmessages +++ b/tools/i18n/tagmessages @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from __future__ import absolute_import -from __future__ import print_function import configparser from hashlib import md5 diff --git a/tools/lib/gitlint-rules.py b/tools/lib/gitlint-rules.py index 8045ad575a..f7d36e05da 100644 --- a/tools/lib/gitlint-rules.py +++ b/tools/lib/gitlint-rules.py @@ -159,7 +159,7 @@ class TitleMatchRegexAllowException(LineRule): regex = self.options['regex'].value pattern = re.compile(regex, re.UNICODE) if not pattern.search(title) and not title.startswith("Revert \""): - violation_msg = u"Title does not match regex ({0})".format(regex) + violation_msg = "Title does not match regex ({})".format(regex) return [RuleViolation(self.id, violation_msg, title)] return [] diff --git a/tools/lib/graph.py b/tools/lib/graph.py index da4ebe860d..762dbbdf67 100644 --- a/tools/lib/graph.py +++ b/tools/lib/graph.py @@ -119,7 +119,7 @@ def make_dot_file(graph): def test(): # type: () -> None - graph = Graph(set([ + graph = Graph({ ('x', 'a'), ('a', 'b'), ('b', 'c'), @@ -128,7 +128,7 @@ def test(): ('d', 'e'), ('e', 'f'), ('e', 'g'), - ])) + }) graph.remove_exterior_nodes() s = make_dot_file(graph) diff --git a/tools/lib/html_branches.py b/tools/lib/html_branches.py index 702914dd04..02a98a593e 100644 --- a/tools/lib/html_branches.py +++ b/tools/lib/html_branches.py @@ -193,7 +193,7 @@ def build_id_dict(templates): template_id_dict = defaultdict(list) # type: (Dict[str, List[str]]) for fn in templates: - with open(fn, 'r') as f: + with open(fn) as f: text = f.read() list_tags = tokenize(text) diff --git a/tools/lib/html_grep.py b/tools/lib/html_grep.py index 7a9387ed15..6cc3eef604 100644 --- a/tools/lib/html_grep.py +++ b/tools/lib/html_grep.py @@ -7,7 +7,7 @@ def show_all_branches(fns): # type: (List[str]) -> None for fn in fns: print(fn) - with open(fn, 'r') as f: + with open(fn) as f: text = f.read() branches = html_branches(text, fn=fn) for branch in branches: @@ -26,7 +26,7 @@ class Grepper: all_branches = [] # type: List[HtmlTreeBranch] for fn in fns: - with open(fn, 'r') as f: + with open(fn) as f: text = f.read() branches = html_branches(text, fn=fn) all_branches += branches diff --git a/tools/lib/pretty_print.py b/tools/lib/pretty_print.py index 11d80fa8e5..fa08722651 100644 --- a/tools/lib/pretty_print.py +++ b/tools/lib/pretty_print.py @@ -193,7 +193,7 @@ def pretty_print_html(html, num_spaces=4): def validate_indent_html(fn, fix): # type: (str, bool) -> int - with open(fn, 'r') as f: + with open(fn) as f: html = f.read() phtml = pretty_print_html(html) if not html.split('\n') == phtml.split('\n'): diff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.py index 89d115ec81..e6ea0a640a 100755 --- a/tools/lib/provision_inner.py +++ b/tools/lib/provision_inner.py @@ -41,7 +41,7 @@ def setup_shell_profile(shell_profile): def write_command(command): # type: (str) -> None if os.path.exists(shell_profile_path): - with open(shell_profile_path, 'r') as shell_profile_file: + with open(shell_profile_path) as shell_profile_file: lines = [line.strip() for line in shell_profile_file.readlines()] if command not in lines: with open(shell_profile_path, 'a+') as shell_profile_file: @@ -77,7 +77,7 @@ def setup_bash_profile() -> None: if os.path.exists(DOT_PROFILE): try: - with open(BASH_PROFILE, "r") as f: + with open(BASH_PROFILE) as f: profile_contents = f.read() if profile_contents == OLD_PROFILE_TEXT: os.unlink(BASH_PROFILE) diff --git a/tools/lib/template_parser.py b/tools/lib/template_parser.py index 2716d5bfa7..8a98c99af5 100644 --- a/tools/lib/template_parser.py +++ b/tools/lib/template_parser.py @@ -214,7 +214,7 @@ def validate(fn=None, text=None, check_indent=True): fn = '' if text is None: - with open(fn, 'r') as f: + with open(fn) as f: text = f.read() tokens = tokenize(text) diff --git a/tools/lib/test_script.py b/tools/lib/test_script.py index 4d4b1b6ca0..50b3523f10 100644 --- a/tools/lib/test_script.py +++ b/tools/lib/test_script.py @@ -56,7 +56,7 @@ def get_provisioning_status(): # their own dependencies and not running provision. return True, None - with open(version_file, 'r') as f: + with open(version_file) as f: version = f.read().strip() # Normal path for people that provision--we're all good! diff --git a/tools/lint b/tools/lint index 02ac0bb594..a0f376502e 100755 --- a/tools/lint +++ b/tools/lint @@ -1,6 +1,4 @@ #!/usr/bin/env python3 -from __future__ import print_function -from __future__ import absolute_import import os import sys import argparse diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 4307eee9c2..2e2020f5b0 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -1,8 +1,3 @@ -# -*- coding: utf-8 -*- - -from __future__ import print_function -from __future__ import absolute_import - from typing import List, TYPE_CHECKING from zulint.custom_rules import RuleList @@ -57,7 +52,7 @@ FILES_WITH_LEGACY_SUBJECT = { shebang_rules = [ {'pattern': '^#!', 'description': "zerver library code shouldn't have a shebang line.", - 'include_only': set(['zerver/'])}, + 'include_only': {'zerver/'}}, # /bin/sh and /usr/bin/env are the only two binaries # that NixOS provides at a fixed path (outside a # buildFHSUserEnv sandbox). @@ -81,12 +76,12 @@ whitespace_rules = [ }, {'pattern': '\t', 'strip': '\n', - 'exclude': set(['tools/ci/success-http-headers.txt']), + 'exclude': {'tools/ci/success-http-headers.txt'}, 'description': 'Fix tab-based whitespace'}, ] # type: List[Rule] comma_whitespace_rule = [ {'pattern': ', {2,}[^#/ ]', - 'exclude': set(['zerver/tests', 'frontend_tests/node_tests', 'corporate/tests']), + 'exclude': {'zerver/tests', 'frontend_tests/node_tests', 'corporate/tests'}, 'description': "Remove multiple whitespaces after ','", 'good_lines': ['foo(1, 2, 3)', 'foo = bar # some inline comment'], 'bad_lines': ['foo(1, 2, 3)', 'foo(1, 2, 3)']}, @@ -110,8 +105,8 @@ js_rules = RuleList( langs=['js'], rules=[ {'pattern': 'subject|SUBJECT', - 'exclude': set(['static/js/util.js', - 'frontend_tests/']), + 'exclude': {'static/js/util.js', + 'frontend_tests/'}, 'exclude_pattern': 'emails', 'description': 'avoid subject in JS code', 'good_lines': ['topic_name'], @@ -155,7 +150,7 @@ js_rules = RuleList( 'description': 'Write JS else statements on same line as }'}, {'pattern': r'''[.]text\(["'][a-zA-Z]''', 'description': 'Strings passed to $().text should be wrapped in i18n.t() for internationalization', - 'exclude': set(['frontend_tests/node_tests/'])}, + 'exclude': {'frontend_tests/node_tests/'}}, {'pattern': r'''compose_error\(["']''', 'description': 'Argument to compose_error should be a literal string enclosed ' 'by i18n.t()'}, @@ -177,7 +172,7 @@ js_rules = RuleList( 'bad_lines': ['$(document).ready(function () {foo();}']}, {'pattern': '[$][.](get|post|patch|delete|ajax)[(]', 'description': "Use channel module for AJAX calls", - 'exclude': set([ + 'exclude': { # Internal modules can do direct network calls 'static/js/blueslip.js', 'static/js/channel.js', @@ -185,17 +180,17 @@ js_rules = RuleList( 'static/js/stats/', 'static/js/portico/', 'static/js/billing/', - ]), + }, 'good_lines': ['channel.get(...)'], 'bad_lines': ['$.get()', '$.post()', '$.ajax()']}, {'pattern': 'style ?=', 'description': "Avoid using the `style=` attribute; we prefer styling in CSS files", - 'exclude': set([ + 'exclude': { 'frontend_tests/node_tests/copy_and_paste.js', 'frontend_tests/node_tests/upload.js', 'static/js/upload.js', 'static/js/stream_color.js', - ]), + }, 'good_lines': ['#my-style {color: blue;}'], 'bad_lines': ['

Foo

', 'style = "color: blue;"']}, *whitespace_rules, @@ -212,14 +207,14 @@ python_rules = RuleList( 'good_lines': ['topic_name'], 'bad_lines': ['subject="foo"', ' MAX_SUBJECT_LEN'], 'exclude': FILES_WITH_LEGACY_SUBJECT, - 'include_only': set([ + 'include_only': { 'zerver/data_import/', 'zerver/lib/', 'zerver/tests/', - 'zerver/views/'])}, + 'zerver/views/'}}, {'pattern': 'msgid|MSGID', - 'exclude': set(['tools/check-capitalization', - 'tools/i18n/tagmessages']), + 'exclude': {'tools/check-capitalization', + 'tools/i18n/tagmessages'}, 'description': 'Avoid using "msgid" as a variable name; use "message_id" instead.'}, {'pattern': '^(?!#)@login_required', 'description': '@login_required is unsupported; use @zulip_login_required', @@ -227,10 +222,10 @@ python_rules = RuleList( 'bad_lines': ['@login_required', ' @login_required']}, {'pattern': '^user_profile[.]save[(][)]', 'description': 'Always pass update_fields when saving user_profile objects', - 'exclude_line': set([ + 'exclude_line': { ('zerver/lib/actions.py', "user_profile.save() # Can't use update_fields because of how the foreign key works."), - ]), - 'exclude': set(['zerver/tests', 'zerver/lib/create_user.py']), + }, + 'exclude': {'zerver/tests', 'zerver/lib/create_user.py'}, 'good_lines': ['user_profile.save(update_fields=["pointer"])'], 'bad_lines': ['user_profile.save()']}, {'pattern': r'^[^"]*"[^"]*"%\(', @@ -252,7 +247,7 @@ python_rules = RuleList( 'bad_lines': ['a =b', 'asdf =42']}, {'pattern': r'":\w[^"]*$', 'description': 'Missing whitespace after ":"', - 'exclude': set(['zerver/tests/test_push_notifications.py']), + 'exclude': {'zerver/tests/test_push_notifications.py'}, 'good_lines': ['"foo": bar', '"some:string:with:colons"'], 'bad_lines': ['"foo":bar', '"foo":1']}, {'pattern': r"':\w[^']*$", @@ -261,7 +256,7 @@ python_rules = RuleList( 'bad_lines': ["'foo':bar", "'foo':1"]}, {'pattern': r"^\s+#\w", 'strip': '\n', - 'exclude': set(['tools/droplets/create.py']), + 'exclude': {'tools/droplets/create.py'}, 'description': 'Missing whitespace after "#"', 'good_lines': ['a = b # some operation', '1+2 # 3 is the result'], 'bad_lines': [' #some operation', ' #not valid!!!']}, @@ -278,9 +273,9 @@ python_rules = RuleList( 'good_lines': ['# type: (Any, Any)', 'colon:separated:string:containing:type:as:keyword'], 'bad_lines': ['# type:(Any, Any)']}, {'pattern': "type: ignore$", - 'exclude': set(['tools/tests', - 'zerver/lib/test_runner.py', - 'zerver/tests']), + 'exclude': {'tools/tests', + 'zerver/lib/test_runner.py', + 'zerver/tests'}, 'description': '"type: ignore" should always end with "# type: ignore # explanation for why"', 'good_lines': ['foo = bar # type: ignore # explanation'], 'bad_lines': ['foo = bar # type: ignore']}, @@ -318,17 +313,17 @@ python_rules = RuleList( 'good_lines': ['"foo %s bar" % ("baz",)"'], 'bad_lines': ['"foo %s bar" % ("baz")']}, {'pattern': 'sudo', - 'include_only': set(['scripts/']), - 'exclude': set(['scripts/lib/setup_venv.py']), - 'exclude_line': set([ + 'include_only': {'scripts/'}, + 'exclude': {'scripts/lib/setup_venv.py'}, + 'exclude_line': { ('scripts/lib/zulip_tools.py', 'sudo_args = kwargs.pop(\'sudo_args\', [])'), ('scripts/lib/zulip_tools.py', 'args = [\'sudo\'] + sudo_args + [\'--\'] + args'), - ]), + }, 'description': 'Most scripts are intended to run on systems without sudo.', 'good_lines': ['subprocess.check_call(["ls"])'], 'bad_lines': ['subprocess.check_call(["sudo", "ls"])']}, {'pattern': 'django.utils.translation', - 'include_only': set(['test/', 'zerver/views/development/']), + 'include_only': {'test/', 'zerver/views/development/'}, 'description': 'Test strings should not be tagged for translation', 'good_lines': [''], 'bad_lines': ['django.utils.translation']}, @@ -341,25 +336,23 @@ python_rules = RuleList( 'good_lines': ['return json_success()'], 'bad_lines': ['return json_success({})']}, {'pattern': r'\Wjson_error\(_\(?\w+\)', - 'exclude': set(['zerver/tests', 'zerver/views/development/']), + 'exclude': {'zerver/tests', 'zerver/views/development/'}, 'description': 'Argument to json_error should be a literal string enclosed by _()', 'good_lines': ['return json_error(_("string"))'], 'bad_lines': ['return json_error(_variable)', 'return json_error(_(variable))']}, {'pattern': r'''\Wjson_error\(['"].+[),]$''', - 'exclude': set(['zerver/tests']), + 'exclude': {'zerver/tests'}, 'description': 'Argument to json_error should a literal string enclosed by _()'}, # To avoid JsonableError(_variable) and JsonableError(_(variable)) {'pattern': r'\WJsonableError\(_\(?\w.+\)', - 'exclude': set(['zerver/tests', 'zerver/views/development/']), + 'exclude': {'zerver/tests', 'zerver/views/development/'}, 'description': 'Argument to JsonableError should be a literal string enclosed by _()'}, {'pattern': r'''\WJsonableError\(["'].+\)''', - 'exclude': set(['zerver/tests', 'zerver/views/development/']), + 'exclude': {'zerver/tests', 'zerver/views/development/'}, 'description': 'Argument to JsonableError should be a literal string enclosed by _()'}, {'pattern': r"""\b_\((?:\s|{}|{})*[^\s'")]""".format(PYSQ, PYDQ), 'description': 'Called _() on a computed string', - 'exclude_line': set([ - ('zerver/lib/i18n.py', 'result = _(string)'), - ]), + 'exclude_line': {('zerver/lib/i18n.py', 'result = _(string)')}, 'good_lines': ["return json_error(_('No presence data for %s') % (target.email,))"], 'bad_lines': ["return json_error(_('No presence data for %s' % (target.email,)))"]}, {'pattern': r'''([a-zA-Z0-9_]+)=REQ\(['"]\1['"]''', @@ -371,35 +364,35 @@ python_rules = RuleList( '''}, # Directly fetching Message objects in e.g. views code is often a security bug. {'pattern': '[^r]Message.objects.get', - 'exclude': set(["zerver/tests", - "zerver/lib/onboarding.py", - "zilencer/management/commands/add_mock_conversation.py", - "zerver/worker/queue_processors.py", - "zerver/management/commands/export.py", - "zerver/lib/export.py"]), + 'exclude': {"zerver/tests", + "zerver/lib/onboarding.py", + "zilencer/management/commands/add_mock_conversation.py", + "zerver/worker/queue_processors.py", + "zerver/management/commands/export.py", + "zerver/lib/export.py"}, 'description': 'Please use access_message() to fetch Message objects', }, {'pattern': 'Stream.objects.get', - 'include_only': set(["zerver/views/"]), + 'include_only': {"zerver/views/"}, 'description': 'Please use access_stream_by_*() to fetch Stream objects', }, {'pattern': 'get_stream[(]', - 'include_only': set(["zerver/views/", "zerver/lib/actions.py"]), - 'exclude_line': set([ + 'include_only': {"zerver/views/", "zerver/lib/actions.py"}, + 'exclude_line': { # This one in check_message is kinda terrible, since it's # how most instances are written, but better to exclude something than nothing ('zerver/lib/actions.py', 'stream = get_stream(stream_name, realm)'), ('zerver/lib/actions.py', 'return get_stream("signups", realm)'), - ]), + }, 'description': 'Please use access_stream_by_*() to fetch Stream objects', }, {'pattern': 'Stream.objects.filter', - 'include_only': set(["zerver/views/"]), + 'include_only': {"zerver/views/"}, 'description': 'Please use access_stream_by_*() to fetch Stream objects', }, {'pattern': '^from (zerver|analytics|confirmation)', - 'include_only': set(["/migrations/"]), - 'exclude': set([ + 'include_only': {"/migrations/"}, + 'exclude': { 'zerver/migrations/0032_verify_all_medium_avatar_images.py', 'zerver/migrations/0060_move_avatars_to_be_uid_based.py', 'zerver/migrations/0104_fix_unreads.py', @@ -407,11 +400,11 @@ python_rules = RuleList( 'zerver/migrations/0209_user_profile_no_empty_password.py', 'zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py', 'pgroonga/migrations/0002_html_escape_subject.py', - ]), + }, 'description': "Don't import models or other code in migrations; see docs/subsystems/schema-migrations.md", }, {'pattern': 'datetime[.](now|utcnow)', - 'include_only': set(["zerver/", "analytics/"]), + 'include_only': {"zerver/", "analytics/"}, 'description': "Don't use datetime in backend code.\n" "See https://zulip.readthedocs.io/en/latest/contributing/code-style.html#naive-datetime-objects", }, @@ -431,7 +424,7 @@ python_rules = RuleList( 'good_lines': ['if my_django_model.id == 42', 'self.user_profile._meta.pk'], 'bad_lines': ['if my_django_model.pk == 42']}, {'pattern': r'^[ ]*# type: \(', - 'exclude': set([ + 'exclude': { # These directories, especially scripts/ and puppet/, # have tools that need to run before a Zulip environment # is provisioned; in some of those, the `typing` module @@ -446,7 +439,7 @@ python_rules = RuleList( 'zerver/views/streams.py', # thumbor is (currently) python2 only 'zthumbor/', - ]), + }, 'description': 'Comment-style function type annotation. Use Python3 style annotations instead.', }, {'pattern': r' = models[.].*null=True.*\) # type: (?!Optional)', @@ -471,7 +464,7 @@ python_rules = RuleList( 'stream = models.ForeignKey(Stream, on_delete=CASCADE) # type: Optional[Stream]'], }, {'pattern': r'[\s([]Text([^\s\w]|$)', - 'exclude': set([ + 'exclude': { # We are likely to want to keep these dirs Python 2+3 compatible, # since the plan includes extracting them to a separate project eventually. 'tools/lib', @@ -479,26 +472,26 @@ python_rules = RuleList( 'zerver/migrations/', # thumbor is (currently) python2 only 'zthumbor/', - ]), + }, 'description': "Now that we're a Python 3 only codebase, we don't need to use typing.Text. Please use str instead.", }, {'pattern': 'exit[(]1[)]', - 'include_only': set(["/management/commands/"]), + 'include_only': {"/management/commands/"}, 'description': 'Raise CommandError to exit with failure in management commands', }, {'pattern': '.is_realm_admin =', 'description': 'Use do_change_is_admin function rather than setting UserProfile\'s is_realm_admin attribute directly.', - 'exclude': set([ + 'exclude': { 'zerver/migrations/0248_userprofile_role_start.py', 'zerver/tests/test_users.py', - ]), + }, }, {'pattern': '.is_guest =', 'description': 'Use do_change_is_guest function rather than setting UserProfile\'s is_guest attribute directly.', - 'exclude': set([ + 'exclude': { 'zerver/migrations/0248_userprofile_role_start.py', 'zerver/tests/test_users.py', - ]), + }, }, *whitespace_rules, *comma_whitespace_rule, @@ -515,11 +508,11 @@ bash_rules = RuleList( ' to set -x|set -e'}, {'pattern': 'sudo', 'description': 'Most scripts are intended to work on systems without sudo', - 'include_only': set(['scripts/']), - 'exclude': set([ + 'include_only': {'scripts/'}, + 'exclude': { 'scripts/lib/install', 'scripts/setup/configure-rabbitmq' - ]), }, + }, }, *whitespace_rules[0:1], ], shebang_rules=shebang_rules, @@ -576,7 +569,7 @@ css_rules = RuleList( prose_style_rules = [ {'pattern': r'[^\/\#\-"]([jJ]avascript)', # exclude usage in hrefs/divs - 'exclude': set(["docs/documentation/api.md"]), + 'exclude': {"docs/documentation/api.md"}, 'description': "javascript should be spelled JavaScript"}, {'pattern': r'''[^\/\-\."'\_\=\>]([gG]ithub)[^\.\-\_"\<]''', # exclude usage in hrefs/divs 'description': "github should be spelled GitHub"}, @@ -593,7 +586,7 @@ prose_style_rules = [ ] # type: List[Rule] html_rules = whitespace_rules + prose_style_rules + [ {'pattern': 'subject|SUBJECT', - 'exclude': set(['templates/zerver/email.html']), + 'exclude': {'templates/zerver/email.html'}, 'exclude_pattern': 'email subject', 'description': 'avoid subject in templates', 'good_lines': ['topic_name'], @@ -602,7 +595,7 @@ html_rules = whitespace_rules + prose_style_rules + [ 'description': "`placeholder` value should be translatable.", 'exclude_line': {('templates/zerver/register.html', 'placeholder="acme"'), ('templates/zerver/register.html', 'placeholder="Acme or Ακμή"')}, - 'exclude': set(["templates/analytics/support.html"]), + 'exclude': {"templates/analytics/support.html"}, 'good_lines': [''], 'bad_lines': ['']}, {'pattern': "placeholder='[^{]", @@ -619,8 +612,8 @@ html_rules = whitespace_rules + prose_style_rules + [ 'bad_lines': ['']}, {'pattern': 'script src="http', 'description': "Don't directly load dependencies from CDNs. See docs/subsystems/html-css.md", - 'exclude': set(["templates/corporate/billing.html", "templates/zerver/hello.html", - "templates/corporate/upgrade.html"]), + 'exclude': {"templates/corporate/billing.html", "templates/zerver/hello.html", + "templates/corporate/upgrade.html"}, 'good_lines': ["{{ render_entrypoint('landing-page') }}"], 'bad_lines': ['']}, {'pattern': "title='[^{]", @@ -628,17 +621,17 @@ html_rules = whitespace_rules + prose_style_rules + [ 'good_lines': [''], 'bad_lines': ["

"]}, {'pattern': r'title="[^{\:]', - 'exclude_line': set([ + 'exclude_line': { ('templates/zerver/app/markdown_help.html', ':heart:') - ]), - 'exclude': set(["templates/zerver/emails", "templates/analytics/realm_details.html", "templates/analytics/support.html"]), + }, + 'exclude': {"templates/zerver/emails", "templates/analytics/realm_details.html", "templates/analytics/support.html"}, 'description': "`title` value should be translatable."}, {'pattern': r'''\Walt=["'][^{"']''', 'description': "alt argument should be enclosed by _() or it should be an empty string.", - 'exclude': set(['static/templates/settings/display_settings.hbs', - 'templates/zerver/app/keyboard_shortcuts.html', - 'templates/zerver/app/markdown_help.html']), + 'exclude': {'static/templates/settings/display_settings.hbs', + 'templates/zerver/app/keyboard_shortcuts.html', + 'templates/zerver/app/markdown_help.html'}, 'good_lines': ['{{ _(name) }}', ''], 'bad_lines': ['Foo Image']}, {'pattern': r'''\Walt=["']{{ ?["']''', @@ -649,13 +642,13 @@ html_rules = whitespace_rules + prose_style_rules + [ 'description': "Don't use inline event handlers (onclick=, etc. attributes) in HTML. Instead," "attach a jQuery event handler ($('#foo').on('click', function () {...})) when " "the DOM is ready (inside a $(function () {...}) block).", - 'exclude': set(['templates/zerver/dev_login.html', 'templates/corporate/upgrade.html']), + 'exclude': {'templates/zerver/dev_login.html', 'templates/corporate/upgrade.html'}, 'good_lines': ["($('#foo').on('click', function () {}"], 'bad_lines': ["", ""]}, {'pattern': 'style ?=', 'description': "Avoid using the `style=` attribute; we prefer styling in CSS files", 'exclude_pattern': r'.*style ?=["' + "'" + '](display: ?none|background: {{|color: {{|background-color: {{).*', - 'exclude': set([ + 'exclude': { # KaTeX output uses style attribute 'templates/zerver/app/markdown_help.html', # 5xx page doesn't have external CSS @@ -714,7 +707,7 @@ html_rules = whitespace_rules + prose_style_rules + [ 'templates/analytics/realm_summary_table.html', 'templates/corporate/zephyr.html', 'templates/corporate/zephyr-mirror.html', - ]), + }, 'good_lines': ['#my-style {color: blue;}', 'style="display: none"', "style='display: none"], 'bad_lines': ['

Foo

', 'style = "color: blue;"']}, ] # type: List[Rule] @@ -764,10 +757,10 @@ json_rules = RuleList( trailing_whitespace_rule, {'pattern': '\t', 'strip': '\n', - 'exclude': set(['zerver/webhooks/']), + 'exclude': {'zerver/webhooks/'}, 'description': 'Fix tab-based whitespace'}, {'pattern': r'":["\[\{]', - 'exclude': set(['zerver/webhooks/', 'zerver/tests/fixtures/']), + 'exclude': {'zerver/webhooks/', 'zerver/tests/fixtures/'}, 'description': 'Require space after : in JSON'}, ] ) @@ -801,15 +794,15 @@ markdown_rules = RuleList( 'description': 'Linkified markdown URLs should use cleaner syntax.'}, {'pattern': 'https://zulip.readthedocs.io/en/latest/[a-zA-Z0-9]', 'exclude': {'docs/overview/contributing.md', 'docs/overview/readme.md', 'docs/README.md'}, - 'include_only': set(['docs/']), + 'include_only': {'docs/'}, 'description': "Use relative links (../foo/bar.html) to other documents in docs/", }, {'pattern': "su zulip -c [^']", - 'include_only': set(['docs/']), + 'include_only': {'docs/'}, 'description': "Always quote arguments using `su zulip -c '` to avoid confusion about how su works.", }, {'pattern': r'\][(][^#h]', - 'include_only': set(['README.md', 'CONTRIBUTING.md']), + 'include_only': {'README.md', 'CONTRIBUTING.md'}, 'description': "Use absolute links from docs served by GitHub", }, ], @@ -823,10 +816,10 @@ help_markdown_rules = RuleList( rules=markdown_rules.rules + [ {'pattern': '[a-z][.][A-Z]', 'description': "Likely missing space after end of sentence", - 'include_only': set(['templates/zerver/help/']), + 'include_only': {'templates/zerver/help/'}, }, {'pattern': r'\b[rR]ealm[s]?\b', - 'include_only': set(['templates/zerver/help/']), + 'include_only': {'templates/zerver/help/'}, 'good_lines': ['Organization', 'deactivate_realm', 'realm_filter'], 'bad_lines': ['Users are in a realm', 'Realm is the best model'], 'description': "Realms are referred to as Organizations in user-facing docs."}, diff --git a/tools/linter_lib/pep8.py b/tools/linter_lib/pep8.py index c7daa2bb99..01d0a72ef6 100644 --- a/tools/linter_lib/pep8.py +++ b/tools/linter_lib/pep8.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import - from zulint.linters import run_pycodestyle from typing import List diff --git a/tools/linter_lib/pyflakes.py b/tools/linter_lib/pyflakes.py index 40a8499e20..def8a874be 100644 --- a/tools/linter_lib/pyflakes.py +++ b/tools/linter_lib/pyflakes.py @@ -1,6 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import - import argparse from typing import List diff --git a/tools/pretty-print-html b/tools/pretty-print-html index 2d104e701e..629267c175 100755 --- a/tools/pretty-print-html +++ b/tools/pretty-print-html @@ -7,7 +7,7 @@ def clean_html(filenames): # type: (List[str]) -> None for fn in filenames: print('Prettifying: %s' % (fn,)) - with open(fn, 'r') as f: + with open(fn) as f: html = f.read() phtml = pretty_print_html(html) with open(fn, 'w') as f: diff --git a/tools/stop-run-dev b/tools/stop-run-dev index d218045df6..156a933cc8 100755 --- a/tools/stop-run-dev +++ b/tools/stop-run-dev @@ -8,7 +8,7 @@ os.chdir(os.path.join(os.path.dirname(__file__), '..')) pid_file_path = os.path.join(os.path.join(os.getcwd(), 'var/run/run_dev.pid')) try: - with open(pid_file_path, 'r') as pid_file: + with open(pid_file_path) as pid_file: try: pid = int(pid_file.read()) except ValueError: diff --git a/tools/test-backend b/tools/test-backend index e9bf749d87..83a1fb73a9 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -143,9 +143,9 @@ FAILED_TEST_PATH = 'var/last_test_failure.json' def get_failed_tests() -> List[str]: try: - with open(FAILED_TEST_PATH, 'r') as f: + with open(FAILED_TEST_PATH) as f: return ujson.load(f) - except IOError: + except OSError: print("var/last_test_failure.json doesn't exist; running all tests.") return [] diff --git a/tools/test-js-with-node b/tools/test-js-with-node index c741dfd25b..ac49d6a38d 100755 --- a/tools/test-js-with-node +++ b/tools/test-js-with-node @@ -244,9 +244,9 @@ def check_line_coverage(fn, line_coverage, line_mapping, log=True): def read_coverage() -> Any: coverage_json = None try: - with open(NODE_COVERAGE_PATH, 'r') as f: + with open(NODE_COVERAGE_PATH) as f: coverage_json = ujson.load(f) - except IOError: + except OSError: print(NODE_COVERAGE_PATH + " doesn't exist. Cannot enforce fully covered files.") raise return coverage_json diff --git a/tools/update-zuliprc-api-field b/tools/update-zuliprc-api-field index 6f7349725d..b75630bc5a 100755 --- a/tools/update-zuliprc-api-field +++ b/tools/update-zuliprc-api-field @@ -28,7 +28,7 @@ for zuliprc_path in zuliprc_paths_list: zuliprc = configparser.ConfigParser() result = '' try: - with open(zuliprc_path, 'r') as f: + with open(zuliprc_path) as f: zuliprc.read_file(f, zuliprc_path) api_details = zuliprc['api'] email = api_details['email'] @@ -66,7 +66,7 @@ for zuliprc_path in zuliprc_paths_list: zuliprc.write(w) result = 'SUCCESS' reason = 'API field updated for user %s' % (email,) - except (IOError, OSError): + except OSError: result = 'FAILURE' reason = 'Writing to file unsuccessful' else: diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export index 7cf49ee13e..d83b6b592f 100755 --- a/tools/zulip-export/zulip-export +++ b/tools/zulip-export/zulip-export @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- # Copyright © 2014 Dropbox, Inc. # diff --git a/zerver/data_import/gitter.py b/zerver/data_import/gitter.py index bf7e3c3cf6..c31eead604 100644 --- a/zerver/data_import/gitter.py +++ b/zerver/data_import/gitter.py @@ -238,7 +238,7 @@ def do_convert_data(gitter_data_file: str, output_dir: str, threads: int=6) -> N raise Exception("Output directory should be empty!") # Read data from the gitter file - with open(gitter_data_file, "r") as fp: + with open(gitter_data_file) as fp: gitter_data = ujson.load(fp) realm, avatar_list, user_map = gitter_workspace_to_realm( diff --git a/zerver/data_import/hipchat.py b/zerver/data_import/hipchat.py index fd7f9ac2c8..ff46e1cca1 100755 --- a/zerver/data_import/hipchat.py +++ b/zerver/data_import/hipchat.py @@ -84,7 +84,7 @@ def untar_input_file(tar_file: str) -> str: def read_user_data(data_dir: str) -> List[ZerverFieldsT]: fn = 'users.json' data_file = os.path.join(data_dir, fn) - with open(data_file, "r") as fp: + with open(data_file) as fp: return ujson.load(fp) def convert_user_data(user_handler: UserHandler, @@ -257,7 +257,7 @@ def convert_room_data(raw_data: List[ZerverFieldsT], users = set() if api_token is not None: hc = hypchat.HypChat(api_token) - room_data = hc.fromurl('{0}/v2/room/{1}/member'.format(hc.endpoint, in_dict['id'])) + room_data = hc.fromurl('{}/v2/room/{}/member'.format(hc.endpoint, in_dict['id'])) for item in room_data['items']: hipchat_user_id = item['id'] diff --git a/zerver/data_import/mattermost.py b/zerver/data_import/mattermost.py index e7b1142126..ab2851e760 100644 --- a/zerver/data_import/mattermost.py +++ b/zerver/data_import/mattermost.py @@ -681,7 +681,7 @@ def mattermost_data_file_to_dict(mattermost_data_file: str) -> Dict[str, Any]: mattermost_data["emoji"] = [] mattermost_data["direct_channel"] = [] - with open(mattermost_data_file, "r") as fp: + with open(mattermost_data_file) as fp: for line in fp: row = ujson.loads(line.rstrip("\n")) data_type = row["type"] diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.py index 6cf6eb7208..ddd1b34304 100755 --- a/zerver/data_import/slack.py +++ b/zerver/data_import/slack.py @@ -205,7 +205,7 @@ def users_to_zerver_userprofile(slack_data_dir: str, users: List[ZerverFieldsT], if not user.get('is_primary_owner', False): user_id_count += 1 - logging.info(u"{} -> {}".format(user['name'], userprofile_dict['email'])) + logging.info("{} -> {}".format(user['name'], userprofile_dict['email'])) process_customprofilefields(zerver_customprofilefield, zerver_customprofilefield_values) logging.info('######### IMPORTING USERS FINISHED #########\n') @@ -397,7 +397,7 @@ def channels_to_zerver_stream(slack_data_dir: str, realm_id: int, stream_id_count += 1 recipient_id_count += 1 - logging.info(u"{} -> created".format(channel['name'])) + logging.info("{} -> created".format(channel['name'])) # TODO map Slack's pins to Zulip's stars # There is the security model that Slack's pins are known to the team owner @@ -443,7 +443,7 @@ def channels_to_zerver_stream(slack_data_dir: str, realm_id: int, huddle_id_count += 1 recipient_id_count += 1 - logging.info(u"{} -> created".format(mpim['name'])) + logging.info("{} -> created".format(mpim['name'])) try: mpims = get_data_file(slack_data_dir + '/mpims.json') @@ -649,8 +649,7 @@ def get_messages_iterator(slack_data_dir: str, added_channels: Dict[str, Any], # we sort the messages according to the timestamp to show messages with # the proper date order - for message in sorted(messages_for_one_day, key=lambda m: m['ts']): - yield message + yield from sorted(messages_for_one_day, key=lambda m: m['ts']) def channel_message_to_zerver_message(realm_id: int, users: List[ZerverFieldsT], @@ -1095,7 +1094,7 @@ def do_convert_data(slack_zip_file: str, output_dir: str, token: str, threads: i logging.info("Zulip data dump created at %s" % (output_dir,)) def get_data_file(path: str) -> Any: - with open(path, "r") as fp: + with open(path) as fp: data = ujson.load(fp) return data diff --git a/zerver/forms.py b/zerver/forms.py index 048c3ea1b2..d351cb9144 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -37,16 +37,16 @@ from typing import Any, List, Optional, Dict, Tuple from two_factor.forms import AuthenticationTokenForm as TwoFactorAuthenticationTokenForm from two_factor.utils import totp_digits -MIT_VALIDATION_ERROR = u'That user does not exist at MIT or is a ' + \ - u'mailing list. ' + \ - u'If you want to sign up an alias for Zulip, ' + \ - u'contact us.' +MIT_VALIDATION_ERROR = 'That user does not exist at MIT or is a ' + \ + 'mailing list. ' + \ + 'If you want to sign up an alias for Zulip, ' + \ + 'contact us.' WRONG_SUBDOMAIN_ERROR = "Your Zulip account is not a member of the " + \ "organization associated with this subdomain. " + \ "Please contact your organization administrator with any questions." -DEACTIVATED_ACCOUNT_ERROR = u"Your account is no longer active. " + \ - u"Please contact your organization administrator to reactivate it." -PASSWORD_TOO_WEAK_ERROR = u"The password is too weak." +DEACTIVATED_ACCOUNT_ERROR = "Your account is no longer active. " + \ + "Please contact your organization administrator to reactivate it." +PASSWORD_TOO_WEAK_ERROR = "The password is too weak." AUTHENTICATION_RATE_LIMITED_ERROR = "You're making too many attempts to sign in. " + \ "Try again in %s seconds or contact your organization administrator " + \ "for help." diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index fd9aeb02df..01caa9bb87 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -1158,11 +1158,11 @@ def get_recipient_info(recipient: Recipient, # direct recipient or were mentioned; for now, we're just making # sure we have the data we need for that without extra database # queries. - default_bot_user_ids = set([ + default_bot_user_ids = { row['id'] for row in rows if row['is_bot'] and row['bot_type'] == UserProfile.DEFAULT_BOT - ]) + } service_bot_tuples = [ (row['id'], row['bot_type']) @@ -1946,7 +1946,7 @@ def get_recipient_from_user_profiles(recipient_profiles: Sequence[UserProfile], # Otherwise, we need a huddle. Make sure the sender is included in huddle messages recipient_profiles_map[sender.id] = sender - user_ids = set([user_id for user_id in recipient_profiles_map]) # type: Set[int] + user_ids = {user_id for user_id in recipient_profiles_map} # type: Set[int] return get_huddle_recipient(user_ids) def validate_recipient_user_profiles(user_profiles: Sequence[UserProfile], @@ -2680,7 +2680,7 @@ def bulk_get_subscriber_user_ids(stream_dicts: Iterable[Mapping[str, Any]], for stream_id in stream_ids ]) - result = dict((stream["id"], []) for stream in stream_dicts) # type: Dict[int, List[int]] + result = {stream["id"]: [] for stream in stream_dicts} # type: Dict[int, List[int]] if not recipient_ids: return result @@ -2857,7 +2857,7 @@ def bulk_add_subscriptions(streams: Iterable[Stream], acting_user: Optional[UserProfile]=None) -> SubT: users = list(users) - recipients_map = dict((stream.id, stream.recipient_id) for stream in streams) # type: Dict[int, int] + recipients_map = {stream.id: stream.recipient_id for stream in streams} # type: Dict[int, int] recipient_ids = [recipient_id for recipient_id in recipients_map.values()] # type: List[int] stream_map = {} # type: Dict[int, Stream] @@ -4877,7 +4877,7 @@ def gather_subscriptions_helper(user_profile: UserProfile, # Deactivated streams aren't in stream_hash. streams = [stream_hash[sub["stream_id"]] for sub in sub_dicts if sub["stream_id"] in stream_hash] - streams_subscribed_map = dict((sub["stream_id"], sub["active"]) for sub in sub_dicts) + streams_subscribed_map = {sub["stream_id"]: sub["active"] for sub in sub_dicts} # Add never subscribed streams to streams_subscribed_map streams_subscribed_map.update({stream['id']: False for stream in all_streams if stream not in streams}) @@ -5577,7 +5577,7 @@ def check_attachment_reference_change(message: Message) -> bool: # For a unsaved message edit (message.* has been updated, but not # saved to the database), adjusts Attachment data to correspond to # the new content. - prev_attachments = set([a.path_id for a in message.attachment_set.all()]) + prev_attachments = {a.path_id for a in message.attachment_set.all()} new_attachments = set(message.potential_attachment_path_ids) if new_attachments == prev_attachments: @@ -5652,7 +5652,7 @@ def try_update_realm_custom_profile_field(realm: Realm, field: CustomProfileFiel notify_realm_custom_profile_fields(realm, 'update') def try_reorder_realm_custom_profile_fields(realm: Realm, order: List[int]) -> None: - order_mapping = dict((_[1], _[0]) for _ in enumerate(order)) + order_mapping = {_[1]: _[0] for _ in enumerate(order)} fields = CustomProfileField.objects.filter(realm=realm) for field in fields: if field.id not in order_mapping: diff --git a/zerver/lib/alert_words.py b/zerver/lib/alert_words.py index db5c8090b2..948aac1d7a 100644 --- a/zerver/lib/alert_words.py +++ b/zerver/lib/alert_words.py @@ -10,8 +10,8 @@ from typing import Dict, Iterable, List def alert_words_in_realm(realm: Realm) -> Dict[int, List[str]]: users_query = UserProfile.objects.filter(realm=realm, is_active=True) alert_word_data = users_query.filter(~Q(alert_words=ujson.dumps([]))).values('id', 'alert_words') - all_user_words = dict((elt['id'], ujson.loads(elt['alert_words'])) for elt in alert_word_data) - user_ids_with_words = dict((user_id, w) for (user_id, w) in all_user_words.items() if len(w)) + all_user_words = {elt['id']: ujson.loads(elt['alert_words']) for elt in alert_word_data} + user_ids_with_words = {user_id: w for (user_id, w) in all_user_words.items() if len(w)} return user_ids_with_words @cache_with_key(realm_alert_words_automaton_cache_key, timeout=3600*24) @@ -25,7 +25,7 @@ def get_alert_word_automaton(realm: Realm) -> ahocorasick.Automaton: (key, user_ids_for_alert_word) = alert_word_automaton.get(alert_word_lower) user_ids_for_alert_word.add(user_id) else: - alert_word_automaton.add_word(alert_word_lower, (alert_word_lower, set([user_id]))) + alert_word_automaton.add_word(alert_word_lower, (alert_word_lower, {user_id})) alert_word_automaton.make_automaton() # If the kind is not AHOCORASICK after calling make_automaton, it means there is no key present # and hence we cannot call items on the automaton yet. To avoid it we return None for such cases diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 9e732caa34..d370c5a528 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -263,7 +263,7 @@ def list_of_tlds() -> List[str]: # tlds-alpha-by-domain.txt comes from https://data.iana.org/TLD/tlds-alpha-by-domain.txt tlds_file = os.path.join(os.path.dirname(__file__), 'tlds-alpha-by-domain.txt') - tlds = [tld.lower().strip() for tld in open(tlds_file, 'r') + tlds = [tld.lower().strip() for tld in open(tlds_file) if tld not in blacklist and not tld[0].startswith('#')] tlds.sort(key=len, reverse=True) return tlds @@ -563,10 +563,10 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor): # We strip leading '/' from relative URLs here to ensure # consistency in what gets passed to /thumbnail url = url.lstrip('/') - img.set("src", "/thumbnail?url={0}&size=thumbnail".format( + img.set("src", "/thumbnail?url={}&size=thumbnail".format( urllib.parse.quote(url, safe='') )) - img.set('data-src-fullsize', "/thumbnail?url={0}&size=full".format( + img.set('data-src-fullsize', "/thumbnail?url={}&size=full".format( urllib.parse.quote(url, safe='') )) else: @@ -1187,7 +1187,7 @@ class Avatar(markdown.inlinepatterns.Pattern): profile_id = user_dict['id'] img.set('class', 'message_body_gravatar') - img.set('src', '/avatar/{0}?s=30'.format(profile_id or email)) + img.set('src', '/avatar/{}?s=30'.format(profile_id or email)) img.set('title', email) img.set('alt', email) return img @@ -1713,9 +1713,9 @@ def possible_linked_stream_names(content: str) -> Set[str]: class AlertWordsNotificationProcessor(markdown.preprocessors.Preprocessor): - allowed_before_punctuation = set([' ', '\n', '(', '"', '.', ',', '\'', ';', '[', '*', '`', '>']) - allowed_after_punctuation = set([' ', '\n', ')', '",', '?', ':', '.', ',', '\'', ';', ']', '!', - '*', '`']) + allowed_before_punctuation = {' ', '\n', '(', '"', '.', ',', '\'', ';', '[', '*', '`', '>'} + allowed_after_punctuation = {' ', '\n', ')', '",', '?', ':', '.', ',', '\'', ';', ']', '!', + '*', '`'} def check_valid_start_position(self, content: str, index: int) -> bool: if index <= 0 or content[index] in self.allowed_before_punctuation: diff --git a/zerver/lib/bugdown/api_arguments_table_generator.py b/zerver/lib/bugdown/api_arguments_table_generator.py index 394df36c6e..9ff95af0b5 100644 --- a/zerver/lib/bugdown/api_arguments_table_generator.py +++ b/zerver/lib/bugdown/api_arguments_table_generator.py @@ -30,7 +30,7 @@ class MarkdownArgumentsTableGenerator(Extension): class APIArgumentsTablePreprocessor(Preprocessor): def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None: - super(APIArgumentsTablePreprocessor, self).__init__(md) + super().__init__(md) self.base_path = config['base_path'] def run(self, lines: List[str]) -> List[str]: @@ -66,7 +66,7 @@ class APIArgumentsTablePreprocessor(Preprocessor): if e.args != ('parameters',): raise e else: - with open(filename, 'r') as fp: + with open(filename) as fp: json_obj = json.load(fp) arguments = json_obj[doc_name] diff --git a/zerver/lib/bugdown/api_code_examples.py b/zerver/lib/bugdown/api_code_examples.py index fb59d21d26..75cb164ffe 100644 --- a/zerver/lib/bugdown/api_code_examples.py +++ b/zerver/lib/bugdown/api_code_examples.py @@ -278,7 +278,7 @@ class APICodeExamplesGenerator(Extension): class APICodeExamplesPreprocessor(Preprocessor): def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None: - super(APICodeExamplesPreprocessor, self).__init__(md) + super().__init__(md) self.api_url = config['api_url'] def run(self, lines: List[str]) -> List[str]: diff --git a/zerver/lib/bugdown/include.py b/zerver/lib/bugdown/include.py index bd3a557bea..a8077391b9 100644 --- a/zerver/lib/bugdown/include.py +++ b/zerver/lib/bugdown/include.py @@ -1,4 +1,3 @@ -from __future__ import print_function import re import os from typing import Any, Dict, List @@ -42,7 +41,7 @@ class IncludeCustomPreprocessor(IncludePreprocessor): os.path.join(self.base_path, filename) ) try: - with open(filename, 'r', encoding=self.encoding) as r: + with open(filename, encoding=self.encoding) as r: text = r.readlines() except Exception as e: print('Warning: could not find file {}. Error: {}'.format(filename, e)) diff --git a/zerver/lib/bugdown/nested_code_blocks.py b/zerver/lib/bugdown/nested_code_blocks.py index 72716a42d6..8641499256 100644 --- a/zerver/lib/bugdown/nested_code_blocks.py +++ b/zerver/lib/bugdown/nested_code_blocks.py @@ -15,7 +15,7 @@ class NestedCodeBlocksRenderer(Extension): class NestedCodeBlocksRendererTreeProcessor(markdown.treeprocessors.Treeprocessor): def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None: - super(NestedCodeBlocksRendererTreeProcessor, self).__init__(md) + super().__init__(md) def run(self, root: Element) -> None: code_tags = walk_tree_with_family(root, self.get_code_tags) diff --git a/zerver/lib/bugdown/tabbed_sections.py b/zerver/lib/bugdown/tabbed_sections.py index eba584fbfc..fbf2efdf79 100644 --- a/zerver/lib/bugdown/tabbed_sections.py +++ b/zerver/lib/bugdown/tabbed_sections.py @@ -84,7 +84,7 @@ class TabbedSectionsGenerator(Extension): class TabbedSectionsPreprocessor(Preprocessor): def __init__(self, md: markdown.Markdown, config: Dict[str, Any]) -> None: - super(TabbedSectionsPreprocessor, self).__init__(md) + super().__init__(md) def run(self, lines: List[str]) -> List[str]: tab_section = self.parse_tabs(lines) diff --git a/zerver/lib/bugdown/testing_mocks.py b/zerver/lib/bugdown/testing_mocks.py index 8958f2043f..f47e9dd57a 100644 --- a/zerver/lib/bugdown/testing_mocks.py +++ b/zerver/lib/bugdown/testing_mocks.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Any, Dict, Optional import ujson diff --git a/zerver/lib/bulk_create.py b/zerver/lib/bulk_create.py index 757e3229f3..cb29292dcb 100644 --- a/zerver/lib/bulk_create.py +++ b/zerver/lib/bulk_create.py @@ -88,7 +88,7 @@ def bulk_set_users_or_streams_recipient_fields(model: Model, object_ids = [obj.id for obj in objects] recipients = Recipient.objects.filter(type=recipient_type, type_id__in=object_ids) - objects_dict = dict((obj.id, obj) for obj in objects) + objects_dict = {obj.id: obj for obj in objects} for recipient in recipients: assert recipient.type == recipient_type diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index c97e3ce3ac..6bb0abb7e8 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -87,7 +87,7 @@ def get_or_create_key_prefix() -> str: # The file already exists tries = 1 while tries < 10: - with open(filename, 'r') as f: + with open(filename) as f: prefix = f.readline()[:-1] if len(prefix) == 33: break @@ -244,7 +244,7 @@ def cache_get_many(keys: List[str], cache_name: Optional[str]=None) -> Dict[str, remote_cache_stats_start() ret = get_cache_backend(cache_name).get_many(keys) remote_cache_stats_finish() - return dict([(key[len(KEY_PREFIX):], value) for key, value in ret.items()]) + return {key[len(KEY_PREFIX):]: value for key, value in ret.items()} def safe_cache_get_many(keys: List[str], cache_name: Optional[str]=None) -> Dict[str, Any]: """Variant of cache_get_many that drops any keys that fail @@ -290,7 +290,7 @@ def safe_cache_set_many(items: Dict[str, Any], cache_name: Optional[str]=None, good_keys, bad_keys = filter_good_and_bad_keys(list(items.keys())) log_invalid_cache_keys(stack_trace, bad_keys) - good_items = dict((key, items[key]) for key in good_keys) + good_items = {key: items[key] for key in good_keys} return cache_set_many(good_items, cache_name, timeout) def cache_delete(key: str, cache_name: Optional[str]=None) -> None: @@ -404,8 +404,8 @@ def generic_bulk_cached_fetch( cached_objects[key] = item if len(items_for_remote_cache) > 0: safe_cache_set_many(items_for_remote_cache) - return dict((object_id, cached_objects[cache_keys[object_id]]) for object_id in object_ids - if cache_keys[object_id] in cached_objects) + return {object_id: cached_objects[cache_keys[object_id]] for object_id in object_ids + if cache_keys[object_id] in cached_objects} def preview_url_cache_key(url: str) -> str: return "preview_url:%s" % (make_safe_digest(url),) @@ -425,7 +425,7 @@ def user_profile_by_email_cache_key(email: str) -> str: return 'user_profile_by_email:%s' % (make_safe_digest(email.strip()),) def user_profile_cache_key_id(email: str, realm_id: int) -> str: - return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm_id,) + return "user_profile:%s:%s" % (make_safe_digest(email.strip()), realm_id,) def user_profile_cache_key(email: str, realm: 'Realm') -> str: return user_profile_cache_key_id(email, realm.id) @@ -451,7 +451,7 @@ def realm_user_dicts_cache_key(realm_id: int) -> str: return "realm_user_dicts:%s" % (realm_id,) def get_realm_used_upload_space_cache_key(realm: 'Realm') -> str: - return u'realm_used_upload_space:%s' % (realm.id,) + return 'realm_used_upload_space:%s' % (realm.id,) def active_user_ids_cache_key(realm_id: int) -> str: return "active_user_ids:%s" % (realm_id,) diff --git a/zerver/lib/display_recipient.py b/zerver/lib/display_recipient.py index ee5973062c..0c968d1164 100644 --- a/zerver/lib/display_recipient.py +++ b/zerver/lib/display_recipient.py @@ -74,9 +74,9 @@ def bulk_fetch_display_recipients(recipient_tuples: Set[Tuple[int, int, int]] for recipient in recipient_tuples } - stream_recipients = set( + stream_recipients = { recipient for recipient in recipient_tuples if recipient[1] == Recipient.STREAM - ) + } personal_and_huddle_recipients = recipient_tuples - stream_recipients def stream_query_function(recipient_ids: List[int]) -> List[TinyStreamResult]: diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py index 65a67d492a..5e32b2d880 100644 --- a/zerver/lib/email_notifications.py +++ b/zerver/lib/email_notifications.py @@ -309,7 +309,7 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, if not user_profile.enable_offline_email_notifications: return - recipients = set((msg['message'].recipient_id, msg['message'].topic_name()) for msg in missed_messages) + recipients = {(msg['message'].recipient_id, msg['message'].topic_name()) for msg in missed_messages} if len(recipients) != 1: raise ValueError( 'All missed_messages must have the same recipient and topic %r' % @@ -359,7 +359,7 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, 'narrow_url': narrow_url, }) - senders = list(set(m['message'].sender for m in missed_messages)) + senders = list({m['message'].sender for m in missed_messages}) if (missed_messages[0]['message'].recipient.type == Recipient.HUDDLE): display_recipient = get_display_recipient(missed_messages[0]['message'].recipient) # Make sure that this is a list of strings, not a string. @@ -383,9 +383,9 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, elif (context['mention'] or context['stream_email_notify']): # Keep only the senders who actually mentioned the user if context['mention']: - senders = list(set(m['message'].sender for m in missed_messages - if m['trigger'] == 'mentioned' or - m['trigger'] == 'wildcard_mentioned')) + senders = list({m['message'].sender for m in missed_messages + if m['trigger'] == 'mentioned' or + m['trigger'] == 'wildcard_mentioned'}) message = missed_messages[0]['message'] stream = Stream.objects.only('id', 'name').get(id=message.recipient.type_id) stream_header = "%s > %s" % (stream.name, message.topic_name()) diff --git a/zerver/lib/emoji.py b/zerver/lib/emoji.py index 2967f83dbb..cac302e065 100644 --- a/zerver/lib/emoji.py +++ b/zerver/lib/emoji.py @@ -21,9 +21,9 @@ EMOTICON_CONVERSIONS = emoji_codes["emoticon_conversions"] possible_emoticons = EMOTICON_CONVERSIONS.keys() possible_emoticon_regexes = (re.escape(emoticon) for emoticon in possible_emoticons) terminal_symbols = ',.;?!()\\[\\] "\'\\n\\t' # from composebox_typeahead.js -emoticon_regex = ('(?('.format(terminal_symbols) +emoticon_regex = ('(?('.format(terminal_symbols) + ')|('.join(possible_emoticon_regexes) - + '))(?![^{0}])'.format(terminal_symbols)) + + '))(?![^{}])'.format(terminal_symbols)) # Translates emoticons to their colon syntax, e.g. `:smiley:`. def translate_emoticons(text: str) -> str: diff --git a/zerver/lib/export.py b/zerver/lib/export.py index 0bd1879b60..28d8363385 100644 --- a/zerver/lib/export.py +++ b/zerver/lib/export.py @@ -274,7 +274,7 @@ def sanity_check_output(data: TableData) -> None: list(apps.get_app_config('two_factor').get_models(include_auto_created=True)) + list(apps.get_app_config('zerver').get_models(include_auto_created=True)) ) - all_tables_db = set(model._meta.db_table for model in target_models) + all_tables_db = {model._meta.db_table for model in target_models} # These assertion statements will fire when we add a new database # table that is not included in Zulip's data exports. Generally, @@ -783,9 +783,9 @@ def sanity_check_stream_data(response: TableData, config: Config, context: Conte # complex to have a sanity check. return - actual_streams = set([stream.name for stream in Stream.objects.filter( - realm=response["zerver_realm"][0]['id'])]) - streams_in_response = set([stream['name'] for stream in response['zerver_stream']]) + actual_streams = {stream.name for stream in Stream.objects.filter( + realm=response["zerver_realm"][0]['id'])} + streams_in_response = {stream['name'] for stream in response['zerver_stream']} if len(streams_in_response - actual_streams) > 0: print("Error: Streams not present in the realm were exported:") @@ -893,12 +893,12 @@ def fetch_huddle_objects(response: TableData, config: Config, context: Context) realm = context['realm'] assert config.parent is not None assert config.parent.table is not None - user_profile_ids = set(r['id'] for r in response[config.parent.table]) + user_profile_ids = {r['id'] for r in response[config.parent.table]} # First we get all huddles involving someone in the realm. realm_huddle_subs = Subscription.objects.select_related("recipient").filter( recipient__type=Recipient.HUDDLE, user_profile__in=user_profile_ids) - realm_huddle_recipient_ids = set(sub.recipient_id for sub in realm_huddle_subs) + realm_huddle_recipient_ids = {sub.recipient_id for sub in realm_huddle_subs} # Mark all Huddles whose recipient ID contains a cross-realm user. unsafe_huddle_recipient_ids = set() @@ -914,8 +914,8 @@ def fetch_huddle_objects(response: TableData, config: Config, context: Context) # exporting the users from this realm), at the cost of losing # some of these cross-realm messages. huddle_subs = [sub for sub in realm_huddle_subs if sub.recipient_id not in unsafe_huddle_recipient_ids] - huddle_recipient_ids = set(sub.recipient_id for sub in huddle_subs) - huddle_ids = set(sub.recipient.type_id for sub in huddle_subs) + huddle_recipient_ids = {sub.recipient_id for sub in huddle_subs} + huddle_ids = {sub.recipient.type_id for sub in huddle_subs} huddle_subscription_dicts = make_raw(huddle_subs) huddle_recipients = make_raw(Recipient.objects.filter(id__in=huddle_recipient_ids)) @@ -953,7 +953,7 @@ def export_usermessages_batch(input_path: Path, output_path: Path, batch of Message objects and adds the corresponding UserMessage objects. (This is called by the export_usermessage_batch management command).""" - with open(input_path, "r") as input_file: + with open(input_path) as input_file: output = ujson.load(input_file) message_ids = [item['id'] for item in output['zerver_message']] user_profile_ids = set(output['zerver_userprofile_ids']) @@ -979,7 +979,7 @@ def export_partial_message_files(realm: Realm, output_dir = tempfile.mkdtemp(prefix="zulip-export") def get_ids(records: List[Record]) -> Set[int]: - return set(x['id'] for x in records) + return {x['id'] for x in records} # Basic security rule: You can export everything either... # - sent by someone in your exportable_user_ids @@ -1095,7 +1095,7 @@ def write_message_partial_for_query(realm: Realm, message_query: Any, dump_file_ while True: actual_query = message_query.filter(id__gt=min_id)[0:chunk_size] message_chunk = make_raw(actual_query) - message_ids = set(m['id'] for m in message_chunk) + message_ids = {m['id'] for m in message_chunk} assert len(message_ids.intersection(all_message_ids)) == 0 all_message_ids.update(message_ids) @@ -1431,7 +1431,7 @@ def do_write_stats_file_for_realm_export(output_dir: Path) -> None: with open(stats_file, 'w') as f: for fn in fns: f.write(os.path.basename(fn) + '\n') - with open(fn, 'r') as filename: + with open(fn) as filename: data = ujson.load(filename) for k in sorted(data): f.write('%5d %s\n' % (len(data[k]), k)) @@ -1442,7 +1442,7 @@ def do_write_stats_file_for_realm_export(output_dir: Path) -> None: for fn in [avatar_file, uploads_file]: f.write(fn+'\n') - with open(fn, 'r') as filename: + with open(fn) as filename: data = ujson.load(filename) f.write('%5d records\n' % (len(data),)) f.write('\n') @@ -1652,7 +1652,7 @@ def export_messages_single_user(user_profile: UserProfile, output_dir: Path, actual_query = user_message_query.select_related( "message", "message__sending_client").filter(id__gt=min_id)[0:chunk_size] user_message_chunk = [um for um in actual_query] - user_message_ids = set(um.id for um in user_message_chunk) + user_message_ids = {um.id for um in user_message_chunk} if len(user_message_chunk) == 0: break diff --git a/zerver/lib/generate_test_data.py b/zerver/lib/generate_test_data.py index ad2475f831..802527d8ce 100644 --- a/zerver/lib/generate_test_data.py +++ b/zerver/lib/generate_test_data.py @@ -7,7 +7,7 @@ import os from scripts.lib.zulip_tools import get_or_create_dev_uuid_var_path def load_config() -> Dict[str, Any]: - with open("zerver/tests/fixtures/config.generate_data.json", "r") as infile: + with open("zerver/tests/fixtures/config.generate_data.json") as infile: config = ujson.load(infile) return config @@ -47,7 +47,7 @@ def parse_file(config: Dict[str, Any], gens: Dict[str, Any], corpus_file: str) - paragraphs = [] # type: List[str] - with open(corpus_file, "r") as infile: + with open(corpus_file) as infile: # OUR DATA: we need to separate the person talking and what they say paragraphs = remove_line_breaks(infile) paragraphs = add_flair(paragraphs, gens) diff --git a/zerver/lib/i18n.py b/zerver/lib/i18n.py index 4a48195fed..c267ef12af 100644 --- a/zerver/lib/i18n.py +++ b/zerver/lib/i18n.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import operator from django.conf import settings @@ -27,7 +26,7 @@ def with_language(string: str, language: str) -> str: @lru_cache() def get_language_list() -> List[Dict[str, Any]]: path = os.path.join(settings.DEPLOY_ROOT, 'locale', 'language_name_map.json') - with open(path, 'r') as reader: + with open(path) as reader: languages = ujson.load(reader) return languages['name_map'] @@ -90,7 +89,7 @@ def get_language_translation_data(language: str) -> Dict[str, str]: language = 'id_ID' path = os.path.join(settings.DEPLOY_ROOT, 'locale', language, 'translations.json') try: - with open(path, 'r') as reader: + with open(path) as reader: return ujson.load(reader) except FileNotFoundError: print('Translation for {} not found at {}'.format(language, path)) diff --git a/zerver/lib/management.py b/zerver/lib/management.py index 26e358d787..7a7001b094 100644 --- a/zerver/lib/management.py +++ b/zerver/lib/management.py @@ -112,7 +112,7 @@ You can use the command list_realms to find ID of the realms in this server.""" if options["users"] is None: return [] - emails = set([email.strip() for email in options["users"].split(",")]) + emails = {email.strip() for email in options["users"].split(",")} user_profiles = [] for email in emails: user_profiles.append(self.get_user(email, realm)) diff --git a/zerver/lib/message.py b/zerver/lib/message.py index 2d30a13e92..2653d98c8f 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -505,13 +505,13 @@ class MessageDict: @staticmethod def bulk_hydrate_recipient_info(objs: List[Dict[str, Any]]) -> None: - recipient_tuples = set( # We use set to eliminate duplicate tuples. + recipient_tuples = { # We use set to eliminate duplicate tuples. ( obj['recipient_id'], obj['recipient_type'], obj['recipient_type_id'] ) for obj in objs - ) + } display_recipients = bulk_fetch_display_recipients(recipient_tuples) for obj in objs: diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.py index e76b20a324..478fd95439 100644 --- a/zerver/lib/narrow.py +++ b/zerver/lib/narrow.py @@ -14,7 +14,7 @@ def read_stop_words() -> List[str]: global stop_words_list if stop_words_list is None: file_path = os.path.join(settings.DEPLOY_ROOT, "puppet/zulip/files/postgresql/zulip_english.stop") - with open(file_path, 'r') as f: + with open(file_path) as f: stop_words_list = f.read().splitlines() return stop_words_list diff --git a/zerver/lib/parallel.py b/zerver/lib/parallel.py index c8f9672bcb..a0ab91275e 100644 --- a/zerver/lib/parallel.py +++ b/zerver/lib/parallel.py @@ -29,7 +29,7 @@ def run_parallel(job: Callable[[JobData], int], except OSError as e: if e.errno != errno.EBADF: raise - sys.stdin = open("/dev/null", "r") + sys.stdin = open("/dev/null") os._exit(job(item)) pids[pid] = item diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index bf4d111bfb..9ae0df5bb2 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import base64 import binascii import logging @@ -276,7 +274,7 @@ def send_android_push_notification(devices: List[DeviceToken], data: Dict[str, A priority=priority, data=data, retries=10) - except IOError as e: + except OSError as e: logger.warning(str(e)) return diff --git a/zerver/lib/statistics.py b/zerver/lib/statistics.py index c55ceedaae..72d4f47356 100644 --- a/zerver/lib/statistics.py +++ b/zerver/lib/statistics.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from zerver.models import UserProfile, UserActivityInterval from datetime import datetime, timedelta diff --git a/zerver/lib/streams.py b/zerver/lib/streams.py index ebdafc1d35..6bd7aed9c7 100644 --- a/zerver/lib/streams.py +++ b/zerver/lib/streams.py @@ -222,7 +222,7 @@ def filter_stream_authorization(user_profile: UserProfile, unauthorized_streams.append(stream) authorized_streams = [stream for stream in streams if - stream.id not in set(stream.id for stream in unauthorized_streams)] + stream.id not in {stream.id for stream in unauthorized_streams}] return authorized_streams, unauthorized_streams def list_to_streams(streams_raw: Iterable[Mapping[str, Any]], @@ -243,7 +243,7 @@ def list_to_streams(streams_raw: Iterable[Mapping[str, Any]], """ # Validate all streams, getting extant ones, then get-or-creating the rest. - stream_set = set(stream_dict["name"] for stream_dict in streams_raw) + stream_set = {stream_dict["name"] for stream_dict in streams_raw} for stream_name in stream_set: # Stream names should already have been stripped by the diff --git a/zerver/lib/subdomains.py b/zerver/lib/subdomains.py index 2425957a8a..476f0c8523 100644 --- a/zerver/lib/subdomains.py +++ b/zerver/lib/subdomains.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from django.conf import settings from django.http import HttpRequest import re diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 2fb24c7dcd..d86fe9a540 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -90,7 +90,7 @@ class UploadSerializeMixin(SerializeMixin): with open(cls.lockfile, 'w'): # nocoverage - rare locking case pass - super(UploadSerializeMixin, cls).setUpClass(*args, **kwargs) + super().setUpClass(*args, **kwargs) class ZulipTestCase(TestCase): # Ensure that the test system just shows us diffs @@ -813,7 +813,7 @@ class ZulipTestCase(TestCase): return output_dir def get_set(self, data: List[Dict[str, Any]], field: str) -> Set[str]: - values = set(r[field] for r in data) + values = {r[field] for r in data} return values def find_by_id(self, data: List[Dict[str, Any]], db_id: int) -> Dict[str, Any]: diff --git a/zerver/lib/test_fixtures.py b/zerver/lib/test_fixtures.py index 86303da2f9..f6a0d021c2 100644 --- a/zerver/lib/test_fixtures.py +++ b/zerver/lib/test_fixtures.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import json import os import re @@ -289,7 +288,7 @@ def destroy_leaked_test_databases(expiry_time: int = 60 * 60) -> int: databases_in_use = set() # type: Set[str] for file in files: if round(time.time()) - os.path.getmtime(file) < expiry_time: - with open(file, "r") as f: + with open(file) as f: for line in f: databases_in_use.add('zulip_test_template_{}'.format(line).rstrip()) else: diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index d6db29558b..0b3c6e78bb 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -399,7 +399,7 @@ def write_instrumentation_reports(full_suite: bool, include_webhooks: bool) -> N find_patterns(v1_api_and_json_patterns, ['api/v1/', 'json/']) assert len(pattern_cnt) > 100 - untested_patterns = set([p for p in pattern_cnt if pattern_cnt[p] == 0]) + untested_patterns = {p for p in pattern_cnt if pattern_cnt[p] == 0} exempt_patterns = set([ # We exempt some patterns that are called via Tornado. diff --git a/zerver/lib/test_runner.py b/zerver/lib/test_runner.py index fd0510f19a..9cc59e1ece 100644 --- a/zerver/lib/test_runner.py +++ b/zerver/lib/test_runner.py @@ -575,8 +575,7 @@ def get_test_names(suite: Union[TestSuite, ParallelTestSuite]) -> List[str]: def get_tests_from_suite(suite: unittest.TestSuite) -> TestCase: for test in suite: if isinstance(test, TestSuite): - for child in get_tests_from_suite(test): - yield child + yield from get_tests_from_suite(test) else: yield test diff --git a/zerver/lib/thumbnail.py b/zerver/lib/thumbnail.py index 3ba275c147..ef76893886 100644 --- a/zerver/lib/thumbnail.py +++ b/zerver/lib/thumbnail.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # See https://zulip.readthedocs.io/en/latest/subsystems/thumbnailing.html import base64 import os diff --git a/zerver/lib/upload.py b/zerver/lib/upload.py index 537c0f3c9f..b09a5524a5 100644 --- a/zerver/lib/upload.py +++ b/zerver/lib/upload.py @@ -94,7 +94,7 @@ def random_name(bytes: int=60) -> str: class BadImageError(JsonableError): code = ErrorCode.BAD_IMAGE -name_to_tag_num = dict((name, num) for num, name in ExifTags.TAGS.items()) +name_to_tag_num = {name: num for num, name in ExifTags.TAGS.items()} # https://stackoverflow.com/a/6218425 def exif_rotate(image: Image) -> Image: @@ -121,7 +121,7 @@ def resize_avatar(image_data: bytes, size: int=DEFAULT_AVATAR_SIZE) -> bytes: im = Image.open(io.BytesIO(image_data)) im = exif_rotate(im) im = ImageOps.fit(im, (size, size), Image.ANTIALIAS) - except IOError: + except OSError: raise BadImageError(_("Could not decode image; did you upload an image file?")) except DecompressionBombError: raise BadImageError(_("Image size exceeds limit.")) @@ -136,7 +136,7 @@ def resize_logo(image_data: bytes) -> bytes: im = Image.open(io.BytesIO(image_data)) im = exif_rotate(im) im.thumbnail((8*DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_SIZE), Image.ANTIALIAS) - except IOError: + except OSError: raise BadImageError(_("Could not decode image; did you upload an image file?")) except DecompressionBombError: raise BadImageError(_("Image size exceeds limit.")) @@ -188,7 +188,7 @@ def resize_emoji(image_data: bytes, size: int=DEFAULT_EMOJI_SIZE) -> bytes: out = io.BytesIO() im.save(out, format=image_format) return out.getvalue() - except IOError: + except OSError: raise BadImageError(_("Could not decode image; did you upload an image file?")) except DecompressionBombError: raise BadImageError(_("Image size exceeds limit.")) diff --git a/zerver/lib/user_groups.py b/zerver/lib/user_groups.py index cc9aa1153b..816b954b7f 100644 --- a/zerver/lib/user_groups.py +++ b/zerver/lib/user_groups.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from django.db import transaction from django.utils.translation import ugettext as _ from zerver.lib.exceptions import JsonableError diff --git a/zerver/lib/utils.py b/zerver/lib/utils.py index 1688377f5e..97c1e5ac03 100644 --- a/zerver/lib/utils.py +++ b/zerver/lib/utils.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Any, Callable, List, Optional, Sequence, TypeVar, Iterable, Set, Tuple import base64 import hashlib @@ -172,7 +170,7 @@ def query_chunker(queries: List[Any], break # Do duplicate-id management here. - tup_ids = set([tup[0] for tup in tup_chunk]) + tup_ids = {tup[0] for tup in tup_chunk} assert len(tup_ids) == len(tup_chunk) assert len(tup_ids.intersection(id_collector)) == 0 id_collector.update(tup_ids) diff --git a/zerver/lib/validator.py b/zerver/lib/validator.py index 7af88c6f13..24b16dd007 100644 --- a/zerver/lib/validator.py +++ b/zerver/lib/validator.py @@ -247,8 +247,8 @@ def check_dict(required_keys: Iterable[Tuple[str, Validator]]=[], type_structure['any'] = value_validator.type_structure # type: ignore # monkey-patching if _allow_only_listed_keys: - required_keys_set = set(x[0] for x in required_keys) - optional_keys_set = set(x[0] for x in optional_keys) + required_keys_set = {x[0] for x in required_keys} + optional_keys_set = {x[0] for x in optional_keys} delta_keys = set(val.keys()) - required_keys_set - optional_keys_set if len(delta_keys) != 0: return _("Unexpected arguments: %s") % (", ".join(list(delta_keys)),) diff --git a/zerver/logging_handlers.py b/zerver/logging_handlers.py index d1d522949f..87eef89dfc 100644 --- a/zerver/logging_handlers.py +++ b/zerver/logging_handlers.py @@ -31,7 +31,7 @@ def add_deployment_metadata(report: Dict[str, Any]) -> None: version_path = os.path.join(os.path.dirname(__file__), '../version') if os.path.exists(version_path): - with open(version_path, 'r') as f: # nocoverage + with open(version_path) as f: # nocoverage report['zulip_version_file'] = f.read().strip() def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None: diff --git a/zerver/management/commands/add_users_to_streams.py b/zerver/management/commands/add_users_to_streams.py index 3061e76765..7ed396aa86 100644 --- a/zerver/management/commands/add_users_to_streams.py +++ b/zerver/management/commands/add_users_to_streams.py @@ -25,7 +25,7 @@ class Command(ZulipBaseCommand): assert realm is not None # Should be ensured by parser user_profiles = self.get_users(options, realm) - stream_names = set([stream.strip() for stream in options["streams"].split(",")]) + stream_names = {stream.strip() for stream in options["streams"].split(",")} for stream_name in set(stream_names): for user_profile in user_profiles: diff --git a/zerver/management/commands/archive_messages.py b/zerver/management/commands/archive_messages.py index 46d214c11e..a3fa8f90fb 100644 --- a/zerver/management/commands/archive_messages.py +++ b/zerver/management/commands/archive_messages.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import - from typing import Any from django.core.management.base import BaseCommand diff --git a/zerver/management/commands/bulk_change_user_name.py b/zerver/management/commands/bulk_change_user_name.py index 59743ca0eb..970aceef9e 100644 --- a/zerver/management/commands/bulk_change_user_name.py +++ b/zerver/management/commands/bulk_change_user_name.py @@ -18,7 +18,7 @@ class Command(ZulipBaseCommand): def handle(self, *args: Any, **options: str) -> None: data_file = options['data_file'] realm = self.get_realm(options) - with open(data_file, "r") as f: + with open(data_file) as f: for line in f: email, new_name = line.strip().split(",", 1) diff --git a/zerver/management/commands/compilemessages.py b/zerver/management/commands/compilemessages.py index 5ea4c724a4..e64eb2badf 100644 --- a/zerver/management/commands/compilemessages.py +++ b/zerver/management/commands/compilemessages.py @@ -38,7 +38,7 @@ class Command(compilemessages.Command): path = join(deploy_root, 'locale', 'language_options.json') output_path = join(deploy_root, 'locale', 'language_name_map.json') - with open(path, 'r') as reader: + with open(path) as reader: languages = ujson.load(reader) lang_list = [] for lang_info in languages['languages']: @@ -61,7 +61,7 @@ class Command(compilemessages.Command): def get_name_from_po_file(self, po_filename: str, locale: str) -> str: lang_name_re = re.compile(r'"Language-Team: (.*?) \(') - with open(po_filename, 'r') as reader: + with open(po_filename) as reader: result = lang_name_re.search(reader.read()) if result: try: diff --git a/zerver/management/commands/create_default_stream_groups.py b/zerver/management/commands/create_default_stream_groups.py index 3cf42fbd1b..d8fea02fbe 100644 --- a/zerver/management/commands/create_default_stream_groups.py +++ b/zerver/management/commands/create_default_stream_groups.py @@ -44,7 +44,7 @@ Create default stream groups which the users can choose during sign up. assert realm is not None # Should be ensured by parser streams = [] - stream_names = set([stream.strip() for stream in options["streams"].split(",")]) + stream_names = {stream.strip() for stream in options["streams"].split(",")} for stream_name in set(stream_names): stream = ensure_stream(realm, stream_name) streams.append(stream) diff --git a/zerver/management/commands/create_user.py b/zerver/management/commands/create_user.py index fc776ab48e..1aa1feb464 100644 --- a/zerver/management/commands/create_user.py +++ b/zerver/management/commands/create_user.py @@ -78,7 +78,7 @@ parameters, or specify no parameters for interactive user creation.""") try: if options['password_file']: - with open(options['password_file'], 'r') as f: + with open(options['password_file']) as f: pw = f.read() elif options['password']: pw = options['password'] diff --git a/zerver/management/commands/generate_multiuse_invite_link.py b/zerver/management/commands/generate_multiuse_invite_link.py index a6100d63c0..44dbd17b36 100644 --- a/zerver/management/commands/generate_multiuse_invite_link.py +++ b/zerver/management/commands/generate_multiuse_invite_link.py @@ -32,7 +32,7 @@ class Command(ZulipBaseCommand): streams = [] # type: List[Stream] if options["streams"]: - stream_names = set([stream.strip() for stream in options["streams"].split(",")]) + stream_names = {stream.strip() for stream in options["streams"].split(",")} for stream_name in set(stream_names): stream = ensure_stream(realm, stream_name) streams.append(stream) diff --git a/zerver/management/commands/get_migration_status.py b/zerver/management/commands/get_migration_status.py index e80371cb89..847e333fae 100644 --- a/zerver/management/commands/get_migration_status.py +++ b/zerver/management/commands/get_migration_status.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import argparse import os from typing import Any diff --git a/zerver/management/commands/makemessages.py b/zerver/management/commands/makemessages.py index 41950716fd..35bacc2eba 100644 --- a/zerver/management/commands/makemessages.py +++ b/zerver/management/commands/makemessages.py @@ -72,7 +72,7 @@ class Command(makemessages.Command): xgettext_options += ['--keyword={}:1,"{}"'.format(func, tag)] def add_arguments(self, parser: ArgumentParser) -> None: - super(Command, self).add_arguments(parser) + super().add_arguments(parser) parser.add_argument('--frontend-source', type=str, default='static/templates', help='Name of the Handlebars template directory') @@ -165,7 +165,7 @@ class Command(makemessages.Command): for filename in [f for f in filenames if f.endswith(".hbs")]: if filename.startswith('.'): continue - with open(os.path.join(dirpath, filename), 'r') as reader: + with open(os.path.join(dirpath, filename)) as reader: data = reader.read() translation_strings.extend(self.extract_strings(data)) @@ -240,9 +240,9 @@ class Command(makemessages.Command): for locale, output_path in zip(self.get_locales(), self.get_output_paths()): self.stdout.write("[frontend] processing locale {}".format(locale)) try: - with open(output_path, 'r') as reader: + with open(output_path) as reader: old_strings = json.load(reader) - except (IOError, ValueError): + except (OSError, ValueError): old_strings = {} new_strings = { diff --git a/zerver/management/commands/merge_streams.py b/zerver/management/commands/merge_streams.py index e56df3b07c..a5d9316c14 100644 --- a/zerver/management/commands/merge_streams.py +++ b/zerver/management/commands/merge_streams.py @@ -53,7 +53,7 @@ class Command(ZulipBaseCommand): # preserve any stream settings/colors/etc. from the stream # being destroyed, but it's convenient. existing_subs = Subscription.objects.filter(recipient=recipient_to_keep) - users_already_subscribed = dict((sub.user_profile_id, sub.active) for sub in existing_subs) + users_already_subscribed = {sub.user_profile_id: sub.active for sub in existing_subs} subs_to_deactivate = Subscription.objects.filter(recipient=recipient_to_destroy, active=True) users_to_activate = [ diff --git a/zerver/management/commands/send_custom_email.py b/zerver/management/commands/send_custom_email.py index 33ddd51c11..76ecfd288d 100644 --- a/zerver/management/commands/send_custom_email.py +++ b/zerver/management/commands/send_custom_email.py @@ -20,7 +20,7 @@ def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None ) """ - with open(options["markdown_template_path"], "r") as f: + with open(options["markdown_template_path"]) as f: email_template_hash = hashlib.sha256(f.read().encode('utf-8')).hexdigest()[0:32] email_id = "zerver/emails/custom_email_%s" % (email_template_hash,) markdown_email_base_template_path = "templates/zerver/emails/custom_email_base.pre.html" @@ -35,7 +35,7 @@ def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None # And then extend it with our standard email headers. with open(html_source_template_path, "w") as f: - with open(markdown_email_base_template_path, "r") as base_template: + with open(markdown_email_base_template_path) as base_template: # Note that we're doing a hacky non-Jinja2 substitution here; # we do this because the normal render_markdown_path ordering # doesn't commute properly with inline-email-css. diff --git a/zerver/management/commands/sync_ldap_user_data.py b/zerver/management/commands/sync_ldap_user_data.py index 078c09a271..497ecdcd2b 100644 --- a/zerver/management/commands/sync_ldap_user_data.py +++ b/zerver/management/commands/sync_ldap_user_data.py @@ -18,7 +18,7 @@ log_to_file(logger, settings.LDAP_SYNC_LOG_PATH) def sync_ldap_user_data(user_profiles: List[UserProfile], deactivation_protection: bool=True) -> None: logger.info("Starting update.") with transaction.atomic(): - realms = set([u.realm.string_id for u in user_profiles]) + realms = {u.realm.string_id for u in user_profiles} for u in user_profiles: # This will save the user if relevant, and will do nothing if the user diff --git a/zerver/middleware.py b/zerver/middleware.py index 01650fb8a8..80576b9b59 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -116,15 +116,15 @@ def write_log_line(log_data: MutableMapping[str, Any], path: str, method: str, r if settings.STATSD_HOST != '': # For statsd timer name if path == '/': - statsd_path = u'webreq' + statsd_path = 'webreq' else: - statsd_path = u"webreq.%s" % (path[1:].replace('/', '.'),) + statsd_path = "webreq.%s" % (path[1:].replace('/', '.'),) # Remove non-ascii chars from path (there should be none, if there are it's # because someone manually entered a nonexistent path), as UTF-8 chars make # statsd sad when it sends the key name over the socket statsd_path = statsd_path.encode('ascii', errors='ignore').decode("ascii") # TODO: This could probably be optimized to use a regular expression rather than a loop. - suppress_statsd = any((blacklisted in statsd_path for blacklisted in statsd_blacklisted_requests)) + suppress_statsd = any(blacklisted in statsd_path for blacklisted in statsd_blacklisted_requests) else: suppress_statsd = True statsd_path = '' @@ -227,13 +227,13 @@ def write_log_line(log_data: MutableMapping[str, Any], path: str, method: str, r assert error_content_iter is not None error_content_list = list(error_content_iter) if not error_content_list: - error_data = u'' + error_data = '' elif isinstance(error_content_list[0], str): - error_data = u''.join(error_content_list) + error_data = ''.join(error_content_list) elif isinstance(error_content_list[0], bytes): error_data = repr(b''.join(error_content_list)) if len(error_data) > 200: - error_data = u"[content more than 200 characters]" + error_data = "[content more than 200 characters]" logger.info('status=%3d, data=%s, uid=%s' % (status_code, error_data, requestor_for_logs)) class LogRequests(MiddlewareMixin): diff --git a/zerver/migrations/0001_initial.py b/zerver/migrations/0001_initial.py index dfb9ce4ecf..dffc288083 100644 --- a/zerver/migrations/0001_initial.py +++ b/zerver/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-22 10:22 import bitfield.models import django.contrib.auth.models @@ -319,35 +318,35 @@ CREATE TRIGGER zerver_message_update_search_tsvector_async ), migrations.AlterUniqueTogether( name='userpresence', - unique_together=set([('user_profile', 'client')]), + unique_together={('user_profile', 'client')}, ), migrations.AlterUniqueTogether( name='usermessage', - unique_together=set([('user_profile', 'message')]), + unique_together={('user_profile', 'message')}, ), migrations.AlterUniqueTogether( name='useractivity', - unique_together=set([('user_profile', 'client', 'query')]), + unique_together={('user_profile', 'client', 'query')}, ), migrations.AlterUniqueTogether( name='subscription', - unique_together=set([('user_profile', 'recipient')]), + unique_together={('user_profile', 'recipient')}, ), migrations.AlterUniqueTogether( name='stream', - unique_together=set([('name', 'realm')]), + unique_together={('name', 'realm')}, ), migrations.AlterUniqueTogether( name='recipient', - unique_together=set([('type', 'type_id')]), + unique_together={('type', 'type_id')}, ), migrations.AlterUniqueTogether( name='realmfilter', - unique_together=set([('realm', 'pattern')]), + unique_together={('realm', 'pattern')}, ), migrations.AlterUniqueTogether( name='realmemoji', - unique_together=set([('realm', 'name')]), + unique_together={('realm', 'name')}, ), migrations.AddField( model_name='realm', @@ -396,7 +395,7 @@ CREATE TRIGGER zerver_message_update_search_tsvector_async ), migrations.AlterUniqueTogether( name='defaultstream', - unique_together=set([('realm', 'stream')]), + unique_together={('realm', 'stream')}, ), migrations.AddField( model_name='userprofile', diff --git a/zerver/migrations/0029_realm_subdomain.py b/zerver/migrations/0029_realm_subdomain.py index 75d058d188..69a0fb2832 100644 --- a/zerver/migrations/0029_realm_subdomain.py +++ b/zerver/migrations/0029_realm_subdomain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.core.exceptions import ObjectDoesNotExist from django.db import migrations, models diff --git a/zerver/migrations/0030_realm_org_type.py b/zerver/migrations/0030_realm_org_type.py index b77de1b6c2..6f32a07e1e 100644 --- a/zerver/migrations/0030_realm_org_type.py +++ b/zerver/migrations/0030_realm_org_type.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0031_remove_system_avatar_source.py b/zerver/migrations/0031_remove_system_avatar_source.py index 1f19c92d89..7e57a2c01a 100644 --- a/zerver/migrations/0031_remove_system_avatar_source.py +++ b/zerver/migrations/0031_remove_system_avatar_source.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0032_verify_all_medium_avatar_images.py b/zerver/migrations/0032_verify_all_medium_avatar_images.py index 4019a04304..1dceada9c9 100644 --- a/zerver/migrations/0032_verify_all_medium_avatar_images.py +++ b/zerver/migrations/0032_verify_all_medium_avatar_images.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import hashlib from typing import Text diff --git a/zerver/migrations/0033_migrate_domain_to_realmalias.py b/zerver/migrations/0033_migrate_domain_to_realmalias.py index 3aa8f556e1..d9c3dafcb4 100644 --- a/zerver/migrations/0033_migrate_domain_to_realmalias.py +++ b/zerver/migrations/0033_migrate_domain_to_realmalias.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0034_userprofile_enable_online_push_notifications.py b/zerver/migrations/0034_userprofile_enable_online_push_notifications.py index 5666f13feb..d35c8f8b27 100644 --- a/zerver/migrations/0034_userprofile_enable_online_push_notifications.py +++ b/zerver/migrations/0034_userprofile_enable_online_push_notifications.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0035_realm_message_retention_period_days.py b/zerver/migrations/0035_realm_message_retention_period_days.py index fe5e015e20..322a2602e2 100644 --- a/zerver/migrations/0035_realm_message_retention_period_days.py +++ b/zerver/migrations/0035_realm_message_retention_period_days.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0036_rename_subdomain_to_string_id.py b/zerver/migrations/0036_rename_subdomain_to_string_id.py index 75d08f2ffa..7ca2566c86 100644 --- a/zerver/migrations/0036_rename_subdomain_to_string_id.py +++ b/zerver/migrations/0036_rename_subdomain_to_string_id.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0037_disallow_null_string_id.py b/zerver/migrations/0037_disallow_null_string_id.py index 4549def203..ae5b2c3b86 100644 --- a/zerver/migrations/0037_disallow_null_string_id.py +++ b/zerver/migrations/0037_disallow_null_string_id.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0038_realm_change_to_community_defaults.py b/zerver/migrations/0038_realm_change_to_community_defaults.py index e8cbf91e6a..ad8c885a03 100644 --- a/zerver/migrations/0038_realm_change_to_community_defaults.py +++ b/zerver/migrations/0038_realm_change_to_community_defaults.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0039_realmalias_drop_uniqueness.py b/zerver/migrations/0039_realmalias_drop_uniqueness.py index e3df757c19..7e014b6edf 100644 --- a/zerver/migrations/0039_realmalias_drop_uniqueness.py +++ b/zerver/migrations/0039_realmalias_drop_uniqueness.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0040_realm_authentication_methods.py b/zerver/migrations/0040_realm_authentication_methods.py index 1adb82f9e0..b86d5eccb0 100644 --- a/zerver/migrations/0040_realm_authentication_methods.py +++ b/zerver/migrations/0040_realm_authentication_methods.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import bitfield.models from django.db import migrations diff --git a/zerver/migrations/0041_create_attachments_for_old_messages.py b/zerver/migrations/0041_create_attachments_for_old_messages.py index b38b557b69..002a8e4a81 100644 --- a/zerver/migrations/0041_create_attachments_for_old_messages.py +++ b/zerver/migrations/0041_create_attachments_for_old_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import re diff --git a/zerver/migrations/0042_attachment_file_name_length.py b/zerver/migrations/0042_attachment_file_name_length.py index f53740ee35..84f1da7717 100644 --- a/zerver/migrations/0042_attachment_file_name_length.py +++ b/zerver/migrations/0042_attachment_file_name_length.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0043_realm_filter_validators.py b/zerver/migrations/0043_realm_filter_validators.py index 1243619b29..ce20726c23 100644 --- a/zerver/migrations/0043_realm_filter_validators.py +++ b/zerver/migrations/0043_realm_filter_validators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import django.core.validators from django.db import migrations, models diff --git a/zerver/migrations/0044_reaction.py b/zerver/migrations/0044_reaction.py index ff4d9b6cf9..36ea5118af 100644 --- a/zerver/migrations/0044_reaction.py +++ b/zerver/migrations/0044_reaction.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import django.db.models.deletion from django.conf import settings from django.db import migrations, models @@ -23,6 +22,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='reaction', - unique_together=set([('user_profile', 'message', 'emoji_name')]), + unique_together={('user_profile', 'message', 'emoji_name')}, ), ] diff --git a/zerver/migrations/0045_realm_waiting_period_threshold.py b/zerver/migrations/0045_realm_waiting_period_threshold.py index 85ce3b5705..beae91282a 100644 --- a/zerver/migrations/0045_realm_waiting_period_threshold.py +++ b/zerver/migrations/0045_realm_waiting_period_threshold.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0046_realmemoji_author.py b/zerver/migrations/0046_realmemoji_author.py index 41fa608ecb..e3cee97162 100644 --- a/zerver/migrations/0046_realmemoji_author.py +++ b/zerver/migrations/0046_realmemoji_author.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2016-12-20 07:02 import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0047_realm_add_emoji_by_admins_only.py b/zerver/migrations/0047_realm_add_emoji_by_admins_only.py index 9abbc041de..4445a73f05 100644 --- a/zerver/migrations/0047_realm_add_emoji_by_admins_only.py +++ b/zerver/migrations/0047_realm_add_emoji_by_admins_only.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2016-12-20 13:45 from django.db import migrations, models diff --git a/zerver/migrations/0048_enter_sends_default_to_false.py b/zerver/migrations/0048_enter_sends_default_to_false.py index 3a35960cf9..fbf3afa5e4 100644 --- a/zerver/migrations/0048_enter_sends_default_to_false.py +++ b/zerver/migrations/0048_enter_sends_default_to_false.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2016-12-29 02:18 from django.db import migrations, models diff --git a/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py b/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py index 81cf745ba9..f44f567c02 100644 --- a/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py +++ b/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zerver/migrations/0050_userprofile_avatar_version.py b/zerver/migrations/0050_userprofile_avatar_version.py index 7b3ed3896e..7ac306dd6d 100644 --- a/zerver/migrations/0050_userprofile_avatar_version.py +++ b/zerver/migrations/0050_userprofile_avatar_version.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-01-23 17:44 from django.db import migrations, models diff --git a/zerver/migrations/0051_realmalias_add_allow_subdomains.py b/zerver/migrations/0051_realmalias_add_allow_subdomains.py index 14e8f89665..dec9cce795 100644 --- a/zerver/migrations/0051_realmalias_add_allow_subdomains.py +++ b/zerver/migrations/0051_realmalias_add_allow_subdomains.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-01-25 20:55 from django.db import migrations, models @@ -17,6 +16,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='realmalias', - unique_together=set([('realm', 'domain')]), + unique_together={('realm', 'domain')}, ), ] diff --git a/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py b/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py index 3603ff9ea4..b0537afa45 100644 --- a/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py +++ b/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-11 03:07 import django.db.models.deletion from django.db import migrations, models diff --git a/zerver/migrations/0053_emailchangestatus.py b/zerver/migrations/0053_emailchangestatus.py index 84ad324323..9f239d0b1e 100644 --- a/zerver/migrations/0053_emailchangestatus.py +++ b/zerver/migrations/0053_emailchangestatus.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-23 05:37 import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0054_realm_icon.py b/zerver/migrations/0054_realm_icon.py index d648772cd8..3a814dc1f8 100644 --- a/zerver/migrations/0054_realm_icon.py +++ b/zerver/migrations/0054_realm_icon.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-15 06:18 from django.db import migrations, models diff --git a/zerver/migrations/0055_attachment_size.py b/zerver/migrations/0055_attachment_size.py index d1e703b298..c90bd9b1cb 100644 --- a/zerver/migrations/0055_attachment_size.py +++ b/zerver/migrations/0055_attachment_size.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-01 06:28 from django.db import migrations, models diff --git a/zerver/migrations/0056_userprofile_emoji_alt_code.py b/zerver/migrations/0056_userprofile_emoji_alt_code.py index b1b632c34a..ec90d5026d 100644 --- a/zerver/migrations/0056_userprofile_emoji_alt_code.py +++ b/zerver/migrations/0056_userprofile_emoji_alt_code.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-02 07:28 from django.db import migrations, models diff --git a/zerver/migrations/0057_realmauditlog.py b/zerver/migrations/0057_realmauditlog.py index 07fd2755fb..dbbb156c63 100644 --- a/zerver/migrations/0057_realmauditlog.py +++ b/zerver/migrations/0057_realmauditlog.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-04 07:33 import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0058_realm_email_changes_disabled.py b/zerver/migrations/0058_realm_email_changes_disabled.py index d5ded2b5f8..bbe88c5a38 100644 --- a/zerver/migrations/0058_realm_email_changes_disabled.py +++ b/zerver/migrations/0058_realm_email_changes_disabled.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-27 14:34 from django.db import migrations, models diff --git a/zerver/migrations/0059_userprofile_quota.py b/zerver/migrations/0059_userprofile_quota.py index c5f7ecad29..91031df913 100644 --- a/zerver/migrations/0059_userprofile_quota.py +++ b/zerver/migrations/0059_userprofile_quota.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-04 07:40 from django.db import migrations, models diff --git a/zerver/migrations/0060_move_avatars_to_be_uid_based.py b/zerver/migrations/0060_move_avatars_to_be_uid_based.py index 1fcfcd97ec..5f394583e5 100644 --- a/zerver/migrations/0060_move_avatars_to_be_uid_based.py +++ b/zerver/migrations/0060_move_avatars_to_be_uid_based.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-27 17:03 import os from typing import Text diff --git a/zerver/migrations/0061_userprofile_timezone.py b/zerver/migrations/0061_userprofile_timezone.py index d91685a863..a1ebf32e18 100644 --- a/zerver/migrations/0061_userprofile_timezone.py +++ b/zerver/migrations/0061_userprofile_timezone.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-15 11:43 from django.db import migrations, models diff --git a/zerver/migrations/0062_default_timezone.py b/zerver/migrations/0062_default_timezone.py index 66cf989678..ac30ad8dfd 100644 --- a/zerver/migrations/0062_default_timezone.py +++ b/zerver/migrations/0062_default_timezone.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-16 12:22 from django.db import migrations, models diff --git a/zerver/migrations/0063_realm_description.py b/zerver/migrations/0063_realm_description.py index 7ddeec1e59..25440462c7 100644 --- a/zerver/migrations/0063_realm_description.py +++ b/zerver/migrations/0063_realm_description.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-19 19:06 from django.db import migrations, models diff --git a/zerver/migrations/0064_sync_uploads_filesize_with_db.py b/zerver/migrations/0064_sync_uploads_filesize_with_db.py index 663e4da861..a68a950fda 100644 --- a/zerver/migrations/0064_sync_uploads_filesize_with_db.py +++ b/zerver/migrations/0064_sync_uploads_filesize_with_db.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-18 12:38 import os from typing import Optional diff --git a/zerver/migrations/0065_realm_inline_image_preview.py b/zerver/migrations/0065_realm_inline_image_preview.py index 7c018d1d3a..5ee3b7bc8f 100644 --- a/zerver/migrations/0065_realm_inline_image_preview.py +++ b/zerver/migrations/0065_realm_inline_image_preview.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-21 15:56 from django.db import migrations, models diff --git a/zerver/migrations/0066_realm_inline_url_embed_preview.py b/zerver/migrations/0066_realm_inline_url_embed_preview.py index c8bb4ea6a4..5243d94c89 100644 --- a/zerver/migrations/0066_realm_inline_url_embed_preview.py +++ b/zerver/migrations/0066_realm_inline_url_embed_preview.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-21 15:58 from django.db import migrations, models diff --git a/zerver/migrations/0067_archived_models.py b/zerver/migrations/0067_archived_models.py index 57bb4dafd9..41cd8a98dc 100644 --- a/zerver/migrations/0067_archived_models.py +++ b/zerver/migrations/0067_archived_models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-26 01:10 import bitfield.models import django.db.models.deletion @@ -85,6 +84,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='archivedusermessage', - unique_together=set([('user_profile', 'message')]), + unique_together={('user_profile', 'message')}, ), ] diff --git a/zerver/migrations/0068_remove_realm_domain.py b/zerver/migrations/0068_remove_realm_domain.py index ee5ef6d0ad..4527bc925a 100644 --- a/zerver/migrations/0068_remove_realm_domain.py +++ b/zerver/migrations/0068_remove_realm_domain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-13 23:32 from django.db import migrations diff --git a/zerver/migrations/0069_realmauditlog_extra_data.py b/zerver/migrations/0069_realmauditlog_extra_data.py index a8b32e0db6..17eda4c749 100644 --- a/zerver/migrations/0069_realmauditlog_extra_data.py +++ b/zerver/migrations/0069_realmauditlog_extra_data.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-27 20:00 from django.db import migrations, models diff --git a/zerver/migrations/0070_userhotspot.py b/zerver/migrations/0070_userhotspot.py index 1986ea9574..1a9effea9c 100644 --- a/zerver/migrations/0070_userhotspot.py +++ b/zerver/migrations/0070_userhotspot.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-28 00:22 import django.db.models.deletion import django.utils.timezone @@ -24,6 +23,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='userhotspot', - unique_together=set([('user', 'hotspot')]), + unique_together={('user', 'hotspot')}, ), ] diff --git a/zerver/migrations/0071_rename_realmalias_to_realmdomain.py b/zerver/migrations/0071_rename_realmalias_to_realmdomain.py index 560233ebb6..e0b4a8d6fa 100644 --- a/zerver/migrations/0071_rename_realmalias_to_realmdomain.py +++ b/zerver/migrations/0071_rename_realmalias_to_realmdomain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-31 14:21 from django.db import migrations diff --git a/zerver/migrations/0072_realmauditlog_add_index_event_time.py b/zerver/migrations/0072_realmauditlog_add_index_event_time.py index f5b7a20664..0c6e0ecee2 100644 --- a/zerver/migrations/0072_realmauditlog_add_index_event_time.py +++ b/zerver/migrations/0072_realmauditlog_add_index_event_time.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-31 05:51 from django.db import migrations, models diff --git a/zerver/migrations/0073_custom_profile_fields.py b/zerver/migrations/0073_custom_profile_fields.py index e7a923ee36..01d4b5c256 100644 --- a/zerver/migrations/0073_custom_profile_fields.py +++ b/zerver/migrations/0073_custom_profile_fields.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-17 06:49 import django.db.models.deletion from django.conf import settings @@ -32,10 +31,10 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='customprofilefieldvalue', - unique_together=set([('user_profile', 'field')]), + unique_together={('user_profile', 'field')}, ), migrations.AlterUniqueTogether( name='customprofilefield', - unique_together=set([('realm', 'name')]), + unique_together={('realm', 'name')}, ), ] diff --git a/zerver/migrations/0074_fix_duplicate_attachments.py b/zerver/migrations/0074_fix_duplicate_attachments.py index d1ed9c50f1..4e552cd95b 100644 --- a/zerver/migrations/0074_fix_duplicate_attachments.py +++ b/zerver/migrations/0074_fix_duplicate_attachments.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-13 22:12 from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0075_attachment_path_id_unique.py b/zerver/migrations/0075_attachment_path_id_unique.py index 445447f82f..396b7013fc 100644 --- a/zerver/migrations/0075_attachment_path_id_unique.py +++ b/zerver/migrations/0075_attachment_path_id_unique.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-13 22:29 from django.db import migrations, models diff --git a/zerver/migrations/0076_userprofile_emojiset.py b/zerver/migrations/0076_userprofile_emojiset.py index 27db75e580..483db6ea2e 100644 --- a/zerver/migrations/0076_userprofile_emojiset.py +++ b/zerver/migrations/0076_userprofile_emojiset.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-23 19:51 from django.db import migrations, models diff --git a/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py b/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py index 3b774b65d4..a19e593a2f 100644 --- a/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py +++ b/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-09 05:23 import io import logging @@ -66,7 +65,7 @@ class Uploader: return None try: resized_image = self.resize_emoji(response.content) - except IOError: + except OSError: return None self.upload_files(response, resized_image, dst_path_id) return file_name @@ -113,7 +112,7 @@ class S3Uploader(Uploader): def upload_files(self, response: Response, resized_image: bytes, dst_path_id: str) -> None: headers = None # type: Optional[Dict[str, str]] - content_type = response.headers.get(str("Content-Type")) or guess_type(dst_path_id)[0] + content_type = response.headers.get("Content-Type") or guess_type(dst_path_id)[0] if content_type: headers = {'Content-Type': content_type} if resized_image: diff --git a/zerver/migrations/0078_service.py b/zerver/migrations/0078_service.py index dcdf42a8dd..e17f20610e 100644 --- a/zerver/migrations/0078_service.py +++ b/zerver/migrations/0078_service.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-27 16:55 import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0079_remove_old_scheduled_jobs.py b/zerver/migrations/0079_remove_old_scheduled_jobs.py index d0ce68f515..60b1fdb3e8 100644 --- a/zerver/migrations/0079_remove_old_scheduled_jobs.py +++ b/zerver/migrations/0079_remove_old_scheduled_jobs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-10 05:59 from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0080_realm_description_length.py b/zerver/migrations/0080_realm_description_length.py index 46b4eb056b..797dedd858 100644 --- a/zerver/migrations/0080_realm_description_length.py +++ b/zerver/migrations/0080_realm_description_length.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-11 20:27 from django.db import migrations, models diff --git a/zerver/migrations/0081_make_emoji_lowercase.py b/zerver/migrations/0081_make_emoji_lowercase.py index 2c6fb4c37f..2da3c83600 100644 --- a/zerver/migrations/0081_make_emoji_lowercase.py +++ b/zerver/migrations/0081_make_emoji_lowercase.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-02 21:44 import django.core.validators from django.db import migrations, models diff --git a/zerver/migrations/0082_index_starred_user_messages.py b/zerver/migrations/0082_index_starred_user_messages.py index 1ce3ce3ba9..f97a11306c 100644 --- a/zerver/migrations/0082_index_starred_user_messages.py +++ b/zerver/migrations/0082_index_starred_user_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0083_index_mentioned_user_messages.py b/zerver/migrations/0083_index_mentioned_user_messages.py index ace5287312..765258366e 100644 --- a/zerver/migrations/0083_index_mentioned_user_messages.py +++ b/zerver/migrations/0083_index_mentioned_user_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0084_realmemoji_deactivated.py b/zerver/migrations/0084_realmemoji_deactivated.py index c811d7e762..54c7af9929 100644 --- a/zerver/migrations/0084_realmemoji_deactivated.py +++ b/zerver/migrations/0084_realmemoji_deactivated.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-22 14:49 from django.db import migrations, models diff --git a/zerver/migrations/0085_fix_bots_with_none_bot_type.py b/zerver/migrations/0085_fix_bots_with_none_bot_type.py index 193887b886..2b1ba2fcb7 100644 --- a/zerver/migrations/0085_fix_bots_with_none_bot_type.py +++ b/zerver/migrations/0085_fix_bots_with_none_bot_type.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-20 10:31 from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0086_realm_alter_default_org_type.py b/zerver/migrations/0086_realm_alter_default_org_type.py index 4907f114f1..1dca4623d8 100644 --- a/zerver/migrations/0086_realm_alter_default_org_type.py +++ b/zerver/migrations/0086_realm_alter_default_org_type.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-26 21:56 from django.db import migrations, models diff --git a/zerver/migrations/0087_remove_old_scheduled_jobs.py b/zerver/migrations/0087_remove_old_scheduled_jobs.py index 147c28189d..f7febd36d0 100644 --- a/zerver/migrations/0087_remove_old_scheduled_jobs.py +++ b/zerver/migrations/0087_remove_old_scheduled_jobs.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-10 05:59 from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0088_remove_referral_and_invites.py b/zerver/migrations/0088_remove_referral_and_invites.py index 206dd81fc9..46a2bc0c1c 100644 --- a/zerver/migrations/0088_remove_referral_and_invites.py +++ b/zerver/migrations/0088_remove_referral_and_invites.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-07 08:34 from django.db import migrations diff --git a/zerver/migrations/0089_auto_20170710_1353.py b/zerver/migrations/0089_auto_20170710_1353.py index 1f948358c9..f4f01e0de4 100644 --- a/zerver/migrations/0089_auto_20170710_1353.py +++ b/zerver/migrations/0089_auto_20170710_1353.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-10 13:53 from django.db import migrations, models diff --git a/zerver/migrations/0090_userprofile_high_contrast_mode.py b/zerver/migrations/0090_userprofile_high_contrast_mode.py index 33a0b1e244..85a8feb6bd 100644 --- a/zerver/migrations/0090_userprofile_high_contrast_mode.py +++ b/zerver/migrations/0090_userprofile_high_contrast_mode.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-07 15:58 from django.db import migrations, models diff --git a/zerver/migrations/0091_realm_allow_edit_history.py b/zerver/migrations/0091_realm_allow_edit_history.py index dd6607cf47..ea68a2a4b5 100644 --- a/zerver/migrations/0091_realm_allow_edit_history.py +++ b/zerver/migrations/0091_realm_allow_edit_history.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-16 08:57 from django.db import migrations, models diff --git a/zerver/migrations/0092_create_scheduledemail.py b/zerver/migrations/0092_create_scheduledemail.py index 8f2875257d..89d366de7b 100644 --- a/zerver/migrations/0092_create_scheduledemail.py +++ b/zerver/migrations/0092_create_scheduledemail.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-11 23:41 import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0093_subscription_event_log_backfill.py b/zerver/migrations/0093_subscription_event_log_backfill.py index bde817cdd3..ae08c429fc 100644 --- a/zerver/migrations/0093_subscription_event_log_backfill.py +++ b/zerver/migrations/0093_subscription_event_log_backfill.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0094_realm_filter_url_validator.py b/zerver/migrations/0094_realm_filter_url_validator.py index 60a1608fc7..c6d72f11ca 100644 --- a/zerver/migrations/0094_realm_filter_url_validator.py +++ b/zerver/migrations/0094_realm_filter_url_validator.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-22 13:44 import django.core.validators from django.db import migrations, models diff --git a/zerver/migrations/0095_index_unread_user_messages.py b/zerver/migrations/0095_index_unread_user_messages.py index 344c42b5a6..6acf45301d 100644 --- a/zerver/migrations/0095_index_unread_user_messages.py +++ b/zerver/migrations/0095_index_unread_user_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0096_add_password_required.py b/zerver/migrations/0096_add_password_required.py index e4b808153f..2d5744fff3 100644 --- a/zerver/migrations/0096_add_password_required.py +++ b/zerver/migrations/0096_add_password_required.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-08-09 04:21 from django.db import migrations, models diff --git a/zerver/migrations/0097_reactions_emoji_code.py b/zerver/migrations/0097_reactions_emoji_code.py index 7314fe009f..47bdf02d65 100644 --- a/zerver/migrations/0097_reactions_emoji_code.py +++ b/zerver/migrations/0097_reactions_emoji_code.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-18 21:26 import os diff --git a/zerver/migrations/0098_index_has_alert_word_user_messages.py b/zerver/migrations/0098_index_has_alert_word_user_messages.py index 0b83e2b99c..09b66274a9 100644 --- a/zerver/migrations/0098_index_has_alert_word_user_messages.py +++ b/zerver/migrations/0098_index_has_alert_word_user_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py b/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py index 050f4b56a2..1dbfd1db8e 100644 --- a/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py +++ b/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0100_usermessage_remove_is_me_message.py b/zerver/migrations/0100_usermessage_remove_is_me_message.py index 699cf7ca85..da8b5ca685 100644 --- a/zerver/migrations/0100_usermessage_remove_is_me_message.py +++ b/zerver/migrations/0100_usermessage_remove_is_me_message.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-27 17:08 import bitfield.models from django.db import migrations diff --git a/zerver/migrations/0101_muted_topic.py b/zerver/migrations/0101_muted_topic.py index e57f24433a..bdb956993e 100644 --- a/zerver/migrations/0101_muted_topic.py +++ b/zerver/migrations/0101_muted_topic.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-30 00:26 import django.db.models.deletion from django.conf import settings @@ -25,6 +24,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='mutedtopic', - unique_together=set([('user_profile', 'stream', 'topic_name')]), + unique_together={('user_profile', 'stream', 'topic_name')}, ), ] diff --git a/zerver/migrations/0102_convert_muted_topic.py b/zerver/migrations/0102_convert_muted_topic.py index 8090ed3283..6e4e5bca16 100644 --- a/zerver/migrations/0102_convert_muted_topic.py +++ b/zerver/migrations/0102_convert_muted_topic.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-30 00:26 import ujson from django.db import connection, migrations diff --git a/zerver/migrations/0103_remove_userprofile_muted_topics.py b/zerver/migrations/0103_remove_userprofile_muted_topics.py index a6efb6a170..f7ec37d3c6 100644 --- a/zerver/migrations/0103_remove_userprofile_muted_topics.py +++ b/zerver/migrations/0103_remove_userprofile_muted_topics.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-31 00:13 from django.db import migrations diff --git a/zerver/migrations/0104_fix_unreads.py b/zerver/migrations/0104_fix_unreads.py index ab95505ad4..0f0a193064 100644 --- a/zerver/migrations/0104_fix_unreads.py +++ b/zerver/migrations/0104_fix_unreads.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-30 00:26 from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py b/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py index 8e91185b24..79c82736b7 100644 --- a/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py +++ b/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-08 17:52 from django.db import migrations, models diff --git a/zerver/migrations/0106_subscription_push_notifications.py b/zerver/migrations/0106_subscription_push_notifications.py index 4979b93de6..76b8b08fb7 100644 --- a/zerver/migrations/0106_subscription_push_notifications.py +++ b/zerver/migrations/0106_subscription_push_notifications.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-08 17:52 from django.db import migrations, models diff --git a/zerver/migrations/0107_multiuseinvite.py b/zerver/migrations/0107_multiuseinvite.py index 35b8b05f30..dad26044fc 100644 --- a/zerver/migrations/0107_multiuseinvite.py +++ b/zerver/migrations/0107_multiuseinvite.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-04 22:48 import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0108_fix_default_string_id.py b/zerver/migrations/0108_fix_default_string_id.py index 21a0968998..f161cd65fa 100644 --- a/zerver/migrations/0108_fix_default_string_id.py +++ b/zerver/migrations/0108_fix_default_string_id.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-24 02:39 from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0109_mark_tutorial_status_finished.py b/zerver/migrations/0109_mark_tutorial_status_finished.py index a6f63775e9..ab812714c5 100644 --- a/zerver/migrations/0109_mark_tutorial_status_finished.py +++ b/zerver/migrations/0109_mark_tutorial_status_finished.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0110_stream_is_in_zephyr_realm.py b/zerver/migrations/0110_stream_is_in_zephyr_realm.py index 3518c46814..d165efe471 100644 --- a/zerver/migrations/0110_stream_is_in_zephyr_realm.py +++ b/zerver/migrations/0110_stream_is_in_zephyr_realm.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-08 18:37 from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0111_botuserstatedata.py b/zerver/migrations/0111_botuserstatedata.py index de9e171276..87cd0ef269 100644 --- a/zerver/migrations/0111_botuserstatedata.py +++ b/zerver/migrations/0111_botuserstatedata.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-18 16:15 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings @@ -25,6 +23,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='botuserstatedata', - unique_together=set([('bot_profile', 'key')]), + unique_together={('bot_profile', 'key')}, ), ] diff --git a/zerver/migrations/0112_index_muted_topics.py b/zerver/migrations/0112_index_muted_topics.py index 945e492ecd..1554b02b0a 100644 --- a/zerver/migrations/0112_index_muted_topics.py +++ b/zerver/migrations/0112_index_muted_topics.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0113_default_stream_group.py b/zerver/migrations/0113_default_stream_group.py index b5c327952b..5db08b8cb0 100644 --- a/zerver/migrations/0113_default_stream_group.py +++ b/zerver/migrations/0113_default_stream_group.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-14 15:12 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models @@ -24,6 +22,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='defaultstreamgroup', - unique_together=set([('realm', 'name')]), + unique_together={('realm', 'name')}, ), ] diff --git a/zerver/migrations/0114_preregistrationuser_invited_as_admin.py b/zerver/migrations/0114_preregistrationuser_invited_as_admin.py index 9563daf0ee..bb15ce804c 100644 --- a/zerver/migrations/0114_preregistrationuser_invited_as_admin.py +++ b/zerver/migrations/0114_preregistrationuser_invited_as_admin.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-19 21:42 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0115_user_groups.py b/zerver/migrations/0115_user_groups.py index d513febe4f..dc86cac347 100644 --- a/zerver/migrations/0115_user_groups.py +++ b/zerver/migrations/0115_user_groups.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-10-30 05:05 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings @@ -41,10 +39,10 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='usergroupmembership', - unique_together=set([('user_group', 'user_profile')]), + unique_together={('user_group', 'user_profile')}, ), migrations.AlterUniqueTogether( name='usergroup', - unique_together=set([('realm', 'name')]), + unique_together={('realm', 'name')}, ), ] diff --git a/zerver/migrations/0116_realm_allow_message_deleting.py b/zerver/migrations/0116_realm_allow_message_deleting.py index 60209a1641..ef6dacbafa 100644 --- a/zerver/migrations/0116_realm_allow_message_deleting.py +++ b/zerver/migrations/0116_realm_allow_message_deleting.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-28 11:13 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0117_add_desc_to_user_group.py b/zerver/migrations/0117_add_desc_to_user_group.py index 24564849fa..565932dce4 100644 --- a/zerver/migrations/0117_add_desc_to_user_group.py +++ b/zerver/migrations/0117_add_desc_to_user_group.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-01 08:01 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0118_defaultstreamgroup_description.py b/zerver/migrations/0118_defaultstreamgroup_description.py index 0a577b4f37..c72083bc02 100644 --- a/zerver/migrations/0118_defaultstreamgroup_description.py +++ b/zerver/migrations/0118_defaultstreamgroup_description.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-14 19:52 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0119_userprofile_night_mode.py b/zerver/migrations/0119_userprofile_night_mode.py index 6816b21273..715af3f3c4 100644 --- a/zerver/migrations/0119_userprofile_night_mode.py +++ b/zerver/migrations/0119_userprofile_night_mode.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-14 19:28 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0120_botuserconfigdata.py b/zerver/migrations/0120_botuserconfigdata.py index 2e40aad7b8..77417a381f 100644 --- a/zerver/migrations/0120_botuserconfigdata.py +++ b/zerver/migrations/0120_botuserconfigdata.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-01 19:12 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings @@ -25,6 +23,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='botuserconfigdata', - unique_together=set([('bot_profile', 'key')]), + unique_together={('bot_profile', 'key')}, ), ] diff --git a/zerver/migrations/0121_realm_signup_notifications_stream.py b/zerver/migrations/0121_realm_signup_notifications_stream.py index 2697fd9979..de4c697c62 100644 --- a/zerver/migrations/0121_realm_signup_notifications_stream.py +++ b/zerver/migrations/0121_realm_signup_notifications_stream.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-19 22:01 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/zerver/migrations/0122_rename_botuserstatedata_botstoragedata.py b/zerver/migrations/0122_rename_botuserstatedata_botstoragedata.py index c8e3789220..8380522d6a 100644 --- a/zerver/migrations/0122_rename_botuserstatedata_botstoragedata.py +++ b/zerver/migrations/0122_rename_botuserstatedata_botstoragedata.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-24 09:10 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0123_userprofile_make_realm_email_pair_unique.py b/zerver/migrations/0123_userprofile_make_realm_email_pair_unique.py index a4987fce4e..b959fc1314 100644 --- a/zerver/migrations/0123_userprofile_make_realm_email_pair_unique.py +++ b/zerver/migrations/0123_userprofile_make_realm_email_pair_unique.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-22 20:45 -from __future__ import unicode_literals from django.db import migrations, models @@ -19,6 +17,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='userprofile', - unique_together=set([('realm', 'email')]), + unique_together={('realm', 'email')}, ), ] diff --git a/zerver/migrations/0124_stream_enable_notifications.py b/zerver/migrations/0124_stream_enable_notifications.py index 734db32728..edbf5db118 100644 --- a/zerver/migrations/0124_stream_enable_notifications.py +++ b/zerver/migrations/0124_stream_enable_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-29 01:38 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0125_realm_max_invites.py b/zerver/migrations/0125_realm_max_invites.py index 37ce8fcb1c..378ffdc22e 100644 --- a/zerver/migrations/0125_realm_max_invites.py +++ b/zerver/migrations/0125_realm_max_invites.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-30 04:58 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0126_prereg_remove_users_without_realm.py b/zerver/migrations/0126_prereg_remove_users_without_realm.py index 7414cef77a..1d23491985 100644 --- a/zerver/migrations/0126_prereg_remove_users_without_realm.py +++ b/zerver/migrations/0126_prereg_remove_users_without_realm.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-30 04:58 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py b/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py index 0f56d753e0..08ded23b10 100644 --- a/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py +++ b/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Any, List from django.db import migrations diff --git a/zerver/migrations/0128_scheduledemail_realm.py b/zerver/migrations/0128_scheduledemail_realm.py index b05e607d26..219c4d71cf 100644 --- a/zerver/migrations/0128_scheduledemail_realm.py +++ b/zerver/migrations/0128_scheduledemail_realm.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-12-05 01:08 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/zerver/migrations/0129_remove_userprofile_autoscroll_forever.py b/zerver/migrations/0129_remove_userprofile_autoscroll_forever.py index f0ac2ef58d..6f1095f000 100644 --- a/zerver/migrations/0129_remove_userprofile_autoscroll_forever.py +++ b/zerver/migrations/0129_remove_userprofile_autoscroll_forever.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-12-27 17:55 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0131_realm_create_generic_bot_by_admins_only.py b/zerver/migrations/0131_realm_create_generic_bot_by_admins_only.py index ccf00d344d..69b06f7028 100644 --- a/zerver/migrations/0131_realm_create_generic_bot_by_admins_only.py +++ b/zerver/migrations/0131_realm_create_generic_bot_by_admins_only.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-30 20:05 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0132_realm_message_visibility_limit.py b/zerver/migrations/0132_realm_message_visibility_limit.py index 9f8feaf084..3a8ad88ec9 100644 --- a/zerver/migrations/0132_realm_message_visibility_limit.py +++ b/zerver/migrations/0132_realm_message_visibility_limit.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-03 18:14 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0133_rename_botuserconfigdata_botconfigdata.py b/zerver/migrations/0133_rename_botuserconfigdata_botconfigdata.py index e7db05b1c8..ff5f855550 100644 --- a/zerver/migrations/0133_rename_botuserconfigdata_botconfigdata.py +++ b/zerver/migrations/0133_rename_botuserconfigdata_botconfigdata.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-06 09:56 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0134_scheduledmessage.py b/zerver/migrations/0134_scheduledmessage.py index d0fa608c03..e6cfbfe8e3 100644 --- a/zerver/migrations/0134_scheduledmessage.py +++ b/zerver/migrations/0134_scheduledmessage.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-10 01:11 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0135_scheduledmessage_delivery_type.py b/zerver/migrations/0135_scheduledmessage_delivery_type.py index b4895427ac..dd219ce8f7 100644 --- a/zerver/migrations/0135_scheduledmessage_delivery_type.py +++ b/zerver/migrations/0135_scheduledmessage_delivery_type.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-12 10:37 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0136_remove_userprofile_quota.py b/zerver/migrations/0136_remove_userprofile_quota.py index 0b22fc29c3..68e049656a 100644 --- a/zerver/migrations/0136_remove_userprofile_quota.py +++ b/zerver/migrations/0136_remove_userprofile_quota.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-24 20:24 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0137_realm_upload_quota_gb.py b/zerver/migrations/0137_realm_upload_quota_gb.py index e7b0d5e9c6..a86d79dab8 100644 --- a/zerver/migrations/0137_realm_upload_quota_gb.py +++ b/zerver/migrations/0137_realm_upload_quota_gb.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-24 20:24 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0138_userprofile_realm_name_in_notifications.py b/zerver/migrations/0138_userprofile_realm_name_in_notifications.py index b4f9c4eae7..5b7a7950a7 100644 --- a/zerver/migrations/0138_userprofile_realm_name_in_notifications.py +++ b/zerver/migrations/0138_userprofile_realm_name_in_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-21 08:47 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py b/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py index 769a7e680e..d0d7ce8773 100644 --- a/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py +++ b/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0140_realm_send_welcome_emails.py b/zerver/migrations/0140_realm_send_welcome_emails.py index 2e994b1354..24276818ac 100644 --- a/zerver/migrations/0140_realm_send_welcome_emails.py +++ b/zerver/migrations/0140_realm_send_welcome_emails.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-02-18 07:02 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0141_change_usergroup_description_to_textfield.py b/zerver/migrations/0141_change_usergroup_description_to_textfield.py index fca655d876..1b95ca6302 100644 --- a/zerver/migrations/0141_change_usergroup_description_to_textfield.py +++ b/zerver/migrations/0141_change_usergroup_description_to_textfield.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-02-28 17:38 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0142_userprofile_translate_emoticons.py b/zerver/migrations/0142_userprofile_translate_emoticons.py index 9fe87d5442..e849e1c0ee 100644 --- a/zerver/migrations/0142_userprofile_translate_emoticons.py +++ b/zerver/migrations/0142_userprofile_translate_emoticons.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-02-19 22:27 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0143_realm_bot_creation_policy.py b/zerver/migrations/0143_realm_bot_creation_policy.py index 2f1374c63c..772294938f 100644 --- a/zerver/migrations/0143_realm_bot_creation_policy.py +++ b/zerver/migrations/0143_realm_bot_creation_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-03-09 18:00 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0144_remove_realm_create_generic_bot_by_admins_only.py b/zerver/migrations/0144_remove_realm_create_generic_bot_by_admins_only.py index d0152dd527..807dea2744 100644 --- a/zerver/migrations/0144_remove_realm_create_generic_bot_by_admins_only.py +++ b/zerver/migrations/0144_remove_realm_create_generic_bot_by_admins_only.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-03-09 21:21 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py b/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py index 689c71c934..76d84cfaec 100644 --- a/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py +++ b/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from collections import defaultdict from typing import Any, Dict diff --git a/zerver/migrations/0146_userprofile_message_content_in_email_notifications.py b/zerver/migrations/0146_userprofile_message_content_in_email_notifications.py index 1c8a733155..631876c28f 100644 --- a/zerver/migrations/0146_userprofile_message_content_in_email_notifications.py +++ b/zerver/migrations/0146_userprofile_message_content_in_email_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-11-29 12:33 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0147_realm_disallow_disposable_email_addresses.py b/zerver/migrations/0147_realm_disallow_disposable_email_addresses.py index 78a7d2425f..edcb568b58 100644 --- a/zerver/migrations/0147_realm_disallow_disposable_email_addresses.py +++ b/zerver/migrations/0147_realm_disallow_disposable_email_addresses.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-03-05 19:20 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0148_max_invites_forget_default.py b/zerver/migrations/0148_max_invites_forget_default.py index 297faf498a..8ed373cb4e 100644 --- a/zerver/migrations/0148_max_invites_forget_default.py +++ b/zerver/migrations/0148_max_invites_forget_default.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-02-10 02:59 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py index 90b6e432eb..e6464ed522 100644 --- a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py +++ b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import os import shutil @@ -98,7 +97,7 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='realmemoji', - unique_together=set([]), + unique_together=set(), ), migrations.AlterField( model_name='realmemoji', diff --git a/zerver/migrations/0150_realm_allow_community_topic_editing.py b/zerver/migrations/0150_realm_allow_community_topic_editing.py index 1d9e4ad168..5674cbc20b 100644 --- a/zerver/migrations/0150_realm_allow_community_topic_editing.py +++ b/zerver/migrations/0150_realm_allow_community_topic_editing.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-28 22:56 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0151_last_reminder_default_none.py b/zerver/migrations/0151_last_reminder_default_none.py index 2fbda68cc6..5202640fc5 100644 --- a/zerver/migrations/0151_last_reminder_default_none.py +++ b/zerver/migrations/0151_last_reminder_default_none.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-03-29 18:47 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0152_realm_default_twenty_four_hour_time.py b/zerver/migrations/0152_realm_default_twenty_four_hour_time.py index 228f91638d..1d4b0230c8 100644 --- a/zerver/migrations/0152_realm_default_twenty_four_hour_time.py +++ b/zerver/migrations/0152_realm_default_twenty_four_hour_time.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-03-30 17:18 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0153_remove_int_float_custom_fields.py b/zerver/migrations/0153_remove_int_float_custom_fields.py index bcd2789282..3cf5ad9bab 100644 --- a/zerver/migrations/0153_remove_int_float_custom_fields.py +++ b/zerver/migrations/0153_remove_int_float_custom_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-04-02 12:42 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0154_fix_invalid_bot_owner.py b/zerver/migrations/0154_fix_invalid_bot_owner.py index 831dd1298d..f7dc355c89 100644 --- a/zerver/migrations/0154_fix_invalid_bot_owner.py +++ b/zerver/migrations/0154_fix_invalid_bot_owner.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-04-03 01:52 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0155_change_default_realm_description.py b/zerver/migrations/0155_change_default_realm_description.py index 8c5d28c83c..f93608f891 100644 --- a/zerver/migrations/0155_change_default_realm_description.py +++ b/zerver/migrations/0155_change_default_realm_description.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-06 19:17 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0156_add_hint_to_profile_field.py b/zerver/migrations/0156_add_hint_to_profile_field.py index e6ce0ab434..9e430445d7 100644 --- a/zerver/migrations/0156_add_hint_to_profile_field.py +++ b/zerver/migrations/0156_add_hint_to_profile_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-06 04:10 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0157_userprofile_is_guest.py b/zerver/migrations/0157_userprofile_is_guest.py index 9c4356c885..806c66e1e8 100644 --- a/zerver/migrations/0157_userprofile_is_guest.py +++ b/zerver/migrations/0157_userprofile_is_guest.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-20 19:29 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0158_realm_video_chat_provider.py b/zerver/migrations/0158_realm_video_chat_provider.py index 6f7925f508..ddd802fe27 100644 --- a/zerver/migrations/0158_realm_video_chat_provider.py +++ b/zerver/migrations/0158_realm_video_chat_provider.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-10 14:57 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0159_realm_google_hangouts_domain.py b/zerver/migrations/0159_realm_google_hangouts_domain.py index af254df52b..5c8ef50a75 100644 --- a/zerver/migrations/0159_realm_google_hangouts_domain.py +++ b/zerver/migrations/0159_realm_google_hangouts_domain.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-23 16:37 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0160_add_choice_field.py b/zerver/migrations/0160_add_choice_field.py index f0a4ff442b..59d01cc325 100644 --- a/zerver/migrations/0160_add_choice_field.py +++ b/zerver/migrations/0160_add_choice_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-10 04:57 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0161_realm_message_content_delete_limit_seconds.py b/zerver/migrations/0161_realm_message_content_delete_limit_seconds.py index 3cd5ee3261..d1c2ce5dda 100644 --- a/zerver/migrations/0161_realm_message_content_delete_limit_seconds.py +++ b/zerver/migrations/0161_realm_message_content_delete_limit_seconds.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-24 22:12 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0162_change_default_community_topic_editing.py b/zerver/migrations/0162_change_default_community_topic_editing.py index 893225afc3..d6f6a7c6b3 100644 --- a/zerver/migrations/0162_change_default_community_topic_editing.py +++ b/zerver/migrations/0162_change_default_community_topic_editing.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-24 09:10 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0163_remove_userprofile_default_desktop_notifications.py b/zerver/migrations/0163_remove_userprofile_default_desktop_notifications.py index 71b92f6005..d469fa24be 100644 --- a/zerver/migrations/0163_remove_userprofile_default_desktop_notifications.py +++ b/zerver/migrations/0163_remove_userprofile_default_desktop_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-28 20:34 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0164_stream_history_public_to_subscribers.py b/zerver/migrations/0164_stream_history_public_to_subscribers.py index ac47a086d5..38c4b81868 100644 --- a/zerver/migrations/0164_stream_history_public_to_subscribers.py +++ b/zerver/migrations/0164_stream_history_public_to_subscribers.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-28 22:31 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/zerver/migrations/0165_add_date_to_profile_field.py b/zerver/migrations/0165_add_date_to_profile_field.py index 3908ea4a03..43a4bd4342 100644 --- a/zerver/migrations/0165_add_date_to_profile_field.py +++ b/zerver/migrations/0165_add_date_to_profile_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-29 17:24 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0166_add_url_to_profile_field.py b/zerver/migrations/0166_add_url_to_profile_field.py index 246176ab92..d5b1727a95 100644 --- a/zerver/migrations/0166_add_url_to_profile_field.py +++ b/zerver/migrations/0166_add_url_to_profile_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-29 17:25 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0167_custom_profile_fields_sort_order.py b/zerver/migrations/0167_custom_profile_fields_sort_order.py index bf9b71067a..8702655f25 100644 --- a/zerver/migrations/0167_custom_profile_fields_sort_order.py +++ b/zerver/migrations/0167_custom_profile_fields_sort_order.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-08 15:49 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0168_stream_is_web_public.py b/zerver/migrations/0168_stream_is_web_public.py index 1410801aad..6f020c5afe 100644 --- a/zerver/migrations/0168_stream_is_web_public.py +++ b/zerver/migrations/0168_stream_is_web_public.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-27 08:03 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0169_stream_is_announcement_only.py b/zerver/migrations/0169_stream_is_announcement_only.py index 606183d97a..8d25006f3e 100644 --- a/zerver/migrations/0169_stream_is_announcement_only.py +++ b/zerver/migrations/0169_stream_is_announcement_only.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-05-12 04:57 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0170_submessage.py b/zerver/migrations/0170_submessage.py index 751932249a..dfa5a419ca 100644 --- a/zerver/migrations/0170_submessage.py +++ b/zerver/migrations/0170_submessage.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-26 21:54 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0171_userprofile_dense_mode.py b/zerver/migrations/0171_userprofile_dense_mode.py index a7518a9423..5f9978c61b 100644 --- a/zerver/migrations/0171_userprofile_dense_mode.py +++ b/zerver/migrations/0171_userprofile_dense_mode.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-05-24 18:45 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0172_add_user_type_of_custom_profile_field.py b/zerver/migrations/0172_add_user_type_of_custom_profile_field.py index e25fae45fd..aab971821e 100644 --- a/zerver/migrations/0172_add_user_type_of_custom_profile_field.py +++ b/zerver/migrations/0172_add_user_type_of_custom_profile_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-05-08 17:24 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0173_support_seat_based_plans.py b/zerver/migrations/0173_support_seat_based_plans.py index d189a3963e..7d720c6923 100644 --- a/zerver/migrations/0173_support_seat_based_plans.py +++ b/zerver/migrations/0173_support_seat_based_plans.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.13 on 2018-06-28 01:09 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0174_userprofile_delivery_email.py b/zerver/migrations/0174_userprofile_delivery_email.py index f1031e3ba7..4ccdd109d2 100644 --- a/zerver/migrations/0174_userprofile_delivery_email.py +++ b/zerver/migrations/0174_userprofile_delivery_email.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.13 on 2018-07-05 17:57 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py b/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py index 2f68b6c915..a0a66eac26 100644 --- a/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py +++ b/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0176_remove_subscription_notifications.py b/zerver/migrations/0176_remove_subscription_notifications.py index ca0faa6e9e..72f19c9a51 100644 --- a/zerver/migrations/0176_remove_subscription_notifications.py +++ b/zerver/migrations/0176_remove_subscription_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.13 on 2018-07-26 18:38 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py b/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py index 296752c41a..eed9b09652 100644 --- a/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py +++ b/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.13 on 2018-06-14 13:39 -from __future__ import unicode_literals import sys diff --git a/zerver/migrations/0178_rename_to_emails_restricted_to_domains.py b/zerver/migrations/0178_rename_to_emails_restricted_to_domains.py index 861a088e3d..567221c86d 100644 --- a/zerver/migrations/0178_rename_to_emails_restricted_to_domains.py +++ b/zerver/migrations/0178_rename_to_emails_restricted_to_domains.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.13 on 2018-07-27 21:47 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0179_rename_to_digest_emails_enabled.py b/zerver/migrations/0179_rename_to_digest_emails_enabled.py index 19540ff351..5120977c39 100644 --- a/zerver/migrations/0179_rename_to_digest_emails_enabled.py +++ b/zerver/migrations/0179_rename_to_digest_emails_enabled.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-01 10:59 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0180_usermessage_add_active_mobile_push_notification.py b/zerver/migrations/0180_usermessage_add_active_mobile_push_notification.py index e434a12ef1..0b4ffb2f50 100644 --- a/zerver/migrations/0180_usermessage_add_active_mobile_push_notification.py +++ b/zerver/migrations/0180_usermessage_add_active_mobile_push_notification.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-01 23:05 -from __future__ import unicode_literals import bitfield.models from django.db import migrations diff --git a/zerver/migrations/0181_userprofile_change_emojiset.py b/zerver/migrations/0181_userprofile_change_emojiset.py index 12e627eb4b..d50976afc4 100644 --- a/zerver/migrations/0181_userprofile_change_emojiset.py +++ b/zerver/migrations/0181_userprofile_change_emojiset.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0182_set_initial_value_is_private_flag.py b/zerver/migrations/0182_set_initial_value_is_private_flag.py index 1ec308e8dc..e98f7719ed 100644 --- a/zerver/migrations/0182_set_initial_value_is_private_flag.py +++ b/zerver/migrations/0182_set_initial_value_is_private_flag.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import sys from django.db import migrations diff --git a/zerver/migrations/0183_change_custom_field_name_max_length.py b/zerver/migrations/0183_change_custom_field_name_max_length.py index 8471971c59..efafba7db5 100644 --- a/zerver/migrations/0183_change_custom_field_name_max_length.py +++ b/zerver/migrations/0183_change_custom_field_name_max_length.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-16 18:10 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0184_rename_custom_field_types.py b/zerver/migrations/0184_rename_custom_field_types.py index aa491d2f7a..aaa01b777d 100644 --- a/zerver/migrations/0184_rename_custom_field_types.py +++ b/zerver/migrations/0184_rename_custom_field_types.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-15 13:41 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0185_realm_plan_type.py b/zerver/migrations/0185_realm_plan_type.py index b3f7a215a3..3e9935ebcb 100644 --- a/zerver/migrations/0185_realm_plan_type.py +++ b/zerver/migrations/0185_realm_plan_type.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-10 21:36 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0186_userprofile_starred_message_counts.py b/zerver/migrations/0186_userprofile_starred_message_counts.py index 19d875bd9d..890dc2878f 100644 --- a/zerver/migrations/0186_userprofile_starred_message_counts.py +++ b/zerver/migrations/0186_userprofile_starred_message_counts.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-17 06:06 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0187_userprofile_is_billing_admin.py b/zerver/migrations/0187_userprofile_is_billing_admin.py index 33a4d4aa9a..65ac6964be 100644 --- a/zerver/migrations/0187_userprofile_is_billing_admin.py +++ b/zerver/migrations/0187_userprofile_is_billing_admin.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-22 05:45 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0188_userprofile_enable_login_emails.py b/zerver/migrations/0188_userprofile_enable_login_emails.py index e7acf238aa..e2b10f4303 100644 --- a/zerver/migrations/0188_userprofile_enable_login_emails.py +++ b/zerver/migrations/0188_userprofile_enable_login_emails.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-22 09:57 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0189_userprofile_add_some_emojisets.py b/zerver/migrations/0189_userprofile_add_some_emojisets.py index e1c51dc159..1cd485c446 100644 --- a/zerver/migrations/0189_userprofile_add_some_emojisets.py +++ b/zerver/migrations/0189_userprofile_add_some_emojisets.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-28 19:01 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0190_cleanup_pushdevicetoken.py b/zerver/migrations/0190_cleanup_pushdevicetoken.py index 611bad8659..3827da7bd0 100644 --- a/zerver/migrations/0190_cleanup_pushdevicetoken.py +++ b/zerver/migrations/0190_cleanup_pushdevicetoken.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-10-10 22:52 -from __future__ import unicode_literals from django.db import migrations, models @@ -19,6 +17,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='pushdevicetoken', - unique_together=set([('user', 'kind', 'token')]), + unique_together={('user', 'kind', 'token')}, ), ] diff --git a/zerver/migrations/0191_realm_seat_limit.py b/zerver/migrations/0191_realm_seat_limit.py index 7e3e418620..439d3ad164 100644 --- a/zerver/migrations/0191_realm_seat_limit.py +++ b/zerver/migrations/0191_realm_seat_limit.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-11-20 04:43 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0192_customprofilefieldvalue_rendered_value.py b/zerver/migrations/0192_customprofilefieldvalue_rendered_value.py index b74f2ce366..dd058e3770 100644 --- a/zerver/migrations/0192_customprofilefieldvalue_rendered_value.py +++ b/zerver/migrations/0192_customprofilefieldvalue_rendered_value.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-11-14 12:15 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0193_realm_email_address_visibility.py b/zerver/migrations/0193_realm_email_address_visibility.py index 0a3a551b31..6d9546bf0d 100644 --- a/zerver/migrations/0193_realm_email_address_visibility.py +++ b/zerver/migrations/0193_realm_email_address_visibility.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-06 21:36 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0194_userprofile_notification_sound.py b/zerver/migrations/0194_userprofile_notification_sound.py index b19b1b08d4..6661719c19 100644 --- a/zerver/migrations/0194_userprofile_notification_sound.py +++ b/zerver/migrations/0194_userprofile_notification_sound.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-03-12 03:18 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0195_realm_first_visible_message_id.py b/zerver/migrations/0195_realm_first_visible_message_id.py index e444d98422..7ac5c064a0 100644 --- a/zerver/migrations/0195_realm_first_visible_message_id.py +++ b/zerver/migrations/0195_realm_first_visible_message_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-05 14:50 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0196_add_realm_logo_fields.py b/zerver/migrations/0196_add_realm_logo_fields.py index 1f38fa20aa..18cb6e49af 100644 --- a/zerver/migrations/0196_add_realm_logo_fields.py +++ b/zerver/migrations/0196_add_realm_logo_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-16 00:34 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0197_azure_active_directory_auth.py b/zerver/migrations/0197_azure_active_directory_auth.py index 93b3066d26..4c4ff6e57c 100644 --- a/zerver/migrations/0197_azure_active_directory_auth.py +++ b/zerver/migrations/0197_azure_active_directory_auth.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-10-11 00:12 -from __future__ import unicode_literals import bitfield.models from django.db import migrations diff --git a/zerver/migrations/0198_preregistrationuser_invited_as.py b/zerver/migrations/0198_preregistrationuser_invited_as.py index c2d2284053..88ebe8636c 100644 --- a/zerver/migrations/0198_preregistrationuser_invited_as.py +++ b/zerver/migrations/0198_preregistrationuser_invited_as.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-27 17:09 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0199_userstatus.py b/zerver/migrations/0199_userstatus.py index d436fdee26..ffed2ba840 100644 --- a/zerver/migrations/0199_userstatus.py +++ b/zerver/migrations/0199_userstatus.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-17 18:49 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings diff --git a/zerver/migrations/0200_remove_preregistrationuser_invited_as_admin.py b/zerver/migrations/0200_remove_preregistrationuser_invited_as_admin.py index 52fe5491db..1336b672db 100644 --- a/zerver/migrations/0200_remove_preregistrationuser_invited_as_admin.py +++ b/zerver/migrations/0200_remove_preregistrationuser_invited_as_admin.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-30 10:07 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0201_zoom_video_chat.py b/zerver/migrations/0201_zoom_video_chat.py index 68d56239ab..4f5a08f092 100644 --- a/zerver/migrations/0201_zoom_video_chat.py +++ b/zerver/migrations/0201_zoom_video_chat.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2018-12-28 18:00 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0202_add_user_status_info.py b/zerver/migrations/0202_add_user_status_info.py index f780bfb1ca..5cca7d0338 100644 --- a/zerver/migrations/0202_add_user_status_info.py +++ b/zerver/migrations/0202_add_user_status_info.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-19 19:59 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0203_realm_message_content_allowed_in_email_notifications.py b/zerver/migrations/0203_realm_message_content_allowed_in_email_notifications.py index 957632f2b4..8a3665ce5d 100644 --- a/zerver/migrations/0203_realm_message_content_allowed_in_email_notifications.py +++ b/zerver/migrations/0203_realm_message_content_allowed_in_email_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.16 on 2019-01-07 11:46 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0204_remove_realm_billing_fields.py b/zerver/migrations/0204_remove_realm_billing_fields.py index f4debb1089..95c22d889d 100644 --- a/zerver/migrations/0204_remove_realm_billing_fields.py +++ b/zerver/migrations/0204_remove_realm_billing_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-31 22:33 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0205_remove_realmauditlog_requires_billing_update.py b/zerver/migrations/0205_remove_realmauditlog_requires_billing_update.py index b7e2b455ca..f0a13a8320 100644 --- a/zerver/migrations/0205_remove_realmauditlog_requires_billing_update.py +++ b/zerver/migrations/0205_remove_realmauditlog_requires_billing_update.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-02 02:49 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0206_stream_rendered_description.py b/zerver/migrations/0206_stream_rendered_description.py index a6f901ae63..8c92565271 100644 --- a/zerver/migrations/0206_stream_rendered_description.py +++ b/zerver/migrations/0206_stream_rendered_description.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0207_multiuseinvite_invited_as.py b/zerver/migrations/0207_multiuseinvite_invited_as.py index 882fd79610..832edb4e81 100644 --- a/zerver/migrations/0207_multiuseinvite_invited_as.py +++ b/zerver/migrations/0207_multiuseinvite_invited_as.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-06 21:49 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0208_add_realm_night_logo_fields.py b/zerver/migrations/0208_add_realm_night_logo_fields.py index 5370e18c7d..b6b35eabc2 100644 --- a/zerver/migrations/0208_add_realm_night_logo_fields.py +++ b/zerver/migrations/0208_add_realm_night_logo_fields.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-01-15 16:07 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0209_stream_first_message_id.py b/zerver/migrations/0209_stream_first_message_id.py index 34203b253d..55c2bb04ba 100644 --- a/zerver/migrations/0209_stream_first_message_id.py +++ b/zerver/migrations/0209_stream_first_message_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-03-03 13:47 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0209_user_profile_no_empty_password.py b/zerver/migrations/0209_user_profile_no_empty_password.py index 2efda7f9cd..7b8b791fb2 100644 --- a/zerver/migrations/0209_user_profile_no_empty_password.py +++ b/zerver/migrations/0209_user_profile_no_empty_password.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-16 22:48 -from __future__ import unicode_literals from typing import Any, Set, Union diff --git a/zerver/migrations/0210_stream_first_message_id.py b/zerver/migrations/0210_stream_first_message_id.py index 64bc958ab5..06956b80e5 100644 --- a/zerver/migrations/0210_stream_first_message_id.py +++ b/zerver/migrations/0210_stream_first_message_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-25 12:42 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0211_add_users_field_to_scheduled_email.py b/zerver/migrations/0211_add_users_field_to_scheduled_email.py index 90b33dfa78..44c10e4224 100644 --- a/zerver/migrations/0211_add_users_field_to_scheduled_email.py +++ b/zerver/migrations/0211_add_users_field_to_scheduled_email.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-03-14 01:11 -from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models diff --git a/zerver/migrations/0212_make_stream_email_token_unique.py b/zerver/migrations/0212_make_stream_email_token_unique.py index 67561fae74..9848bbe8b1 100644 --- a/zerver/migrations/0212_make_stream_email_token_unique.py +++ b/zerver/migrations/0212_make_stream_email_token_unique.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-03-17 08:37 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0213_realm_digest_weekday.py b/zerver/migrations/0213_realm_digest_weekday.py index 4ef00af198..95e1d5f958 100644 --- a/zerver/migrations/0213_realm_digest_weekday.py +++ b/zerver/migrations/0213_realm_digest_weekday.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-03-28 03:44 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0214_realm_invite_to_stream_policy.py b/zerver/migrations/0214_realm_invite_to_stream_policy.py index de85b21b46..95829b0775 100644 --- a/zerver/migrations/0214_realm_invite_to_stream_policy.py +++ b/zerver/migrations/0214_realm_invite_to_stream_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-04-29 05:29 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0215_realm_avatar_changes_disabled.py b/zerver/migrations/0215_realm_avatar_changes_disabled.py index fd33e3541e..4b85d68e37 100644 --- a/zerver/migrations/0215_realm_avatar_changes_disabled.py +++ b/zerver/migrations/0215_realm_avatar_changes_disabled.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-04-23 02:47 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0216_add_create_stream_policy.py b/zerver/migrations/0216_add_create_stream_policy.py index 59fc604dfc..d9f3c61db7 100644 --- a/zerver/migrations/0216_add_create_stream_policy.py +++ b/zerver/migrations/0216_add_create_stream_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-06 13:15 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0217_migrate_create_stream_policy.py b/zerver/migrations/0217_migrate_create_stream_policy.py index fbea12ba9e..174ac898bc 100644 --- a/zerver/migrations/0217_migrate_create_stream_policy.py +++ b/zerver/migrations/0217_migrate_create_stream_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-06 13:15 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0218_remove_create_stream_by_admins_only.py b/zerver/migrations/0218_remove_create_stream_by_admins_only.py index 4a840203e4..d0094a7e98 100644 --- a/zerver/migrations/0218_remove_create_stream_by_admins_only.py +++ b/zerver/migrations/0218_remove_create_stream_by_admins_only.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-06 13:15 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py b/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py index 90590c36f1..df3c6afc85 100644 --- a/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py +++ b/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-08 05:42 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0220_subscription_notification_settings.py b/zerver/migrations/0220_subscription_notification_settings.py index 8ff91849ee..3cb0761bb5 100644 --- a/zerver/migrations/0220_subscription_notification_settings.py +++ b/zerver/migrations/0220_subscription_notification_settings.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-12 17:41 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0221_subscription_notifications_data_migration.py b/zerver/migrations/0221_subscription_notifications_data_migration.py index 005d19f4fb..b55f39bd02 100644 --- a/zerver/migrations/0221_subscription_notifications_data_migration.py +++ b/zerver/migrations/0221_subscription_notifications_data_migration.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-13 20:13 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0222_userprofile_fluid_layout_width.py b/zerver/migrations/0222_userprofile_fluid_layout_width.py index 0acbbd866f..12e4ee7c75 100644 --- a/zerver/migrations/0222_userprofile_fluid_layout_width.py +++ b/zerver/migrations/0222_userprofile_fluid_layout_width.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-04-15 17:10 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0223_rename_to_is_muted.py b/zerver/migrations/0223_rename_to_is_muted.py index a03e598dab..37565ec675 100644 --- a/zerver/migrations/0223_rename_to_is_muted.py +++ b/zerver/migrations/0223_rename_to_is_muted.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-10 16:04 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0224_alter_field_realm_video_chat_provider.py b/zerver/migrations/0224_alter_field_realm_video_chat_provider.py index 11b82e6ba2..0a5f40e1d3 100644 --- a/zerver/migrations/0224_alter_field_realm_video_chat_provider.py +++ b/zerver/migrations/0224_alter_field_realm_video_chat_provider.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-09 06:54 -from __future__ import unicode_literals from typing import Any, Dict, Optional @@ -12,15 +10,15 @@ from django.db.migrations.state import StateApps # migration was merged, since future should not impact the migration. VIDEO_CHAT_PROVIDERS = { 'jitsi_meet': { - 'name': u"Jitsi", + 'name': "Jitsi", 'id': 1 }, 'google_hangouts': { - 'name': u"Google Hangouts", + 'name': "Google Hangouts", 'id': 2 }, 'zoom': { - 'name': u"Zoom", + 'name': "Zoom", 'id': 3 } } diff --git a/zerver/migrations/0225_archived_reaction_model.py b/zerver/migrations/0225_archived_reaction_model.py index 7befd380b5..990f1f3e04 100644 --- a/zerver/migrations/0225_archived_reaction_model.py +++ b/zerver/migrations/0225_archived_reaction_model.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-29 13:28 -from __future__ import unicode_literals import django.db.models.deletion import django.utils.timezone @@ -32,6 +30,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='archivedreaction', - unique_together=set([('user_profile', 'message', 'emoji_name')]), + unique_together={('user_profile', 'message', 'emoji_name')}, ), ] diff --git a/zerver/migrations/0226_archived_submessage_model.py b/zerver/migrations/0226_archived_submessage_model.py index c6d320e1f2..5cc45c2ca2 100644 --- a/zerver/migrations/0226_archived_submessage_model.py +++ b/zerver/migrations/0226_archived_submessage_model.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-29 13:57 -from __future__ import unicode_literals import django.db.models.deletion import django.utils.timezone diff --git a/zerver/migrations/0227_inline_url_embed_preview_default_off.py b/zerver/migrations/0227_inline_url_embed_preview_default_off.py index ba24ba4a37..654277f6b9 100644 --- a/zerver/migrations/0227_inline_url_embed_preview_default_off.py +++ b/zerver/migrations/0227_inline_url_embed_preview_default_off.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-31 02:33 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0228_userprofile_demote_inactive_streams.py b/zerver/migrations/0228_userprofile_demote_inactive_streams.py index dadcfdb10c..30ac8d84fa 100644 --- a/zerver/migrations/0228_userprofile_demote_inactive_streams.py +++ b/zerver/migrations/0228_userprofile_demote_inactive_streams.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-03-08 19:50 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0229_stream_message_retention_days.py b/zerver/migrations/0229_stream_message_retention_days.py index ad98708a43..649c1a43ef 100644 --- a/zerver/migrations/0229_stream_message_retention_days.py +++ b/zerver/migrations/0229_stream_message_retention_days.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-06-05 14:21 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0230_rename_to_enable_stream_audible_notifications.py b/zerver/migrations/0230_rename_to_enable_stream_audible_notifications.py index 08b60bfb39..b9f4ba340a 100644 --- a/zerver/migrations/0230_rename_to_enable_stream_audible_notifications.py +++ b/zerver/migrations/0230_rename_to_enable_stream_audible_notifications.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-06-12 06:41 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0231_add_archive_transaction_model.py b/zerver/migrations/0231_add_archive_transaction_model.py index 03e093677b..7fe187e909 100644 --- a/zerver/migrations/0231_add_archive_transaction_model.py +++ b/zerver/migrations/0231_add_archive_transaction_model.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-06-23 21:20 -from __future__ import unicode_literals import django.db.models.deletion import django.utils.timezone diff --git a/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py b/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py index 36c4ab005c..8ca3b1a776 100644 --- a/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py +++ b/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import django.db.models.deletion from django.db import migrations, models diff --git a/zerver/migrations/0233_userprofile_avatar_hash.py b/zerver/migrations/0233_userprofile_avatar_hash.py index d2d7b67d14..1f04c64050 100644 --- a/zerver/migrations/0233_userprofile_avatar_hash.py +++ b/zerver/migrations/0233_userprofile_avatar_hash.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-06-28 22:38 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0234_add_external_account_custom_profile_field.py b/zerver/migrations/0234_add_external_account_custom_profile_field.py index 014d3f2f00..e18b7a0b42 100644 --- a/zerver/migrations/0234_add_external_account_custom_profile_field.py +++ b/zerver/migrations/0234_add_external_account_custom_profile_field.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-05-30 08:18 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0235_userprofile_desktop_icon_count_display.py b/zerver/migrations/0235_userprofile_desktop_icon_count_display.py index 717fc1ea9c..8ff03ae5b1 100644 --- a/zerver/migrations/0235_userprofile_desktop_icon_count_display.py +++ b/zerver/migrations/0235_userprofile_desktop_icon_count_display.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-06-29 18:22 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0236_remove_illegal_characters_email_full.py b/zerver/migrations/0236_remove_illegal_characters_email_full.py index 5d04572756..29e4699bb4 100644 --- a/zerver/migrations/0236_remove_illegal_characters_email_full.py +++ b/zerver/migrations/0236_remove_illegal_characters_email_full.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-06-28 21:45 -from __future__ import unicode_literals from unicodedata import category diff --git a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py index 148a37668c..7e4bdf4747 100644 --- a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py +++ b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0238_usermessage_bigint_id.py b/zerver/migrations/0238_usermessage_bigint_id.py index e078c6d62f..9c2536ee58 100644 --- a/zerver/migrations/0238_usermessage_bigint_id.py +++ b/zerver/migrations/0238_usermessage_bigint_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-22 22:02 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py b/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py index 98b3826165..c89c48698d 100644 --- a/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py +++ b/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-21 21:43 -from __future__ import unicode_literals import time diff --git a/zerver/migrations/0240_usermessage_migrate_bigint_id_into_id.py b/zerver/migrations/0240_usermessage_migrate_bigint_id_into_id.py index 7e931ab4ca..3f64b7b2bc 100644 --- a/zerver/migrations/0240_usermessage_migrate_bigint_id_into_id.py +++ b/zerver/migrations/0240_usermessage_migrate_bigint_id_into_id.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-23 21:03 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0241_usermessage_bigint_id_migration_finalize.py b/zerver/migrations/0241_usermessage_bigint_id_migration_finalize.py index fe0a2c2feb..fb719f6100 100644 --- a/zerver/migrations/0241_usermessage_bigint_id_migration_finalize.py +++ b/zerver/migrations/0241_usermessage_bigint_id_migration_finalize.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-23 22:24 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0242_fix_bot_email_property.py b/zerver/migrations/0242_fix_bot_email_property.py index c4dba99dd6..2134765223 100644 --- a/zerver/migrations/0242_fix_bot_email_property.py +++ b/zerver/migrations/0242_fix_bot_email_property.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-09-23 20:39 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0243_message_add_date_sent_column.py b/zerver/migrations/0243_message_add_date_sent_column.py index a4c475e935..5dab9c9ae7 100644 --- a/zerver/migrations/0243_message_add_date_sent_column.py +++ b/zerver/migrations/0243_message_add_date_sent_column.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-28 00:47 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py b/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py index 4952f327af..4cfb7e8aaa 100644 --- a/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py +++ b/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import time from django.db import connection, migrations diff --git a/zerver/migrations/0245_message_date_sent_finalize_part1.py b/zerver/migrations/0245_message_date_sent_finalize_part1.py index 4f7abb842a..8fbc090758 100644 --- a/zerver/migrations/0245_message_date_sent_finalize_part1.py +++ b/zerver/migrations/0245_message_date_sent_finalize_part1.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-23 21:03 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0246_message_date_sent_finalize_part2.py b/zerver/migrations/0246_message_date_sent_finalize_part2.py index 5cd857b157..93f37b0527 100644 --- a/zerver/migrations/0246_message_date_sent_finalize_part2.py +++ b/zerver/migrations/0246_message_date_sent_finalize_part2.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-08-28 19:48 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0247_realmauditlog_event_type_to_int.py b/zerver/migrations/0247_realmauditlog_event_type_to_int.py index 5a2b786499..e090c9d37e 100644 --- a/zerver/migrations/0247_realmauditlog_event_type_to_int.py +++ b/zerver/migrations/0247_realmauditlog_event_type_to_int.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-02 16:48 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0248_userprofile_role_start.py b/zerver/migrations/0248_userprofile_role_start.py index 2ee50096fe..1c556aeb0f 100644 --- a/zerver/migrations/0248_userprofile_role_start.py +++ b/zerver/migrations/0248_userprofile_role_start.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-03 22:27 -from __future__ import unicode_literals from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0249_userprofile_role_finish.py b/zerver/migrations/0249_userprofile_role_finish.py index aab95ed7a1..0bfe4dc37f 100644 --- a/zerver/migrations/0249_userprofile_role_finish.py +++ b/zerver/migrations/0249_userprofile_role_finish.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-03 23:40 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0250_saml_auth.py b/zerver/migrations/0250_saml_auth.py index 871450abb9..8c199c9aa8 100644 --- a/zerver/migrations/0250_saml_auth.py +++ b/zerver/migrations/0250_saml_auth.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.23 on 2019-09-19 00:50 -from __future__ import unicode_literals import bitfield.models from django.db import migrations diff --git a/zerver/migrations/0251_prereg_user_add_full_name.py b/zerver/migrations/0251_prereg_user_add_full_name.py index 39e6c5abc3..27faadd309 100644 --- a/zerver/migrations/0251_prereg_user_add_full_name.py +++ b/zerver/migrations/0251_prereg_user_add_full_name.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.25 on 2019-10-31 20:31 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0252_realm_user_group_edit_policy.py b/zerver/migrations/0252_realm_user_group_edit_policy.py index d6e6226668..25a1e61ee1 100644 --- a/zerver/migrations/0252_realm_user_group_edit_policy.py +++ b/zerver/migrations/0252_realm_user_group_edit_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-16 22:48 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0253_userprofile_wildcard_mentions_notify.py b/zerver/migrations/0253_userprofile_wildcard_mentions_notify.py index 3f85f37c6e..b04e693f80 100644 --- a/zerver/migrations/0253_userprofile_wildcard_mentions_notify.py +++ b/zerver/migrations/0253_userprofile_wildcard_mentions_notify.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.25 on 2019-11-06 23:43 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0254_merge_0209_0253.py b/zerver/migrations/0254_merge_0209_0253.py index eefcc7d54d..1be48a946e 100644 --- a/zerver/migrations/0254_merge_0209_0253.py +++ b/zerver/migrations/0254_merge_0209_0253.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2019-11-21 01:47 -from __future__ import unicode_literals from typing import Any, List diff --git a/zerver/migrations/0255_userprofile_stream_add_recipient_column.py b/zerver/migrations/0255_userprofile_stream_add_recipient_column.py index 881c5d49e9..9e0e9e0509 100644 --- a/zerver/migrations/0255_userprofile_stream_add_recipient_column.py +++ b/zerver/migrations/0255_userprofile_stream_add_recipient_column.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2019-11-27 21:15 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py b/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py index 90c6a963d9..dd7da08e6d 100644 --- a/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py +++ b/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0257_fix_has_link_attribute.py b/zerver/migrations/0257_fix_has_link_attribute.py index 06304b997f..d2cd0b98ab 100644 --- a/zerver/migrations/0257_fix_has_link_attribute.py +++ b/zerver/migrations/0257_fix_has_link_attribute.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-07 05:25 -from __future__ import unicode_literals import time diff --git a/zerver/migrations/0258_enable_online_push_notifications_default.py b/zerver/migrations/0258_enable_online_push_notifications_default.py index e8b9a58053..8b5ea521a8 100644 --- a/zerver/migrations/0258_enable_online_push_notifications_default.py +++ b/zerver/migrations/0258_enable_online_push_notifications_default.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2019-12-11 00:41 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0259_missedmessageemailaddress.py b/zerver/migrations/0259_missedmessageemailaddress.py index 706864c6c8..401621d5ce 100644 --- a/zerver/migrations/0259_missedmessageemailaddress.py +++ b/zerver/migrations/0259_missedmessageemailaddress.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-06 01:23 -from __future__ import unicode_literals import django.db.models.deletion import django.utils.timezone diff --git a/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py b/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py index f782cd08e8..286b0de675 100644 --- a/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py +++ b/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.core.exceptions import ObjectDoesNotExist from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0261_realm_private_message_policy.py b/zerver/migrations/0261_realm_private_message_policy.py index c2d5fcd03e..33a056a81e 100644 --- a/zerver/migrations/0261_realm_private_message_policy.py +++ b/zerver/migrations/0261_realm_private_message_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-08 00:32 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0262_mutedtopic_date_muted.py b/zerver/migrations/0262_mutedtopic_date_muted.py index 9f34e24d9c..b3014ddcc7 100644 --- a/zerver/migrations/0262_mutedtopic_date_muted.py +++ b/zerver/migrations/0262_mutedtopic_date_muted.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-17 15:26 -from __future__ import unicode_literals import datetime from django.db import migrations, models diff --git a/zerver/migrations/0263_stream_stream_post_policy.py b/zerver/migrations/0263_stream_stream_post_policy.py index 16c41067a6..6cf2945ef9 100644 --- a/zerver/migrations/0263_stream_stream_post_policy.py +++ b/zerver/migrations/0263_stream_stream_post_policy.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-27 22:03 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zerver/migrations/0264_migrate_is_announcement_only.py b/zerver/migrations/0264_migrate_is_announcement_only.py index a34c319609..611b464422 100644 --- a/zerver/migrations/0264_migrate_is_announcement_only.py +++ b/zerver/migrations/0264_migrate_is_announcement_only.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-25 23:47 -from __future__ import unicode_literals from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor diff --git a/zerver/migrations/0265_remove_stream_is_announcement_only.py b/zerver/migrations/0265_remove_stream_is_announcement_only.py index a42e97915c..9032565e21 100644 --- a/zerver/migrations/0265_remove_stream_is_announcement_only.py +++ b/zerver/migrations/0265_remove_stream_is_announcement_only.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-27 22:05 -from __future__ import unicode_literals from django.db import migrations diff --git a/zerver/migrations/0266_userpresence_realm.py b/zerver/migrations/0266_userpresence_realm.py index 3787c9171b..1937e5339c 100644 --- a/zerver/migrations/0266_userpresence_realm.py +++ b/zerver/migrations/0266_userpresence_realm.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.28 on 2020-02-08 20:19 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion diff --git a/zerver/migrations/0267_backfill_userpresence_realm_id.py b/zerver/migrations/0267_backfill_userpresence_realm_id.py index adcf830a6c..bb49e21eb7 100644 --- a/zerver/migrations/0267_backfill_userpresence_realm_id.py +++ b/zerver/migrations/0267_backfill_userpresence_realm_id.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/migrations/0268_add_userpresence_realm_timestamp_index.py b/zerver/migrations/0268_add_userpresence_realm_timestamp_index.py index 77ce8d14a2..2eeb6fe187 100644 --- a/zerver/migrations/0268_add_userpresence_realm_timestamp_index.py +++ b/zerver/migrations/0268_add_userpresence_realm_timestamp_index.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.28 on 2020-02-08 20:34 -from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion @@ -20,6 +18,6 @@ class Migration(migrations.Migration): ), migrations.AlterIndexTogether( name='userpresence', - index_together=set([('realm', 'timestamp')]), + index_together={('realm', 'timestamp')}, ), ] diff --git a/zerver/migrations/0269_gitlab_auth.py b/zerver/migrations/0269_gitlab_auth.py index d8b20bf82c..ee3eb38236 100644 --- a/zerver/migrations/0269_gitlab_auth.py +++ b/zerver/migrations/0269_gitlab_auth.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2020-01-29 17:30 -from __future__ import unicode_literals import bitfield.models from django.db import migrations diff --git a/zerver/migrations/0271_huddle_set_recipient_column_values.py b/zerver/migrations/0271_huddle_set_recipient_column_values.py index 493da42932..a669d243bf 100644 --- a/zerver/migrations/0271_huddle_set_recipient_column_values.py +++ b/zerver/migrations/0271_huddle_set_recipient_column_values.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations diff --git a/zerver/models.py b/zerver/models.py index a8caf02fc6..1cc6b3c6b9 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -106,10 +106,10 @@ def flush_per_request_caches() -> None: per_request_realm_filters_cache = {} def get_realm_emoji_cache_key(realm: 'Realm') -> str: - return u'realm_emoji:%s' % (realm.id,) + return 'realm_emoji:%s' % (realm.id,) def get_active_realm_emoji_cache_key(realm: 'Realm') -> str: - return u'active_realm_emoji:%s' % (realm.id,) + return 'active_realm_emoji:%s' % (realm.id,) # This simple call-once caching saves ~500us in auth_enabled_helper, # which is a significant optimization for common_context. Note that @@ -134,13 +134,13 @@ class Realm(models.Model): MAX_GOOGLE_HANGOUTS_DOMAIN_LENGTH = 255 # This is just the maximum domain length by RFC INVITES_STANDARD_REALM_DAILY_MAX = 3000 MESSAGE_VISIBILITY_LIMITED = 10000 - AUTHENTICATION_FLAGS = [u'Google', u'Email', u'GitHub', u'LDAP', u'Dev', - u'RemoteUser', u'AzureAD', u'SAML', u'GitLab'] + AUTHENTICATION_FLAGS = ['Google', 'Email', 'GitHub', 'LDAP', 'Dev', + 'RemoteUser', 'AzureAD', 'SAML', 'GitLab'] SUBDOMAIN_FOR_ROOT_DOMAIN = '' # User-visible display name and description used on e.g. the organization homepage name = models.CharField(max_length=MAX_REALM_NAME_LENGTH, null=True) # type: Optional[str] - description = models.TextField(default=u"") # type: str + description = models.TextField(default="") # type: str # A short, identifier-like name for the organization. Used in subdomains; # e.g. on a server at example.com, an org with string_id `foo` is reached @@ -250,10 +250,10 @@ class Realm(models.Model): # Defaults for new users default_twenty_four_hour_time = models.BooleanField(default=False) # type: bool - default_language = models.CharField(default=u'en', max_length=MAX_LANGUAGE_ID_LENGTH) # type: str + default_language = models.CharField(default='en', max_length=MAX_LANGUAGE_ID_LENGTH) # type: str - DEFAULT_NOTIFICATION_STREAM_NAME = u'general' - INITIAL_PRIVATE_STREAM_NAME = u'core team' + DEFAULT_NOTIFICATION_STREAM_NAME = 'general' + INITIAL_PRIVATE_STREAM_NAME = 'core team' STREAM_EVENTS_NOTIFICATION_TOPIC = _('stream events') notifications_stream = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE) # type: Optional[Stream] signup_notifications_stream = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE) # type: Optional[Stream] @@ -306,15 +306,15 @@ class Realm(models.Model): 'id': 0 }, 'jitsi_meet': { - 'name': u"Jitsi Meet", + 'name': "Jitsi Meet", 'id': 1 }, 'google_hangouts': { - 'name': u"Google Hangouts", + 'name': "Google Hangouts", 'id': 2 }, 'zoom': { - 'name': u"Zoom", + 'name': "Zoom", 'id': 3 } } @@ -368,8 +368,8 @@ class Realm(models.Model): DIGEST_WEEKDAY_VALUES = [0, 1, 2, 3, 4, 5, 6] # Icon is the square mobile icon. - ICON_FROM_GRAVATAR = u'G' - ICON_UPLOADED = u'U' + ICON_FROM_GRAVATAR = 'G' + ICON_UPLOADED = 'U' ICON_SOURCES = ( (ICON_FROM_GRAVATAR, 'Hosted by Gravatar'), (ICON_UPLOADED, 'Uploaded by administrator'), @@ -379,8 +379,8 @@ class Realm(models.Model): icon_version = models.PositiveSmallIntegerField(default=1) # type: int # Logo is the horizontal logo we show in top-left of webapp navbar UI. - LOGO_DEFAULT = u'D' - LOGO_UPLOADED = u'U' + LOGO_DEFAULT = 'D' + LOGO_UPLOADED = 'U' LOGO_SOURCES = ( (LOGO_DEFAULT, 'Default to Zulip'), (LOGO_UPLOADED, 'Uploaded by administrator'), @@ -679,7 +679,7 @@ class RealmFilter(models.Model): return "" % (self.realm.string_id, self.pattern, self.url_format_string) def get_realm_filters_cache_key(realm_id: int) -> str: - return u'%s:all_realm_filters:%s' % (cache.KEY_PREFIX, realm_id,) + return '%s:all_realm_filters:%s' % (cache.KEY_PREFIX, realm_id,) # We have a per-process cache to avoid doing 1000 remote cache queries during page load per_request_realm_filters_cache = {} # type: Dict[int, List[Tuple[str, str, int]]] @@ -903,7 +903,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): realm_name_in_notifications = models.BooleanField(default=False) # type: bool # Words that trigger a mention for this user, formatted as a json-serialized list of strings - alert_words = models.TextField(default=u'[]') # type: str + alert_words = models.TextField(default='[]') # type: str # Used for rate-limiting certain automated messages generated by bots last_reminder = models.DateTimeField(default=None, null=True) # type: Optional[datetime.datetime] @@ -913,7 +913,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): BOT_OWNER_STREAM_ALERT_WAITPERIOD = 1 # API rate limits, formatted as a comma-separated list of range:max pairs - rate_limits = models.CharField(default=u"", max_length=100) # type: str + rate_limits = models.CharField(default="", max_length=100) # type: str # Hours to wait before sending another email to a user EMAIL_REMINDER_WAITPERIOD = 24 @@ -928,7 +928,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): left_side_userlist = models.BooleanField(default=False) # type: bool # display settings - default_language = models.CharField(default=u'en', max_length=MAX_LANGUAGE_ID_LENGTH) # type: str + default_language = models.CharField(default='en', max_length=MAX_LANGUAGE_ID_LENGTH) # type: str dense_mode = models.BooleanField(default=True) # type: bool fluid_layout_width = models.BooleanField(default=False) # type: bool high_contrast_mode = models.BooleanField(default=False) # type: bool @@ -959,7 +959,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): # In Django, the convention is to use an empty string instead of NULL/None # for text-based fields. For more information, see # https://docs.djangoproject.com/en/1.10/ref/models/fields/#django.db.models.Field.null. - timezone = models.CharField(max_length=40, default=u'') # type: str + timezone = models.CharField(max_length=40, default='') # type: str # Emojisets GOOGLE_EMOJISET = 'google' @@ -972,8 +972,8 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): (TEXT_EMOJISET, "Plain text")) emojiset = models.CharField(default=GOOGLE_BLOB_EMOJISET, choices=EMOJISET_CHOICES, max_length=20) # type: str - AVATAR_FROM_GRAVATAR = u'G' - AVATAR_FROM_USER = u'U' + AVATAR_FROM_GRAVATAR = 'G' + AVATAR_FROM_USER = 'U' AVATAR_SOURCES = ( (AVATAR_FROM_GRAVATAR, 'Hosted by Gravatar'), (AVATAR_FROM_USER, 'Uploaded by user'), @@ -982,9 +982,9 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): avatar_version = models.PositiveSmallIntegerField(default=1) # type: int avatar_hash = models.CharField(null=True, max_length=64) # type: Optional[str] - TUTORIAL_WAITING = u'W' - TUTORIAL_STARTED = u'S' - TUTORIAL_FINISHED = u'F' + TUTORIAL_WAITING = 'W' + TUTORIAL_STARTED = 'S' + TUTORIAL_FINISHED = 'F' TUTORIAL_STATES = ((TUTORIAL_WAITING, "Waiting"), (TUTORIAL_STARTED, "Started"), (TUTORIAL_FINISHED, "Finished")) @@ -994,7 +994,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin): # [("step 1", true), ("step 2", false)] # where the second element of each tuple is if the step has been # completed. - onboarding_steps = models.TextField(default=u'[]') # type: str + onboarding_steps = models.TextField(default='[]') # type: str objects = UserManager() # type: UserManager @@ -1198,7 +1198,7 @@ class UserGroup(models.Model): name = models.CharField(max_length=100) members = models.ManyToManyField(UserProfile, through='UserGroupMembership') realm = models.ForeignKey(Realm, on_delete=CASCADE) - description = models.TextField(default=u'') # type: str + description = models.TextField(default='') # type: str class Meta: unique_together = (('realm', 'name'),) @@ -1341,8 +1341,8 @@ class Stream(models.Model): realm = models.ForeignKey(Realm, db_index=True, on_delete=CASCADE) # type: Realm date_created = models.DateTimeField(default=timezone_now) # type: datetime.datetime deactivated = models.BooleanField(default=False) # type: bool - description = models.CharField(max_length=MAX_DESCRIPTION_LENGTH, default=u'') # type: str - rendered_description = models.TextField(default=u'') # type: str + description = models.CharField(max_length=MAX_DESCRIPTION_LENGTH, default='') # type: str + rendered_description = models.TextField(default='') # type: str # Foreign key to the Recipient object for STREAM type messages to this stream. recipient = models.ForeignKey(Recipient, null=True, on_delete=models.SET_NULL) @@ -1483,7 +1483,7 @@ def get_client(name: str) -> Client: return get_client_cache[cache_name] def get_client_cache_key(name: str) -> str: - return u'get_client:%s' % (make_safe_digest(name),) + return 'get_client:%s' % (make_safe_digest(name),) @cache_with_key(get_client_cache_key, timeout=3600*24*7) def get_client_remote_cache(name: str) -> Client: @@ -1782,9 +1782,9 @@ class AbstractReaction(models.Model): # field encodes which one the user selected. emoji_name = models.TextField() # type: str - UNICODE_EMOJI = u'unicode_emoji' - REALM_EMOJI = u'realm_emoji' - ZULIP_EXTRA_EMOJI = u'zulip_extra_emoji' + UNICODE_EMOJI = 'unicode_emoji' + REALM_EMOJI = 'realm_emoji' + ZULIP_EXTRA_EMOJI = 'zulip_extra_emoji' REACTION_TYPES = ((UNICODE_EMOJI, _("Unicode emoji")), (REALM_EMOJI, _("Custom emoji")), (ZULIP_EXTRA_EMOJI, _("Zulip extra emoji"))) @@ -2070,7 +2070,7 @@ class Subscription(models.Model): # Whether this user had muted this stream. is_muted = models.NullBooleanField(default=False) # type: Optional[bool] - DEFAULT_STREAM_COLOR = u"#c2c2c2" + DEFAULT_STREAM_COLOR = "#c2c2c2" color = models.CharField(max_length=10, default=DEFAULT_STREAM_COLOR) # type: str pin_to_top = models.BooleanField(default=False) # type: bool @@ -2282,7 +2282,7 @@ def get_huddle_hash(id_list: List[int]) -> str: return make_safe_digest(hash_key) def huddle_hash_cache_key(huddle_hash: str) -> str: - return u"huddle_by_hash:%s" % (huddle_hash,) + return "huddle_by_hash:%s" % (huddle_hash,) def get_huddle(id_list: List[int]) -> Huddle: huddle_hash = get_huddle_hash(id_list) @@ -2423,7 +2423,7 @@ class DefaultStreamGroup(models.Model): name = models.CharField(max_length=MAX_NAME_LENGTH, db_index=True) # type: str realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm streams = models.ManyToManyField('Stream') # type: Manager - description = models.CharField(max_length=1024, default=u'') # type: str + description = models.CharField(max_length=1024, default='') # type: str class Meta: unique_together = ("realm", "name") @@ -2777,8 +2777,8 @@ class CustomProfileFieldValue(models.Model): # Interfaces for services # They provide additional functionality like parsing message to obtain query url, data to be sent to url, # and parsing the response. -GENERIC_INTERFACE = u'GenericService' -SLACK_INTERFACE = u'SlackOutgoingWebhookService' +GENERIC_INTERFACE = 'GenericService' +SLACK_INTERFACE = 'SlackOutgoingWebhookService' # A Service corresponds to either an outgoing webhook bot or an embedded bot. # The type of Service is determined by the bot_type field of the referenced @@ -2844,7 +2844,7 @@ class BotConfigData(models.Model): key = models.TextField(db_index=True) # type: str value = models.TextField() # type: str - class Meta(object): + class Meta: unique_together = ("bot_profile", "key") class InvalidFakeEmailDomain(Exception): diff --git a/zerver/openapi/test_curl_examples.py b/zerver/openapi/test_curl_examples.py index 68e29f7c7e..f0fc579017 100644 --- a/zerver/openapi/test_curl_examples.py +++ b/zerver/openapi/test_curl_examples.py @@ -18,7 +18,7 @@ def test_generated_curl_examples_for_success(client: Client) -> None: api_url=realm.uri + "/api")]) for file_name in glob.glob("templates/zerver/api/*.md"): - documentation_lines = open(file_name, "r").readlines() + documentation_lines = open(file_name).readlines() for line in documentation_lines: # A typical example from the markdown source looks like this: # {generate_code_example(curl, ...} diff --git a/zerver/tests/test_alert_words.py b/zerver/tests/test_alert_words.py index a7ee90351e..44e86e6c1e 100644 --- a/zerver/tests/test_alert_words.py +++ b/zerver/tests/test_alert_words.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from zerver.lib.alert_words import ( add_user_alert_words, alert_words_in_realm, @@ -23,7 +21,7 @@ from zerver.models import ( import ujson class AlertWordTests(ZulipTestCase): - interesting_alert_word_list = ['alert', 'multi-word word', u'☃'] + interesting_alert_word_list = ['alert', 'multi-word word', '☃'] def test_internal_endpoint(self) -> None: user_name = "cordelia" diff --git a/zerver/tests/test_archive.py b/zerver/tests/test_archive.py index 2a2be4b98d..6336c14720 100644 --- a/zerver/tests/test_archive.py +++ b/zerver/tests/test_archive.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.http import HttpResponse from zerver.lib.test_classes import ZulipTestCase from zerver.lib.actions import do_change_stream_web_public diff --git a/zerver/tests/test_attachments.py b/zerver/tests/test_attachments.py index cd65266cfc..84fa537d71 100644 --- a/zerver/tests/test_attachments.py +++ b/zerver/tests/test_attachments.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mock from typing import Any diff --git a/zerver/tests/test_audit_log.py b/zerver/tests/test_audit_log.py index bfdf9985fa..439070cbb5 100644 --- a/zerver/tests/test_audit_log.py +++ b/zerver/tests/test_audit_log.py @@ -91,7 +91,7 @@ class TestRealmAuditLog(ZulipTestCase): def test_change_avatar_source(self) -> None: now = timezone_now() user = self.example_user('hamlet') - avatar_source = u'G' + avatar_source = 'G' do_change_avatar_fields(user, avatar_source) self.assertEqual(RealmAuditLog.objects.filter(event_type=RealmAuditLog.USER_AVATAR_SOURCE_CHANGED, event_time__gte=now).count(), 1) diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index 300a5f0e7e..40e6089b42 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from bs4 import BeautifulSoup from django.conf import settings from django.contrib.auth import authenticate @@ -3922,7 +3921,7 @@ class TestMaybeSendToRegistration(ZulipTestCase): result = self.client_get(result.url) self.assert_in_response('action="/accounts/register/"', result) - self.assert_in_response('value="{0}" name="key"'.format(confirmation_key), result) + self.assert_in_response('value="{}" name="key"'.format(confirmation_key), result) def test_sso_only_when_preregistration_user_exists(self) -> None: rf = RequestFactory() @@ -3957,7 +3956,7 @@ class TestAdminSetBackends(ZulipTestCase): # Log in as admin self.login('iago') result = self.client_patch("/json/realm", { - 'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True})}) + 'authentication_methods': ujson.dumps({'Email': False, 'Dev': True})}) self.assert_json_success(result) realm = get_realm('zulip') self.assertFalse(password_auth_enabled(realm)) @@ -3967,7 +3966,7 @@ class TestAdminSetBackends(ZulipTestCase): # Log in as admin self.login('iago') result = self.client_patch("/json/realm", { - 'authentication_methods': ujson.dumps({u'Email': False, u'Dev': False})}) + 'authentication_methods': ujson.dumps({'Email': False, 'Dev': False})}) self.assert_json_error(result, 'At least one authentication method must be enabled.') realm = get_realm('zulip') self.assertTrue(password_auth_enabled(realm)) @@ -3978,7 +3977,7 @@ class TestAdminSetBackends(ZulipTestCase): self.login('iago') # Set some supported and unsupported backends result = self.client_patch("/json/realm", { - 'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True, u'GitHub': False})}) + 'authentication_methods': ujson.dumps({'Email': False, 'Dev': True, 'GitHub': False})}) self.assert_json_success(result) realm = get_realm('zulip') # Check that unsupported backend is not enabled @@ -3992,7 +3991,7 @@ class EmailValidatorTestCase(ZulipTestCase): def test_invalid_email(self) -> None: with self.assertRaises(JsonableError): - validate_login_email(u'hamlet') + validate_login_email('hamlet') def test_validate_email(self) -> None: inviter = self.example_user('hamlet') diff --git a/zerver/tests/test_bots.py b/zerver/tests/test_bots.py index 76552df9bb..bdc2993115 100644 --- a/zerver/tests/test_bots.py +++ b/zerver/tests/test_bots.py @@ -553,15 +553,15 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.login_user(user) bot_info = { - 'full_name': u'The Bot of Hamlet', - 'short_name': u'hambot', + 'full_name': 'The Bot of Hamlet', + 'short_name': 'hambot', } result = self.client_post("/json/bots", bot_info) self.assert_json_success(result) bot_info = { - 'full_name': u'The Another Bot of Hamlet', - 'short_name': u'hambot-another', + 'full_name': 'The Another Bot of Hamlet', + 'short_name': 'hambot-another', } result = self.client_post("/json/bots", bot_info) self.assert_json_success(result) @@ -884,8 +884,8 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): othello = self.example_user('othello') bot_info = { - 'full_name': u'The Bot of Hamlet', - 'short_name': u'hambot', + 'full_name': 'The Bot of Hamlet', + 'short_name': 'hambot', } result = self.client_post("/json/bots", bot_info) self.assert_json_success(result) @@ -977,8 +977,8 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): self.assert_num_bots_equal(1) bot_info = { - 'full_name': u'Another Bot of Hamlet', - 'short_name': u'hamelbot', + 'full_name': 'Another Bot of Hamlet', + 'short_name': 'hamelbot', } result = self.client_post("/json/bots", bot_info) self.assert_json_success(result) @@ -1364,8 +1364,8 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): def test_patch_outgoing_webhook_bot(self) -> None: self.login('hamlet') bot_info = { - 'full_name': u'The Bot of Hamlet', - 'short_name': u'hambot', + 'full_name': 'The Bot of Hamlet', + 'short_name': 'hambot', 'bot_type': UserProfile.OUTGOING_WEBHOOK_BOT, 'payload_url': ujson.dumps("http://foo.bar.com"), 'service_interface': Service.GENERIC, @@ -1389,7 +1389,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin): @patch('zulip_bots.bots.giphy.giphy.GiphyHandler.validate_config') def test_patch_bot_config_data(self, mock_validate_config: MagicMock) -> None: self.create_test_bot('test', self.example_user("hamlet"), - full_name=u'Bot with config data', + full_name='Bot with config data', bot_type=UserProfile.EMBEDDED_BOT, service_name='giphy', config_data=ujson.dumps({'key': '12345678'})) diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 3255e1770d..85c6a433e8 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.test import TestCase, override_settings @@ -365,7 +364,7 @@ class BugdownTest(ZulipTestCase): def load_bugdown_tests(self) -> Tuple[Dict[str, Any], List[List[str]]]: test_fixtures = {} - with open(os.path.join(os.path.dirname(__file__), 'fixtures/markdown_test_cases.json'), 'r') as f: + with open(os.path.join(os.path.dirname(__file__), 'fixtures/markdown_test_cases.json')) as f: data = ujson.load(f) for test in data['regular_tests']: test_fixtures[test['name']] = test @@ -383,10 +382,10 @@ class BugdownTest(ZulipTestCase): @slow("Aggregate of runs dozens of individual markdown tests") def test_bugdown_fixtures(self) -> None: format_tests, linkify_tests = self.load_bugdown_tests() - valid_keys = set(["name", "input", "expected_output", - "backend_only_rendering", - "marked_expected_output", "text_content", - "translate_emoticons", "ignore"]) + valid_keys = {"name", "input", "expected_output", + "backend_only_rendering", + "marked_expected_output", "text_content", + "translate_emoticons", "ignore"} for name, test in format_tests.items(): with self.subTest(markdown_test_case=name): @@ -903,29 +902,29 @@ class BugdownTest(ZulipTestCase): self.assertEqual(converted, '

:green_tick:

') def test_unicode_emoji(self) -> None: - msg = u'\u2615' # ☕ + msg = '\u2615' # ☕ converted = bugdown_convert(msg) - self.assertEqual(converted, u'

:coffee:

') + self.assertEqual(converted, '

:coffee:

') - msg = u'\u2615\u2615' # ☕☕ + msg = '\u2615\u2615' # ☕☕ converted = bugdown_convert(msg) - self.assertEqual(converted, u'

:coffee::coffee:

') + self.assertEqual(converted, '

:coffee::coffee:

') def test_no_translate_emoticons_if_off(self) -> None: user_profile = self.example_user('othello') do_set_user_display_setting(user_profile, 'translate_emoticons', False) msg = Message(sender=user_profile, sending_client=get_client("test")) - content = u':)' - expected = u'

:)

' + content = ':)' + expected = '

:)

' converted = render_markdown(msg, content) self.assertEqual(converted, expected) def test_same_markup(self) -> None: - msg = u'\u2615' # ☕ + msg = '\u2615' # ☕ unicode_converted = bugdown_convert(msg) - msg = u':coffee:' # ☕☕ + msg = ':coffee:' # ☕☕ converted = bugdown_convert(msg) self.assertEqual(converted, unicode_converted) @@ -935,15 +934,15 @@ class BugdownTest(ZulipTestCase): msg.set_topic_name("https://google.com/hello-world") converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) - self.assertEqual(converted_topic, [u'https://google.com/hello-world']) + self.assertEqual(converted_topic, ['https://google.com/hello-world']) msg.set_topic_name("http://google.com/hello-world") converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) - self.assertEqual(converted_topic, [u'http://google.com/hello-world']) + self.assertEqual(converted_topic, ['http://google.com/hello-world']) msg.set_topic_name("Without scheme google.com/hello-world") converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) - self.assertEqual(converted_topic, [u'https://google.com/hello-world']) + self.assertEqual(converted_topic, ['https://google.com/hello-world']) msg.set_topic_name("Without scheme random.words/hello-world") converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) @@ -951,7 +950,7 @@ class BugdownTest(ZulipTestCase): msg.set_topic_name("Try out http://ftp.debian.org, https://google.com/ and https://google.in/.") converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) - self.assertEqual(converted_topic, [u'http://ftp.debian.org', 'https://google.com/', 'https://google.in/']) + self.assertEqual(converted_topic, ['http://ftp.debian.org', 'https://google.com/', 'https://google.in/']) def test_realm_patterns(self) -> None: realm = get_realm('zulip') @@ -975,11 +974,11 @@ class BugdownTest(ZulipTestCase): converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) self.assertEqual(converted, '

We should fix #224 and #115, but not issue#124 or #1124z or trac #15 today.

') - self.assertEqual(converted_topic, [u'https://trac.zulip.net/ticket/444']) + self.assertEqual(converted_topic, ['https://trac.zulip.net/ticket/444']) msg.set_topic_name("#444 https://google.com") converted_topic = bugdown.topic_links(realm.id, msg.topic_name()) - self.assertEqual(converted_topic, [u'https://trac.zulip.net/ticket/444', u'https://google.com']) + self.assertEqual(converted_topic, ['https://trac.zulip.net/ticket/444', 'https://google.com']) RealmFilter(realm=realm, pattern=r'#(?P[a-zA-Z]+-[0-9]+)', url_format_string=r'https://trac.zulip.net/ticket/%(id)s').save() @@ -1038,7 +1037,7 @@ class BugdownTest(ZulipTestCase): zulip_filters = all_filters[realm.id] self.assertEqual(len(zulip_filters), 1) self.assertEqual(zulip_filters[0], - (u'#(?P[0-9]{2,8})', u'https://trac.zulip.net/ticket/%(id)s', realm_filter.id)) + ('#(?P[0-9]{2,8})', 'https://trac.zulip.net/ticket/%(id)s', realm_filter.id)) def test_flush_realm_filter(self) -> None: realm = get_realm('zulip') @@ -1128,7 +1127,7 @@ class BugdownTest(ZulipTestCase): content = "We have an ALERTWORD day today!" self.assertEqual(render(msg, content), "

We have an ALERTWORD day today!

") - self.assertEqual(msg.user_ids_with_alert_words, set([user_profile.id])) + self.assertEqual(msg.user_ids_with_alert_words, {user_profile.id}) msg = Message(sender=user_profile, sending_client=get_client("test")) content = "We have a NOTHINGWORD day today!" @@ -1412,7 +1411,7 @@ class BugdownTest(ZulipTestCase): self.assertEqual(render_markdown(msg, content), '

@all test

') self.assertFalse(msg.mentions_wildcard) - self.assertEqual(msg.mentions_user_ids, set([])) + self.assertEqual(msg.mentions_user_ids, set()) def test_mention_at_everyone(self) -> None: user_profile = self.example_user('othello') @@ -1422,7 +1421,7 @@ class BugdownTest(ZulipTestCase): self.assertEqual(render_markdown(msg, content), '

@everyone test

') self.assertFalse(msg.mentions_wildcard) - self.assertEqual(msg.mentions_user_ids, set([])) + self.assertEqual(msg.mentions_user_ids, set()) def test_mention_word_starting_with_at_wildcard(self) -> None: user_profile = self.example_user('othello') @@ -1432,7 +1431,7 @@ class BugdownTest(ZulipTestCase): self.assertEqual(render_markdown(msg, content), '

test @alleycat.com test

') self.assertFalse(msg.mentions_wildcard) - self.assertEqual(msg.mentions_user_ids, set([])) + self.assertEqual(msg.mentions_user_ids, set()) def test_mention_at_normal_user(self) -> None: user_profile = self.example_user('othello') @@ -1442,7 +1441,7 @@ class BugdownTest(ZulipTestCase): self.assertEqual(render_markdown(msg, content), '

@aaron test

') self.assertFalse(msg.mentions_wildcard) - self.assertEqual(msg.mentions_user_ids, set([])) + self.assertEqual(msg.mentions_user_ids, set()) def test_mention_single(self) -> None: sender_user_profile = self.example_user('othello') @@ -1455,7 +1454,7 @@ class BugdownTest(ZulipTestCase): '

' '@King Hamlet

' % (user_id,)) - self.assertEqual(msg.mentions_user_ids, set([user_profile.id])) + self.assertEqual(msg.mentions_user_ids, {user_profile.id}) def test_mention_silent(self) -> None: sender_user_profile = self.example_user('othello') @@ -1499,7 +1498,7 @@ class BugdownTest(ZulipTestCase): '@Cordelia Lear, ' 'check this out

' % (hamlet.id, cordelia.id)) - self.assertEqual(msg.mentions_user_ids, set([hamlet.id, cordelia.id])) + self.assertEqual(msg.mentions_user_ids, {hamlet.id, cordelia.id}) def test_mention_in_quotes(self) -> None: othello = self.example_user('othello') @@ -1519,7 +1518,7 @@ class BugdownTest(ZulipTestCase): ' and ' '@Cordelia Lear' '

' % (hamlet.id, othello.id, hamlet.id, cordelia.id)) - self.assertEqual(msg.mentions_user_ids, set([hamlet.id, cordelia.id])) + self.assertEqual(msg.mentions_user_ids, {hamlet.id, cordelia.id}) # Both fenced quote and > quote should be identical for both silent and regular syntax. expected = ('
\n

' @@ -1567,7 +1566,7 @@ class BugdownTest(ZulipTestCase): '@Cordelia Lear, ' 'hi.

' % (twin1.id, twin2.id, cordelia.id)) - self.assertEqual(msg.mentions_user_ids, set([twin1.id, twin2.id, cordelia.id])) + self.assertEqual(msg.mentions_user_ids, {twin1.id, twin2.id, cordelia.id}) def test_mention_invalid(self) -> None: sender_user_profile = self.example_user('othello') @@ -1603,7 +1602,7 @@ class BugdownTest(ZulipTestCase): '

' '@Atomic #123

' % (test_user.id,)) - self.assertEqual(msg.mentions_user_ids, set([test_user.id])) + self.assertEqual(msg.mentions_user_ids, {test_user.id}) content = "@_**Atomic #123**" self.assertEqual(render_markdown(msg, content), '

' '@support

' % (user_id, user_group.id)) - self.assertEqual(msg.mentions_user_ids, set([user_profile.id])) - self.assertEqual(msg.mentions_user_group_ids, set([user_group.id])) + self.assertEqual(msg.mentions_user_ids, {user_profile.id}) + self.assertEqual(msg.mentions_user_group_ids, {user_group.id}) def test_user_group_mention_atomic_string(self) -> None: sender_user_profile = self.example_user('othello') @@ -1662,8 +1661,8 @@ class BugdownTest(ZulipTestCase): 'data-user-group-id="%s">' '@support #123

' % (user_id, user_group.id)) - self.assertEqual(msg.mentions_user_ids, set([user_profile.id])) - self.assertEqual(msg.mentions_user_group_ids, set([user_group.id])) + self.assertEqual(msg.mentions_user_ids, {user_profile.id}) + self.assertEqual(msg.mentions_user_group_ids, {user_group.id}) def test_possible_user_group_mentions(self) -> None: def assert_mentions(content: str, names: Set[str]) -> None: @@ -1703,7 +1702,7 @@ class BugdownTest(ZulipTestCase): 'check this out' '

' % (support.id, backend.id)) - self.assertEqual(msg.mentions_user_group_ids, set([support.id, backend.id])) + self.assertEqual(msg.mentions_user_group_ids, {support.id, backend.id}) def test_user_group_mention_invalid(self) -> None: sender_user_profile = self.example_user('othello') @@ -1831,17 +1830,17 @@ class BugdownTest(ZulipTestCase): def test_stream_unicode(self) -> None: realm = get_realm('zulip') - uni = Stream.objects.create(name=u'привет', realm=realm) + uni = Stream.objects.create(name='привет', realm=realm) sender_user_profile = self.example_user('othello') msg = Message(sender=sender_user_profile, sending_client=get_client("test")) - content = u"#**привет**" + content = "#**привет**" quoted_name = '.D0.BF.D1.80.D0.B8.D0.B2.D0.B5.D1.82' href = '/#narrow/stream/{stream_id}-{quoted_name}'.format( stream_id=uni.id, quoted_name=quoted_name) self.assertEqual( render_markdown(msg, content), - u'

#{s.name}

'.format( + '

#{s.name}

'.format( s=uni, href=href, )) @@ -1860,13 +1859,13 @@ class BugdownTest(ZulipTestCase): '[0-9]{2,8})' ' https://trac.zulip.net/ticket/%(id)s>') # Create a stream that potentially interferes with the pattern. - stream = Stream.objects.create(name=u'Stream #1234', realm=realm) + stream = Stream.objects.create(name='Stream #1234', realm=realm) msg = Message(sender=sender_user_profile, sending_client=get_client("test")) - content = u"#**Stream #1234**" + content = "#**Stream #1234**" href = '/#narrow/stream/{stream_id}-Stream-.231234'.format(stream_id=stream.id) self.assertEqual( render_markdown(msg, content), - u'

#{s.name}

'.format( + '

#{s.name}

'.format( s=stream, href=href, )) @@ -2000,7 +1999,7 @@ class BugdownApiTests(ZulipTestCase): ) self.assert_json_success(result) self.assertEqual(result.json()['rendered'], - u'

That is a bold statement

') + '

That is a bold statement

') def test_render_mention_stream_api(self) -> None: """Determines whether we're correctly passing the realm context""" @@ -2014,7 +2013,7 @@ class BugdownApiTests(ZulipTestCase): user_id = self.example_user('hamlet').id stream_id = get_stream('Denmark', get_realm('zulip')).id self.assertEqual(result.json()['rendered'], - u'

This mentions #Denmark and @King Hamlet.

' % (stream_id, stream_id, user_id)) + '

This mentions #Denmark and @King Hamlet.

' % (stream_id, stream_id, user_id)) class BugdownErrorTests(ZulipTestCase): def test_bugdown_error_handling(self) -> None: @@ -2034,7 +2033,7 @@ class BugdownErrorTests(ZulipTestCase): def test_ultra_long_rendering(self) -> None: """A rendered message with an ultra-long lenght (> 10 * MAX_MESSAGE_LENGTH) throws an exception""" - msg = u'mock rendered message\n' * MAX_MESSAGE_LENGTH + msg = 'mock rendered message\n' * MAX_MESSAGE_LENGTH with mock.patch('zerver.lib.bugdown.timeout', return_value=msg), \ mock.patch('zerver.lib.bugdown.bugdown_logger'): @@ -2104,7 +2103,7 @@ class BugdownAvatarTestCase(ZulipTestCase): message = Message(sender=sender_user_profile, sending_client=get_client("test")) user_profile = self.example_user('hamlet') - msg = '!avatar({0})'.format(user_profile.email) + msg = '!avatar({})'.format(user_profile.email) converted = bugdown.convert(msg, message=message) values = {'email': user_profile.email, 'id': user_profile.id} self.assertEqual( @@ -2116,7 +2115,7 @@ class BugdownAvatarTestCase(ZulipTestCase): message = Message(sender=sender_user_profile, sending_client=get_client("test")) email = 'fakeuser@example.com' - msg = '!avatar({0})'.format(email) + msg = '!avatar({})'.format(email) converted = bugdown.convert(msg, message=message) self.assertEqual( converted, diff --git a/zerver/tests/test_camo.py b/zerver/tests/test_camo.py index 7376fb33c3..8224047a31 100644 --- a/zerver/tests/test_camo.py +++ b/zerver/tests/test_camo.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import ZulipTestCase class CamoURLTest(ZulipTestCase): diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py index 0ed07343b3..e535a5079e 100644 --- a/zerver/tests/test_custom_profile_data.py +++ b/zerver/tests/test_custom_profile_data.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Union, List, Dict, Any from zerver.lib.actions import try_add_realm_custom_profile_field, \ @@ -30,14 +28,14 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): def test_create(self) -> None: self.login('iago') realm = get_realm('zulip') - data = {"name": u"Phone", "field_type": "text id"} # type: Dict[str, Any] + data = {"name": "Phone", "field_type": "text id"} # type: Dict[str, Any] result = self.client_post("/json/realm/profile_fields", info=data) - self.assert_json_error(result, u'Argument "field_type" is not valid JSON.') + self.assert_json_error(result, 'Argument "field_type" is not valid JSON.') data["name"] = "" data["field_type"] = 100 result = self.client_post("/json/realm/profile_fields", info=data) - self.assert_json_error(result, u'Label cannot be blank.') + self.assert_json_error(result, 'Label cannot be blank.') data["name"] = "*" * 41 data["field_type"] = 100 @@ -46,7 +44,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): data["name"] = "Phone" result = self.client_post("/json/realm/profile_fields", info=data) - self.assert_json_error(result, u'Invalid field type.') + self.assert_json_error(result, 'Invalid field type.') data["name"] = "Phone" data["hint"] = "*" * 81 @@ -66,7 +64,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): result = self.client_post("/json/realm/profile_fields", info=data) self.assert_json_error(result, - u'A field with that label already exists.') + 'A field with that label already exists.') def test_create_choice_field(self) -> None: self.login('iago') @@ -280,7 +278,7 @@ class CreateCustomProfileFieldTest(CustomProfileFieldTestCase): def test_not_realm_admin(self) -> None: self.login('hamlet') result = self.client_post("/json/realm/profile_fields") - self.assert_json_error(result, u'Must be an organization administrator') + self.assert_json_error(result, 'Must be an organization administrator') result = self.client_delete("/json/realm/profile_fields/1") self.assert_json_error(result, 'Must be an organization administrator') @@ -308,7 +306,7 @@ class DeleteCustomProfileFieldTest(CustomProfileFieldTestCase): 'data': ujson.dumps([invalid_field_id]) }) self.assert_json_error(result, - u'Field id %d not found.' % (invalid_field_id,)) + 'Field id %d not found.' % (invalid_field_id,)) field = CustomProfileField.objects.get(name="Mentor", realm=realm) data = [{'id': field.id, @@ -334,7 +332,7 @@ class DeleteCustomProfileFieldTest(CustomProfileFieldTestCase): user_profile = self.example_user('iago') realm = user_profile.realm field = CustomProfileField.objects.get(name="Phone number", realm=realm) - data = [{'id': field.id, 'value': u'123456'}] # type: List[Dict[str, Union[int, str, List[int]]]] + data = [{'id': field.id, 'value': '123456'}] # type: List[Dict[str, Union[int, str, List[int]]]] do_update_user_custom_profile_data_if_changed(user_profile, data) self.assertTrue(self.custom_field_exists_in_realm(field.id)) @@ -354,7 +352,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): info={'name': 'Phone Number', 'field_type': CustomProfileField.SHORT_TEXT} ) - self.assert_json_error(result, u'Field id 100 not found.') + self.assert_json_error(result, 'Field id 100 not found.') field = CustomProfileField.objects.get(name="Phone number", realm=realm) result = self.client_patch( @@ -362,7 +360,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): info={'name': '', 'field_type': CustomProfileField.SHORT_TEXT} ) - self.assert_json_error(result, u'Label cannot be blank.') + self.assert_json_error(result, 'Label cannot be blank.') self.assertEqual(CustomProfileField.objects.count(), self.original_count) result = self.client_patch( @@ -435,10 +433,10 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): def test_update_is_aware_of_uniqueness(self) -> None: self.login('iago') realm = get_realm('zulip') - field_1 = try_add_realm_custom_profile_field(realm, u"Phone", + field_1 = try_add_realm_custom_profile_field(realm, "Phone", CustomProfileField.SHORT_TEXT) - field_2 = try_add_realm_custom_profile_field(realm, u"Phone 1", + field_2 = try_add_realm_custom_profile_field(realm, "Phone 1", CustomProfileField.SHORT_TEXT) self.assertTrue(self.custom_field_exists_in_realm(field_1.id)) @@ -447,7 +445,7 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): "/json/realm/profile_fields/{}".format(field_2.id), info={'name': 'Phone', 'field_type': CustomProfileField.SHORT_TEXT}) self.assert_json_error( - result, u'A field with that label already exists.') + result, 'A field with that label already exists.') def assert_error_update_invalid_value(self, field_name: str, new_value: object, error_msg: str) -> None: self.login('iago') @@ -466,30 +464,30 @@ class UpdateCustomProfileFieldTest(CustomProfileFieldTestCase): 'data': ujson.dumps(data) }) self.assert_json_error(result, - u"Field id 1234 not found.") + "Field id 1234 not found.") def test_update_invalid_short_text(self) -> None: field_name = "Phone number" self.assert_error_update_invalid_value(field_name, 't' * 201, - u"{} is too long (limit: 50 characters)".format(field_name)) + "{} is too long (limit: 50 characters)".format(field_name)) def test_update_invalid_date(self) -> None: field_name = "Birthday" - self.assert_error_update_invalid_value(field_name, u"a-b-c", - u"{} is not a date".format(field_name)) + self.assert_error_update_invalid_value(field_name, "a-b-c", + "{} is not a date".format(field_name)) self.assert_error_update_invalid_value(field_name, 123, - u"{} is not a string".format(field_name)) + "{} is not a string".format(field_name)) def test_update_invalid_url(self) -> None: field_name = "Favorite website" - self.assert_error_update_invalid_value(field_name, u"not URL", - u"{} is not a URL".format(field_name)) + self.assert_error_update_invalid_value(field_name, "not URL", + "{} is not a URL".format(field_name)) def test_update_invalid_user_field(self) -> None: field_name = "Mentor" invalid_user_id = 1000 self.assert_error_update_invalid_value(field_name, [invalid_user_id], - u"Invalid user ID: %d" + "Invalid user ID: %d" % (invalid_user_id,)) def test_update_profile_data_successfully(self) -> None: @@ -756,9 +754,9 @@ class ReorderCustomProfileFieldTest(CustomProfileFieldTestCase): result = self.client_patch("/json/realm/profile_fields", info={'order': ujson.dumps(order)}) self.assert_json_error( - result, u'Invalid order mapping.') + result, 'Invalid order mapping.') order = [1, 2] result = self.client_patch("/json/realm/profile_fields", info={'order': ujson.dumps(order)}) self.assert_json_error( - result, u'Invalid order mapping.') + result, 'Invalid order mapping.') diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 605290242e..8245f85e1c 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import base64 import mock import re @@ -582,7 +581,7 @@ body: HTTP_AUTHORIZATION=api_auth) self.assert_json_error(result, "This endpoint requires HTTP basic authentication.") - api_auth = 'Basic ' + base64.b64encode("foo".encode('utf-8')).decode('utf-8') + api_auth = 'Basic ' + base64.b64encode(b"foo").decode('utf-8') result = self.client_post('/api/v1/external/zendesk', {}, HTTP_AUTHORIZATION=api_auth) self.assert_json_error(result, "Invalid authorization header for basic auth", @@ -1653,11 +1652,11 @@ class ReturnSuccessOnHeadRequestDecorator(ZulipTestCase): @return_success_on_head_request def test_function(request: HttpRequest) -> HttpResponse: - return json_response(msg=u'from_test_function') # nocoverage. isn't meant to be called + return json_response(msg='from_test_function') # nocoverage. isn't meant to be called response = test_function(request) self.assert_json_success(response) - self.assertNotEqual(ujson.loads(response.content).get('msg'), u'from_test_function') + self.assertNotEqual(ujson.loads(response.content).get('msg'), 'from_test_function') def test_returns_normal_response_if_request_method_is_not_head(self) -> None: class HeadRequest: @@ -1667,10 +1666,10 @@ class ReturnSuccessOnHeadRequestDecorator(ZulipTestCase): @return_success_on_head_request def test_function(request: HttpRequest) -> HttpResponse: - return json_response(msg=u'from_test_function') + return json_response(msg='from_test_function') response = test_function(request) - self.assertEqual(ujson.loads(response.content).get('msg'), u'from_test_function') + self.assertEqual(ujson.loads(response.content).get('msg'), 'from_test_function') class RestAPITest(ZulipTestCase): def test_method_not_allowed(self) -> None: diff --git a/zerver/tests/test_digest.py b/zerver/tests/test_digest.py index 210865e1fc..a2b49425ab 100644 --- a/zerver/tests/test_digest.py +++ b/zerver/tests/test_digest.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import datetime import mock import time diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index 626604bb40..b77f83accc 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import os import ujson import mock @@ -454,8 +452,8 @@ class PrivacyTermsTest(ZulipTestCase): def test_custom_tos_template(self) -> None: response = self.client_get("/terms/") - self.assert_in_success_response([u"Thanks for using our products and services (\"Services\"). ", - u"By using our Services, you are agreeing to these terms"], + self.assert_in_success_response(["Thanks for using our products and services (\"Services\"). ", + "By using our Services, you are agreeing to these terms"], response) def test_custom_terms_of_service_template(self) -> None: diff --git a/zerver/tests/test_email_change.py b/zerver/tests/test_email_change.py index 0456ec3714..cf0374881d 100644 --- a/zerver/tests/test_email_change.py +++ b/zerver/tests/test_email_change.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import datetime from email.utils import parseaddr import re diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.py index d6fc129a0c..71d1682c7b 100644 --- a/zerver/tests/test_email_mirror.py +++ b/zerver/tests/test_email_mirror.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import subprocess from django.http import HttpResponse diff --git a/zerver/tests/test_embedded_bot_system.py b/zerver/tests/test_embedded_bot_system.py index 0131e2176e..e65dedbadd 100644 --- a/zerver/tests/test_embedded_bot_system.py +++ b/zerver/tests/test_embedded_bot_system.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from mock import patch from zerver.lib.bot_lib import EmbeddedBotQuitException diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 2557858439..261e40afb8 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # See https://zulip.readthedocs.io/en/latest/subsystems/events-system.html for # high-level documentation on how this system works. from typing import Any, Callable, Dict, List, Optional, Set, Tuple @@ -768,7 +767,7 @@ class EventsRegisterTest(ZulipTestCase): events = self.do_test( lambda: do_update_embedded_data(self.user_profile, message, - u"embed_content", "

embed_content

"), + "embed_content", "

embed_content

"), state_change_expected=False, ) error = schema_checker('events[0]', events[0]) @@ -1607,11 +1606,11 @@ class EventsRegisterTest(ZulipTestCase): def do_set_realm_property_test(self, name: str) -> None: bool_tests = [True, False, True] # type: List[bool] test_values = dict( - default_language=[u'es', u'de', u'en'], - description=[u'Realm description', u'New description'], + default_language=['es', 'de', 'en'], + description=['Realm description', 'New description'], digest_weekday=[0, 1, 2], message_retention_days=[10, 20], - name=[u'Zulip', u'New Name'], + name=['Zulip', 'New Name'], waiting_period_threshold=[10, 20], create_stream_policy=[3, 2, 1], invite_to_stream_policy=[3, 2, 1], @@ -1623,11 +1622,11 @@ class EventsRegisterTest(ZulipTestCase): Realm.VIDEO_CHAT_PROVIDERS['jitsi_meet']['id'], Realm.VIDEO_CHAT_PROVIDERS['google_hangouts']['id'] ], - google_hangouts_domain=[u"zulip.com", u"zulip.org"], - zoom_api_secret=[u"abc", u"xyz"], - zoom_api_key=[u"abc", u"xyz"], - zoom_user_id=[u"example@example.com", u"example@example.org"], - default_code_block_language=[u'python', u'javascript'] + google_hangouts_domain=["zulip.com", "zulip.org"], + zoom_api_secret=["abc", "xyz"], + zoom_api_key=["abc", "xyz"], + zoom_user_id=["example@example.com", "example@example.org"] + default_code_block_language=['python', 'javascript'] ) # type: Dict[str, Any] vals = test_values.get(name) @@ -1844,9 +1843,9 @@ class EventsRegisterTest(ZulipTestCase): """Test updating each setting in UserProfile.property_types dict.""" test_changes = dict( - emojiset = [u'twitter'], - default_language = [u'es', u'de', u'en'], - timezone = [u'US/Mountain', u'US/Samoa', u'Pacific/Galapogos', u''], + emojiset = ['twitter'], + default_language = ['es', 'de', 'en'], + timezone = ['US/Mountain', 'US/Samoa', 'Pacific/Galapogos', ''], demote_inactive_streams = [2, 3, 1], ) # type: Dict[str, Any] @@ -2404,7 +2403,7 @@ class EventsRegisterTest(ZulipTestCase): def test_rename_stream(self) -> None: stream = self.make_stream('old_name') - new_name = u'stream with a brand new name' + new_name = 'stream with a brand new name' self.subscribe(self.user_profile, stream.name) notification = '

King Hamlet renamed stream old_name to stream with a brand new name.

' notification = notification.format(user_id=self.user_profile.id) @@ -2475,7 +2474,7 @@ class EventsRegisterTest(ZulipTestCase): self.assert_on_error(error) def test_subscribe_other_user_never_subscribed(self) -> None: - action = lambda: self.subscribe(self.example_user("othello"), u"test_stream") + action = lambda: self.subscribe(self.example_user("othello"), "test_stream") events = self.do_test(action, num_events=2) peer_add_schema_checker = self.check_events_dict([ ('type', equals('subscription')), @@ -2638,7 +2637,7 @@ class EventsRegisterTest(ZulipTestCase): error = add_schema_checker('events[1]', events[1]) self.assert_on_error(error) - action = lambda: do_change_stream_description(stream, u'new description') + action = lambda: do_change_stream_description(stream, 'new description') events = self.do_test(action, include_subscribers=include_subscribers) error = stream_update_schema_checker('events[0]', events[0]) @@ -3740,20 +3739,20 @@ class TestEventsRegisterNarrowDefaults(ZulipTestCase): def test_use_passed_narrow_no_default(self) -> None: self.user_profile.default_events_register_stream_id = None self.user_profile.save() - result = _default_narrow(self.user_profile, [[u'stream', u'my_stream']]) - self.assertEqual(result, [[u'stream', u'my_stream']]) + result = _default_narrow(self.user_profile, [['stream', 'my_stream']]) + self.assertEqual(result, [['stream', 'my_stream']]) def test_use_passed_narrow_with_default(self) -> None: self.user_profile.default_events_register_stream_id = self.stream.id self.user_profile.save() - result = _default_narrow(self.user_profile, [[u'stream', u'my_stream']]) - self.assertEqual(result, [[u'stream', u'my_stream']]) + result = _default_narrow(self.user_profile, [['stream', 'my_stream']]) + self.assertEqual(result, [['stream', 'my_stream']]) def test_use_default_if_narrow_is_empty(self) -> None: self.user_profile.default_events_register_stream_id = self.stream.id self.user_profile.save() result = _default_narrow(self.user_profile, []) - self.assertEqual(result, [[u'stream', u'Verona']]) + self.assertEqual(result, [['stream', 'Verona']]) def test_use_narrow_if_default_is_none(self) -> None: self.user_profile.default_events_register_stream_id = None diff --git a/zerver/tests/test_external.py b/zerver/tests/test_external.py index c5a90a3c87..f5a1e09139 100644 --- a/zerver/tests/test_external.py +++ b/zerver/tests/test_external.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.core.exceptions import ValidationError from django.http import HttpResponse diff --git a/zerver/tests/test_gitter_importer.py b/zerver/tests/test_gitter_importer.py index 8c030fcf97..d1fb4f308d 100644 --- a/zerver/tests/test_gitter_importer.py +++ b/zerver/tests/test_gitter_importer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.import_realm import ( do_import_realm, ) @@ -65,11 +64,11 @@ class GitterImporter(ZulipTestCase): # test recipient exported_recipient_id = self.get_set(realm['zerver_recipient'], 'id') exported_recipient_type = self.get_set(realm['zerver_recipient'], 'type') - self.assertEqual(set([1, 2]), exported_recipient_type) + self.assertEqual({1, 2}, exported_recipient_type) # test subscription exported_subscription_userprofile = self.get_set(realm['zerver_subscription'], 'user_profile') - self.assertEqual(set([0, 1]), exported_subscription_userprofile) + self.assertEqual({0, 1}, exported_subscription_userprofile) exported_subscription_recipient = self.get_set(realm['zerver_subscription'], 'recipient') self.assertEqual(len(exported_subscription_recipient), 3) self.assertIn(realm['zerver_subscription'][1]['recipient'], exported_recipient_id) diff --git a/zerver/tests/test_hotspots.py b/zerver/tests/test_hotspots.py index 48633a3037..c516307d04 100644 --- a/zerver/tests/test_hotspots.py +++ b/zerver/tests/test_hotspots.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from zerver.lib.actions import do_mark_hotspot_as_read, do_create_user from zerver.lib.hotspots import ALL_HOTSPOTS, get_next_hotspots from zerver.lib.test_classes import ZulipTestCase diff --git a/zerver/tests/test_i18n.py b/zerver/tests/test_i18n.py index 044a71efbe..b1257bf52b 100644 --- a/zerver/tests/test_i18n.py +++ b/zerver/tests/test_i18n.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Any import mock @@ -73,10 +71,10 @@ class TranslationTestCase(ZulipTestCase): return response def test_accept_language_header(self) -> None: - languages = [('en', u'Sign up'), - ('de', u'Registrieren'), - ('sr', u'Упишите се'), - ('zh-hans', u'注册'), + languages = [('en', 'Sign up'), + ('de', 'Registrieren'), + ('sr', 'Упишите се'), + ('zh-hans', '注册'), ] for lang, word in languages: @@ -85,10 +83,10 @@ class TranslationTestCase(ZulipTestCase): self.assert_in_response(word, response) def test_cookie(self) -> None: - languages = [('en', u'Sign up'), - ('de', u'Registrieren'), - ('sr', u'Упишите се'), - ('zh-hans', u'注册'), + languages = [('en', 'Sign up'), + ('de', 'Registrieren'), + ('sr', 'Упишите се'), + ('zh-hans', '注册'), ] for lang, word in languages: @@ -100,10 +98,10 @@ class TranslationTestCase(ZulipTestCase): self.assert_in_response(word, response) def test_i18n_urls(self) -> None: - languages = [('en', u'Sign up'), - ('de', u'Registrieren'), - ('sr', u'Упишите се'), - ('zh-hans', u'注册'), + languages = [('en', 'Sign up'), + ('de', 'Registrieren'), + ('sr', 'Упишите се'), + ('zh-hans', '注册'), ] for lang, word in languages: @@ -125,7 +123,7 @@ class JsonTranslationTestCase(ZulipTestCase): result = self.client_post("/json/invites", HTTP_ACCEPT_LANGUAGE='de') - expected_error = u"this arg is bad: 'invitee_emails' (translated to German)" + expected_error = "this arg is bad: 'invitee_emails' (translated to German)" self.assert_json_error_contains(result, expected_error, status_code=400) diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.py index 67bd68eeb3..dcf8c974ca 100644 --- a/zerver/tests/test_import_export.py +++ b/zerver/tests/test_import_export.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from django.conf import settings import os @@ -290,7 +288,7 @@ class ImportExportTest(ZulipTestCase): realm = Realm.objects.get(string_id='zulip') message = Message.objects.all()[0] user_profile = message.sender - url = upload_message_file(u'dummy.txt', len(b'zulip!'), u'text/plain', b'zulip!', user_profile) + url = upload_message_file('dummy.txt', len(b'zulip!'), 'text/plain', b'zulip!', user_profile) attachment_path_id = url.replace('/user_uploads/', '') claim_attachment( user_profile=user_profile, @@ -346,7 +344,7 @@ class ImportExportTest(ZulipTestCase): # Test uploads fn = os.path.join(full_data['uploads_dir'], path_id) - with open(fn, 'r') as f: + with open(fn) as f: self.assertEqual(f.read(), 'zulip!') records = full_data['uploads_dir_records'] self.assertEqual(records[0]['path'], path_id) @@ -409,7 +407,7 @@ class ImportExportTest(ZulipTestCase): # Test uploads fields = attachment_path_id.split('/') fn = os.path.join(full_data['uploads_dir'], os.path.join(fields[0], fields[1], fields[2])) - with open(fn, 'r') as f: + with open(fn) as f: self.assertEqual(f.read(), 'zulip!') records = full_data['uploads_dir_records'] self.assertEqual(records[0]['path'], os.path.join(fields[0], fields[1], fields[2])) @@ -478,7 +476,7 @@ class ImportExportTest(ZulipTestCase): exported_streams = self.get_set(data['zerver_stream'], 'name') self.assertEqual( exported_streams, - set([u'Denmark', u'Rome', u'Scotland', u'Venice', u'Verona']) + {'Denmark', 'Rome', 'Scotland', 'Venice', 'Verona'} ) data = full_data['message'] @@ -500,7 +498,7 @@ class ImportExportTest(ZulipTestCase): cordelia = self.example_user('iago') hamlet = self.example_user('hamlet') - user_ids = set([cordelia.id, hamlet.id]) + user_ids = {cordelia.id, hamlet.id} pm_a_msg_id = self.send_personal_message(self.example_user("AARON"), self.example_user("othello")) pm_b_msg_id = self.send_personal_message(self.example_user("cordelia"), self.example_user("iago")) @@ -605,8 +603,8 @@ class ImportExportTest(ZulipTestCase): exported_streams = self.get_set(data['zerver_stream'], 'name') self.assertEqual( exported_streams, - set([u'Denmark', u'Rome', u'Scotland', u'Venice', u'Verona', - u'Private A', u'Private B', u'Private C']) + {'Denmark', 'Rome', 'Scotland', 'Venice', 'Verona', + 'Private A', 'Private B', 'Private C'} ) data = full_data['message'] @@ -672,9 +670,9 @@ class ImportExportTest(ZulipTestCase): user = read_file('user.json') exported_user_id = self.get_set(user['zerver_userprofile'], 'id') - self.assertEqual(exported_user_id, set([cordelia.id])) + self.assertEqual(exported_user_id, {cordelia.id}) exported_user_email = self.get_set(user['zerver_userprofile'], 'email') - self.assertEqual(exported_user_email, set([cordelia.email])) + self.assertEqual(exported_user_email, {cordelia.email}) exported_recipient_type_id = self.get_set(user['zerver_recipient'], 'type_id') self.assertIn(cordelia.id, exported_recipient_type_id) @@ -725,12 +723,12 @@ class ImportExportTest(ZulipTestCase): ) # data to test import of muted topic - stream = get_stream(u'Verona', original_realm) + stream = get_stream('Verona', original_realm) add_topic_mute( user_profile=sample_user, stream_id=stream.id, recipient_id=stream.recipient.id, - topic_name=u'Verona2') + topic_name='Verona2') do_update_user_presence(sample_user, get_client("website"), timezone_now(), UserPresence.ACTIVE) @@ -958,7 +956,7 @@ class ImportExportTest(ZulipTestCase): assert_realm_values(get_user_mention) def get_stream_mention(r: Realm) -> Set[Any]: - mentioned_stream = get_stream(u'Denmark', r) + mentioned_stream = get_stream('Denmark', r) data_stream_id = 'data-stream-id="{}"'.format(mentioned_stream.id) mention_message = get_stream_messages(r).get(rendered_content__contains=data_stream_id) return mention_message.content diff --git a/zerver/tests/test_integrations_dev_panel.py b/zerver/tests/test_integrations_dev_panel.py index dcbb456144..473f6d0571 100644 --- a/zerver/tests/test_integrations_dev_panel.py +++ b/zerver/tests/test_integrations_dev_panel.py @@ -30,7 +30,7 @@ class TestIntegrationsDevPanel(ZulipTestCase): bot = get_user('webhook-bot@zulip.com', self.zulip_realm) url = "/api/v1/external/airbrake?api_key={key}&stream=Denmark&topic=Airbrake Notifications".format(key=bot.api_key) target_url = "/devtools/integrations/check_send_webhook_fixture_message" - with open("zerver/webhooks/airbrake/fixtures/error_message.json", "r") as f: + with open("zerver/webhooks/airbrake/fixtures/error_message.json") as f: body = f.read() data = { @@ -57,7 +57,7 @@ class TestIntegrationsDevPanel(ZulipTestCase): bot = get_user('webhook-bot@zulip.com', self.zulip_realm) url = "/api/v1/external/github?api_key={key}&stream=Denmark&topic=GitHub Notifications".format(key=bot.api_key) target_url = "/devtools/integrations/check_send_webhook_fixture_message" - with open("zerver/webhooks/github/fixtures/ping__organization.json", "r") as f: + with open("zerver/webhooks/github/fixtures/ping__organization.json") as f: body = f.read() data = { @@ -80,7 +80,7 @@ class TestIntegrationsDevPanel(ZulipTestCase): bot = get_user('webhook-bot@zulip.com', self.zulip_realm) url = "/api/v1/external/wordpress?api_key={key}&stream=Denmark&topic=Wordpress Notifications".format(key=bot.api_key) target_url = "/devtools/integrations/check_send_webhook_fixture_message" - with open("zerver/webhooks/wordpress/fixtures/publish_post_no_data_provided.txt", "r") as f: + with open("zerver/webhooks/wordpress/fixtures/publish_post_no_data_provided.txt") as f: body = f.read() data = { diff --git a/zerver/tests/test_link_embed.py b/zerver/tests/test_link_embed.py index 974b81b520..78e9692f72 100644 --- a/zerver/tests/test_link_embed.py +++ b/zerver/tests/test_link_embed.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mock import ujson from typing import Any, Callable, Dict, Optional @@ -253,7 +251,7 @@ class PreviewTestCase(ZulipTestCase): """ def setUp(self) -> None: - super(PreviewTestCase, self).setUp() + super().setUp() Realm.objects.all().update(inline_url_embed_preview=True) @classmethod @@ -291,7 +289,7 @@ class PreviewTestCase(ZulipTestCase): with mock.patch('requests.get', mocked_response): FetchLinksEmbedData().consume(event) - embedded_link = 'The Rock'.format(url) + embedded_link = 'The Rock'.format(url) msg = Message.objects.select_related("sender").get(id=msg_id) self.assertIn(embedded_link, msg.rendered_content) @@ -319,7 +317,7 @@ class PreviewTestCase(ZulipTestCase): # Verify the initial message doesn't have the embedded links rendered msg = Message.objects.select_related("sender").get(id=msg_id) self.assertNotIn( - 'The Rock'.format(url), + 'The Rock'.format(url), msg.rendered_content) # Mock the network request result so the test can be fast without Internet @@ -359,7 +357,7 @@ class PreviewTestCase(ZulipTestCase): msg = Message.objects.select_related("sender").get(id=msg_id) # The content of the message has changed since the event for original_url has been created, # it should not be rendered. Another, up-to-date event will have been sent (edited_url). - self.assertNotIn('The Rock'.format(original_url), + self.assertNotIn('The Rock'.format(original_url), msg.rendered_content) mocked_response_edited.assert_not_called() @@ -369,7 +367,7 @@ class PreviewTestCase(ZulipTestCase): # up-to-date event for edited_url. queue_json_publish(*args, **kwargs) msg = Message.objects.select_related("sender").get(id=msg_id) - self.assertIn('The Rock'.format(edited_url), + self.assertIn('The Rock'.format(edited_url), msg.rendered_content) with mock.patch('zerver.views.messages.queue_json_publish', wraps=wrapped_queue_json_publish) as patched: @@ -380,7 +378,7 @@ class PreviewTestCase(ZulipTestCase): def test_get_link_embed_data(self) -> None: url = 'http://test.org/' - embedded_link = 'The Rock'.format(url) + embedded_link = 'The Rock'.format(url) # When humans send, we should get embedded content. msg = self._send_message_with_test_org_url(sender=self.example_user('hamlet')) @@ -450,7 +448,7 @@ class PreviewTestCase(ZulipTestCase): def test_invalid_link(self) -> None: with self.settings(INLINE_URL_EMBED_PREVIEW=True, TEST_SUITE=False, CACHES=TEST_CACHES): self.assertIsNone(get_link_embed_data('com.notvalidlink')) - self.assertIsNone(get_link_embed_data(u'μένει.com.notvalidlink')) + self.assertIsNone(get_link_embed_data('μένει.com.notvalidlink')) def test_link_embed_data_from_cache(self) -> None: url = 'http://test.org/' @@ -651,8 +649,8 @@ class PreviewTestCase(ZulipTestCase): 'message_realm_id': msg.sender.realm_id, 'message_content': url} - mocked_data = {'html': ''.format(url), - 'oembed': True, 'type': 'video', 'image': '{0}/image.png'.format(url)} + mocked_data = {'html': ''.format(url), + 'oembed': True, 'type': 'video', 'image': '{}/image.png'.format(url)} mocked_response = mock.Mock(side_effect=self.create_mock_response(url)) with self.settings(TEST_SUITE=False, CACHES=TEST_CACHES): with mock.patch('requests.get', mocked_response): diff --git a/zerver/tests/test_logging_handlers.py b/zerver/tests/test_logging_handlers.py index b65e04727c..cc629cbe3b 100644 --- a/zerver/tests/test_logging_handlers.py +++ b/zerver/tests/test_logging_handlers.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import logging import sys diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.py index b08edd59e8..dec4d0b6cb 100644 --- a/zerver/tests/test_management_commands.py +++ b/zerver/tests/test_management_commands.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import glob import os import re @@ -261,7 +259,7 @@ class TestGenerateRealmCreationLink(ZulipTestCase): # Get realm creation page result = self.client_get(generated_link) - self.assert_in_success_response([u"Create a new Zulip organization"], result) + self.assert_in_success_response(["Create a new Zulip organization"], result) # Enter email with self.assertRaises(Realm.DoesNotExist): diff --git a/zerver/tests/test_mattermost_importer.py b/zerver/tests/test_mattermost_importer.py index 431646b0e5..4630969dae 100644 --- a/zerver/tests/test_mattermost_importer.py +++ b/zerver/tests/test_mattermost_importer.py @@ -309,7 +309,7 @@ class MatterMostImporter(ZulipTestCase): self.assertEqual(zerver_realm_emoji[1]["deactivated"], False) records_file = os.path.join(output_dir, "emoji", "records.json") - with open(records_file, "r") as f: + with open(records_file) as f: records_json = ujson.load(f) self.assertEqual(records_json[0]["file_name"], "peerdium") @@ -475,11 +475,11 @@ class MatterMostImporter(ZulipTestCase): world_map_emoji_code = name_to_codepoint["world_map"] self.assertEqual(len(total_reactions), 4) - self.assertEqual(self.get_set(total_reactions, "reaction_type"), set([Reaction.REALM_EMOJI, Reaction.UNICODE_EMOJI])) - self.assertEqual(self.get_set(total_reactions, "emoji_name"), set(["tick", "smile", "world_map"])) - self.assertEqual(self.get_set(total_reactions, "emoji_code"), set([tick_emoji_code, smile_emoji_code, - world_map_emoji_code])) - self.assertEqual(self.get_set(total_reactions, "user_profile"), set([harry_id, ron_id])) + self.assertEqual(self.get_set(total_reactions, "reaction_type"), {Reaction.REALM_EMOJI, Reaction.UNICODE_EMOJI}) + self.assertEqual(self.get_set(total_reactions, "emoji_name"), {"tick", "smile", "world_map"}) + self.assertEqual(self.get_set(total_reactions, "emoji_code"), {tick_emoji_code, smile_emoji_code, + world_map_emoji_code}) + self.assertEqual(self.get_set(total_reactions, "user_profile"), {harry_id, ron_id}) self.assertEqual(len(self.get_set(total_reactions, "id")), 4) self.assertEqual(len(self.get_set(total_reactions, "message")), 1) @@ -513,23 +513,23 @@ class MatterMostImporter(ZulipTestCase): exported_user_ids = self.get_set(realm['zerver_userprofile'], 'id') exported_user_full_names = self.get_set(realm['zerver_userprofile'], 'full_name') - self.assertEqual(set(['Harry Potter', 'Ron Weasley', 'Severus Snape']), exported_user_full_names) + self.assertEqual({'Harry Potter', 'Ron Weasley', 'Severus Snape'}, exported_user_full_names) exported_user_emails = self.get_set(realm['zerver_userprofile'], 'email') - self.assertEqual(set(['harry@zulip.com', 'ron@zulip.com', 'snape@zulip.com']), exported_user_emails) + self.assertEqual({'harry@zulip.com', 'ron@zulip.com', 'snape@zulip.com'}, exported_user_emails) self.assertEqual(len(realm['zerver_stream']), 3) exported_stream_names = self.get_set(realm['zerver_stream'], 'name') - self.assertEqual(exported_stream_names, set(['Gryffindor common room', 'Gryffindor quidditch team', 'Dumbledores army'])) - self.assertEqual(self.get_set(realm['zerver_stream'], 'realm'), set([realm['zerver_realm'][0]['id']])) - self.assertEqual(self.get_set(realm['zerver_stream'], 'deactivated'), set([False])) + self.assertEqual(exported_stream_names, {'Gryffindor common room', 'Gryffindor quidditch team', 'Dumbledores army'}) + self.assertEqual(self.get_set(realm['zerver_stream'], 'realm'), {realm['zerver_realm'][0]['id']}) + self.assertEqual(self.get_set(realm['zerver_stream'], 'deactivated'), {False}) self.assertEqual(len(realm['zerver_defaultstream']), 0) exported_recipient_ids = self.get_set(realm['zerver_recipient'], 'id') self.assertEqual(len(exported_recipient_ids), 6) exported_recipient_types = self.get_set(realm['zerver_recipient'], 'type') - self.assertEqual(exported_recipient_types, set([1, 2])) + self.assertEqual(exported_recipient_types, {1, 2}) exported_recipient_type_ids = self.get_set(realm['zerver_recipient'], 'type_id') self.assertEqual(len(exported_recipient_type_ids), 3) @@ -586,23 +586,23 @@ class MatterMostImporter(ZulipTestCase): exported_user_ids = self.get_set(realm['zerver_userprofile'], 'id') exported_user_full_names = self.get_set(realm['zerver_userprofile'], 'full_name') - self.assertEqual(set(['Harry Potter', 'Ron Weasley', 'Ginny Weasley', 'Tom Riddle']), exported_user_full_names) + self.assertEqual({'Harry Potter', 'Ron Weasley', 'Ginny Weasley', 'Tom Riddle'}, exported_user_full_names) exported_user_emails = self.get_set(realm['zerver_userprofile'], 'email') - self.assertEqual(set(['harry@zulip.com', 'ron@zulip.com', 'ginny@zulip.com', 'voldemort@zulip.com']), exported_user_emails) + self.assertEqual({'harry@zulip.com', 'ron@zulip.com', 'ginny@zulip.com', 'voldemort@zulip.com'}, exported_user_emails) self.assertEqual(len(realm['zerver_stream']), 3) exported_stream_names = self.get_set(realm['zerver_stream'], 'name') - self.assertEqual(exported_stream_names, set(['Gryffindor common room', 'Gryffindor quidditch team', 'Dumbledores army'])) - self.assertEqual(self.get_set(realm['zerver_stream'], 'realm'), set([realm['zerver_realm'][0]['id']])) - self.assertEqual(self.get_set(realm['zerver_stream'], 'deactivated'), set([False])) + self.assertEqual(exported_stream_names, {'Gryffindor common room', 'Gryffindor quidditch team', 'Dumbledores army'}) + self.assertEqual(self.get_set(realm['zerver_stream'], 'realm'), {realm['zerver_realm'][0]['id']}) + self.assertEqual(self.get_set(realm['zerver_stream'], 'deactivated'), {False}) self.assertEqual(len(realm['zerver_defaultstream']), 0) exported_recipient_ids = self.get_set(realm['zerver_recipient'], 'id') self.assertEqual(len(exported_recipient_ids), 8) exported_recipient_types = self.get_set(realm['zerver_recipient'], 'type') - self.assertEqual(exported_recipient_types, set([1, 2, 3])) + self.assertEqual(exported_recipient_types, {1, 2, 3}) exported_recipient_type_ids = self.get_set(realm['zerver_recipient'], 'type_id') self.assertEqual(len(exported_recipient_type_ids), 4) diff --git a/zerver/tests/test_message_edit_notifications.py b/zerver/tests/test_message_edit_notifications.py index 87008c185a..654305fb1a 100644 --- a/zerver/tests/test_message_edit_notifications.py +++ b/zerver/tests/test_message_edit_notifications.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Any, Dict, Mapping, Union import mock diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index 2c0f52b25a..d3789b6717 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import IntegrityError from django.db.models import Q from django.conf import settings @@ -1204,15 +1203,15 @@ class StreamMessagesTest(ZulipTestCase): self.login('hamlet') # Subscribe everyone to a stream with non-ASCII characters. - non_ascii_stream_name = u"hümbüǵ" + non_ascii_stream_name = "hümbüǵ" realm = get_realm("zulip") stream = self.make_stream(non_ascii_stream_name) for user_profile in UserProfile.objects.filter(is_active=True, is_bot=False, realm=realm)[0:3]: self.subscribe(user_profile, stream.name) - self.assert_stream_message(non_ascii_stream_name, topic_name=u"hümbüǵ", - content=u"hümbüǵ") + self.assert_stream_message(non_ascii_stream_name, topic_name="hümbüǵ", + content="hümbüǵ") def test_get_raw_unread_data_for_huddle_messages(self) -> None: users = [ @@ -1238,8 +1237,8 @@ class StreamMessagesTest(ZulipTestCase): recent_conversations = get_recent_private_conversations(users[1]) self.assertEqual(len(recent_conversations), 1) recent_conversation = list(recent_conversations.values())[0] - self.assertEqual(set(recent_conversation['user_ids']), set(user.id for user in users if - user != users[1])) + self.assertEqual(set(recent_conversation['user_ids']), {user.id for user in users if + user != users[1]}) self.assertEqual(recent_conversation['max_message_id'], message2_id) class MessageDictTest(ZulipTestCase): @@ -1364,7 +1363,7 @@ class MessageDictTest(ZulipTestCase): sender = self.example_user('othello') receiver = self.example_user('hamlet') pm_recipient = Recipient.objects.get(type_id=receiver.id, type=Recipient.PERSONAL) - stream_name = u'Çiğdem' + stream_name = 'Çiğdem' stream = self.make_stream(stream_name) stream_recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM) sending_client = make_client(name="test suite") @@ -1556,7 +1555,7 @@ class SewMessageAndReactionTest(ZulipTestCase): sender = self.example_user('othello') receiver = self.example_user('hamlet') pm_recipient = Recipient.objects.get(type_id=receiver.id, type=Recipient.PERSONAL) - stream_name = u'Çiğdem' + stream_name = 'Çiğdem' stream = self.make_stream(stream_name) stream_recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM) sending_client = make_client(name="test suite") @@ -1846,7 +1845,7 @@ class MessagePOSTTest(ZulipTestCase): self.assertEqual(len(recent_conversations), 1) recent_conversation = list(recent_conversations.values())[0] recipient_id = list(recent_conversations.keys())[0] - self.assertEqual(set(recent_conversation['user_ids']), set([othello.id])) + self.assertEqual(set(recent_conversation['user_ids']), {othello.id}) self.assertEqual(recent_conversation['max_message_id'], message_id) # Now send a message to yourself and see how that interacts with the data structure @@ -1860,14 +1859,14 @@ class MessagePOSTTest(ZulipTestCase): recent_conversations = get_recent_private_conversations(user_profile) self.assertEqual(len(recent_conversations), 2) recent_conversation = recent_conversations[recipient_id] - self.assertEqual(set(recent_conversation['user_ids']), set([othello.id])) + self.assertEqual(set(recent_conversation['user_ids']), {othello.id}) self.assertEqual(recent_conversation['max_message_id'], message_id) # Now verify we have the appropriate self-pm data structure del recent_conversations[recipient_id] recent_conversation = list(recent_conversations.values())[0] recipient_id = list(recent_conversations.keys())[0] - self.assertEqual(set(recent_conversation['user_ids']), set([])) + self.assertEqual(set(recent_conversation['user_ids']), set()) self.assertEqual(recent_conversation['max_message_id'], self_message_id) def test_personal_message_by_id(self) -> None: @@ -2122,7 +2121,7 @@ class MessagePOSTTest(ZulipTestCase): """ self.login('hamlet') post_data = {"type": "stream", "to": "Verona", "client": "test suite", - "content": u" I like null bytes \x00 in my content", "topic": "Test topic"} + "content": " I like null bytes \x00 in my content", "topic": "Test topic"} result = self.client_post("/json/messages", post_data) self.assert_json_error(result, "Message must not contain null bytes") @@ -2966,8 +2965,8 @@ class EditMessageTest(ZulipTestCase): self.assertEqual(history[0]['prev_content'], 'content 1') self.assertEqual(history[0]['user_id'], hamlet.id) self.assertEqual(set(history[0].keys()), - {u'timestamp', u'prev_content', u'user_id', - u'prev_rendered_content', u'prev_rendered_content_version'}) + {'timestamp', 'prev_content', 'user_id', + 'prev_rendered_content', 'prev_rendered_content_version'}) result = self.client_patch("/json/messages/" + str(msg_id), { 'message_id': msg_id, @@ -3030,7 +3029,7 @@ class EditMessageTest(ZulipTestCase): message_history = list(reversed(json_response['message_history'])) i = 0 for entry in message_history: - expected_entries = {u'content', u'rendered_content', u'topic', u'timestamp', u'user_id'} + expected_entries = {'content', 'rendered_content', 'topic', 'timestamp', 'user_id'} if i in {0, 2, 3}: expected_entries.add('prev_topic') if i in {1, 2, 4}: @@ -4299,7 +4298,7 @@ class CheckMessageTest(ZulipTestCase): def test_basic_check_message_call(self) -> None: sender = self.example_user('othello') client = make_client(name="test suite") - stream_name = u'España y Francia' + stream_name = 'España y Francia' self.make_stream(stream_name) topic_name = 'issue' message_content = 'whatever' @@ -4324,7 +4323,7 @@ class CheckMessageTest(ZulipTestCase): sender = bot client = make_client(name="test suite") - stream_name = u'Россия' + stream_name = 'Россия' topic_name = 'issue' addressee = Addressee.for_stream_name(stream_name, topic_name) message_content = 'whatever' diff --git a/zerver/tests/test_muting.py b/zerver/tests/test_muting.py index 4a0324a054..3e4186cbd9 100644 --- a/zerver/tests/test_muting.py +++ b/zerver/tests/test_muting.py @@ -23,7 +23,7 @@ class MutedTopicsTests(ZulipTestCase): hamlet = self.example_user('hamlet') cordelia = self.example_user('cordelia') realm = hamlet.realm - stream = get_stream(u'Verona', realm) + stream = get_stream('Verona', realm) recipient = stream.recipient topic_name = 'teST topic' @@ -89,7 +89,7 @@ class MutedTopicsTests(ZulipTestCase): realm = user.realm self.login_user(user) - stream = get_stream(u'Verona', realm) + stream = get_stream('Verona', realm) recipient = stream.recipient url = '/api/v1/users/me/subscriptions/muted_topics' @@ -125,7 +125,7 @@ class MutedTopicsTests(ZulipTestCase): user_profile=user, stream_id=stream.id, recipient_id=recipient.id, - topic_name=u'Verona3', + topic_name='Verona3', date_muted=timezone_now(), ) diff --git a/zerver/tests/test_narrow.py b/zerver/tests/test_narrow.py index f976d8170f..a671411214 100644 --- a/zerver/tests/test_narrow.py +++ b/zerver/tests/test_narrow.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - from django.db import connection from django.test import TestCase, override_settings from sqlalchemy.sql import ( @@ -457,7 +454,7 @@ class NarrowLibraryTest(TestCase): def test_build_narrow_filter(self) -> None: fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures/narrow.json') - with open(fixtures_path, 'r') as f: + with open(fixtures_path) as f: scenarios = ujson.load(f) self.assertTrue(len(scenarios) == 9) for scenario in scenarios: @@ -1457,17 +1454,17 @@ class GetOldMessagesTest(ZulipTestCase): # We need to susbcribe to a stream and then send a message to # it to ensure that we actually have a stream message in this # narrow view. - lambda_stream_name = u"\u03bb-stream" + lambda_stream_name = "\u03bb-stream" stream = self.subscribe(user, lambda_stream_name) self.assertTrue(stream.is_in_zephyr_realm) - lambda_stream_d_name = u"\u03bb-stream.d" + lambda_stream_d_name = "\u03bb-stream.d" self.subscribe(user, lambda_stream_d_name) - self.send_stream_message(user, u"\u03bb-stream") - self.send_stream_message(user, u"\u03bb-stream.d") + self.send_stream_message(user, "\u03bb-stream") + self.send_stream_message(user, "\u03bb-stream.d") - narrow = [dict(operator='stream', operand=u'\u03bb-stream')] + narrow = [dict(operator='stream', operand='\u03bb-stream')] result = self.get_and_check_messages(dict(num_after=2, narrow=ujson.dumps(narrow)), subdomain="zephyr") @@ -1492,13 +1489,13 @@ class GetOldMessagesTest(ZulipTestCase): # it to ensure that we actually have a stream message in this # narrow view. self.subscribe(mit_user_profile, "Scotland") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"\u03bb-topic") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"\u03bb-topic.d") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"\u03bb-topic.d.d") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"\u03bb-topic.d.d.d") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"\u03bb-topic.d.d.d.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="\u03bb-topic") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="\u03bb-topic.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="\u03bb-topic.d.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="\u03bb-topic.d.d.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="\u03bb-topic.d.d.d.d") - narrow = [dict(operator='topic', operand=u'\u03bb-topic')] + narrow = [dict(operator='topic', operand='\u03bb-topic')] result = self.get_and_check_messages( dict(num_after=100, narrow=ujson.dumps(narrow)), subdomain="zephyr") @@ -1523,15 +1520,15 @@ class GetOldMessagesTest(ZulipTestCase): self.login_user(mit_user_profile) self.subscribe(mit_user_profile, "Scotland") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u".d.d") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"PERSONAL") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u'(instance "").d') - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u".d.d.d") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u"personal.d") - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u'(instance "")') - self.send_stream_message(mit_user_profile, "Scotland", topic_name=u".d.d.d.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name=".d.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="PERSONAL") + self.send_stream_message(mit_user_profile, "Scotland", topic_name='(instance "").d') + self.send_stream_message(mit_user_profile, "Scotland", topic_name=".d.d.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name="personal.d") + self.send_stream_message(mit_user_profile, "Scotland", topic_name='(instance "")') + self.send_stream_message(mit_user_profile, "Scotland", topic_name=".d.d.d.d") - narrow = [dict(operator='topic', operand=u'personal.d.d')] + narrow = [dict(operator='topic', operand='personal.d.d')] result = self.get_and_check_messages( dict(num_before=50, num_after=50, @@ -1616,7 +1613,7 @@ class GetOldMessagesTest(ZulipTestCase): self.assertEqual(len(list(messages.keys())), 1) message = messages[str(good_id)] self.assertEqual(message['match_content'], - u'

KEYWORDMATCH and should work

') + '

KEYWORDMATCH and should work

') @override_settings(USING_PGROONGA=False) def test_get_messages_with_search(self) -> None: @@ -1629,10 +1626,10 @@ class GetOldMessagesTest(ZulipTestCase): ('meetings', 'please bring your laptops to take notes'), ('dinner', 'Anybody staying late tonight?'), ('urltest', 'https://google.com'), - (u'日本', u'こんに ちは 。 今日は いい 天気ですね。'), - (u'日本', u'今朝はごはんを食べました。'), - (u'日本', u'昨日、日本 のお菓子を送りました。'), - ('english', u'I want to go to 日本!'), + ('日本', 'こんに ちは 。 今日は いい 天気ですね。'), + ('日本', '今朝はごはんを食べました。'), + ('日本', '昨日、日本 のお菓子を送りました。'), + ('english', 'I want to go to 日本!'), ] next_message_id = self.get_last_message().id + 1 @@ -1712,7 +1709,7 @@ class GetOldMessagesTest(ZulipTestCase): # Test searching in messages with unicode characters narrow = [ - dict(operator='search', operand=u'日本'), + dict(operator='search', operand='日本'), ] result = self.get_and_check_messages(dict( narrow=ujson.dumps(narrow), @@ -1725,14 +1722,14 @@ class GetOldMessagesTest(ZulipTestCase): japanese_message = [ m for m in messages - if m[TOPIC_NAME] == u'日本'][-1] + if m[TOPIC_NAME] == '日本'][-1] self.assertEqual( japanese_message[MATCH_TOPIC], - u'日本') + '日本') self.assertEqual( japanese_message['match_content'], - u'

昨日、日本' + - u' のお菓子を送りました。

') + '

昨日、日本' + + ' のお菓子を送りました。

') (english_message,) = [ m for m in messages @@ -1743,7 +1740,7 @@ class GetOldMessagesTest(ZulipTestCase): 'english') self.assertIn( english_message['match_content'], - u'

I want to go to 日本!

') + '

I want to go to 日本!

') # Multiple search operands with unicode multi_search_narrow = [ @@ -1815,10 +1812,10 @@ class GetOldMessagesTest(ZulipTestCase): next_message_id = self.get_last_message().id + 1 messages_to_search = [ - (u'日本語', u'こんにちは。今日はいい天気ですね。'), - (u'日本語', u'今朝はごはんを食べました。'), - (u'日本語', u'昨日、日本のお菓子を送りました。'), - ('english', u'I want to go to 日本!'), + ('日本語', 'こんにちは。今日はいい天気ですね。'), + ('日本語', '今朝はごはんを食べました。'), + ('日本語', '昨日、日本のお菓子を送りました。'), + ('english', 'I want to go to 日本!'), ('english', 'Can you speak https://en.wikipedia.org/wiki/Japanese?'), ('english', 'https://google.com'), ('bread & butter', 'chalk & cheese'), @@ -1843,7 +1840,7 @@ class GetOldMessagesTest(ZulipTestCase): """) narrow = [ - dict(operator='search', operand=u'日本'), + dict(operator='search', operand='日本'), ] result = self.get_and_check_messages(dict( narrow=ujson.dumps(narrow), @@ -1854,14 +1851,14 @@ class GetOldMessagesTest(ZulipTestCase): self.assertEqual(len(result['messages']), 4) messages = result['messages'] - japanese_message = [m for m in messages if m[TOPIC_NAME] == u'日本語'][-1] + japanese_message = [m for m in messages if m[TOPIC_NAME] == '日本語'][-1] self.assertEqual( japanese_message[MATCH_TOPIC], - u'日本語') + '日本語') self.assertEqual( japanese_message['match_content'], - u'

昨日、日本の' + - u'お菓子を送りました。

') + '

昨日、日本の' + + 'お菓子を送りました。

') english_message = [m for m in messages if m[TOPIC_NAME] == 'english'][0] self.assertEqual( @@ -1872,8 +1869,8 @@ class GetOldMessagesTest(ZulipTestCase): # NOTE: The whitespace here is off due to a pgroonga bug. # This bug is a pgroonga regression and according to one of # the author, this should be fixed in its next release. - [u'

I want to go to 日本!

', # This is correct. - u'

I want to go to 日本!

', ]) + ['

I want to go to 日本!

', # This is correct. + '

I want to go to 日本!

', ]) # Should not crash when multiple search operands are present multi_search_narrow = [ diff --git a/zerver/tests/test_onboarding.py b/zerver/tests/test_onboarding.py index c14319d462..cd34ad4f15 100644 --- a/zerver/tests/test_onboarding.py +++ b/zerver/tests/test_onboarding.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from zerver.models import Realm, UserProfile from zerver.lib.onboarding import create_if_missing_realm_internal_bots from zerver.lib.test_classes import ( diff --git a/zerver/tests/test_openapi.py b/zerver/tests/test_openapi.py index 5a21ec3019..449b0d26cc 100644 --- a/zerver/tests/test_openapi.py +++ b/zerver/tests/test_openapi.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import re import sys import mock @@ -162,7 +160,7 @@ class OpenAPIToolsTest(ZulipTestCase): class OpenAPIArgumentsTest(ZulipTestCase): # This will be filled during test_openapi_arguments: checked_endpoints = set() # type: Set[str] - pending_endpoints = set([ + pending_endpoints = { #### TODO: These endpoints are a priority to document: '/messages/matches_narrow', '/realm/presence', @@ -268,7 +266,7 @@ class OpenAPIArgumentsTest(ZulipTestCase): '/user_groups/{user_group_id}/members', # Regex with an unnamed capturing group. '/users/(?!me/)(?P[^/]*)/presence', - ]) + } # Endpoints where the documentation is currently failing our # consistency tests. We aim to keep this list empty. @@ -612,9 +610,9 @@ so maybe we shouldn't include it in pending_endpoints. # argument list matches what actually appears in the # codebase. - openapi_parameter_names = set( - [parameter['name'] for parameter in openapi_parameters] - ) + openapi_parameter_names = { + parameter['name'] for parameter in openapi_parameters + } if len(accepted_arguments - openapi_parameter_names) > 0: # nocoverage print("Undocumented parameters for", diff --git a/zerver/tests/test_outgoing_webhook_interfaces.py b/zerver/tests/test_outgoing_webhook_interfaces.py index 36358fd3cb..3359f07ac8 100644 --- a/zerver/tests/test_outgoing_webhook_interfaces.py +++ b/zerver/tests/test_outgoing_webhook_interfaces.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import cast, Any, Dict import mock @@ -111,9 +110,9 @@ class TestGenericOutgoingWebhookService(ZulipTestCase): wide_message_dict = MessageDict.wide_dict(message) event = { - u'command': '@**test**', - u'message': wide_message_dict, - u'trigger': 'mention', + 'command': '@**test**', + 'message': wide_message_dict, + 'trigger': 'mention', } request_data = self.handler.build_bot_request(event) @@ -155,11 +154,11 @@ class TestSlackOutgoingWebhookService(ZulipTestCase): def setUp(self) -> None: super().setUp() self.stream_message_event = { - u'command': '@**test**', - u'user_profile_id': 12, - u'service_name': 'test-service', - u'trigger': 'mention', - u'message': { + 'command': '@**test**', + 'user_profile_id': 12, + 'service_name': 'test-service', + 'trigger': 'mention', + 'message': { 'content': 'test_content', 'type': 'stream', 'sender_realm_str': 'zulip', @@ -173,11 +172,11 @@ class TestSlackOutgoingWebhookService(ZulipTestCase): } self.private_message_event = { - u'user_profile_id': 24, - u'service_name': 'test-service', - u'command': 'test content', - u'trigger': 'private_message', - u'message': { + 'user_profile_id': 24, + 'service_name': 'test-service', + 'command': 'test content', + 'trigger': 'private_message', + 'message': { 'sender_id': 3, 'sender_realm_str': 'zulip', 'timestamp': 1529821610, diff --git a/zerver/tests/test_outgoing_webhook_system.py b/zerver/tests/test_outgoing_webhook_system.py index 493f879f42..7f18f71574 100644 --- a/zerver/tests/test_outgoing_webhook_system.py +++ b/zerver/tests/test_outgoing_webhook_system.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import ujson import logging import mock diff --git a/zerver/tests/test_presence.py b/zerver/tests/test_presence.py index 747a3e542e..911570b5cd 100644 --- a/zerver/tests/test_presence.py +++ b/zerver/tests/test_presence.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from datetime import timedelta from django.utils.timezone import now as timezone_now import mock diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index 4f097d6b82..1909c6d45d 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -625,7 +625,7 @@ class PushNotificationTest(BouncerTestCase): yield mock_apns def setup_apns_tokens(self) -> None: - self.tokens = [u'aaaa', u'bbbb'] + self.tokens = ['aaaa', 'bbbb'] for token in self.tokens: PushDeviceToken.objects.create( kind=PushDeviceToken.APNS, @@ -633,7 +633,7 @@ class PushNotificationTest(BouncerTestCase): user=self.user_profile, ios_app_id=settings.ZULIP_IOS_APP_ID) - self.remote_tokens = [u'cccc'] + self.remote_tokens = ['cccc'] for token in self.remote_tokens: RemotePushDeviceToken.objects.create( kind=RemotePushDeviceToken.APNS, @@ -643,7 +643,7 @@ class PushNotificationTest(BouncerTestCase): ) def setup_gcm_tokens(self) -> None: - self.gcm_tokens = [u'1111', u'2222'] + self.gcm_tokens = ['1111', '2222'] for token in self.gcm_tokens: PushDeviceToken.objects.create( kind=PushDeviceToken.GCM, @@ -651,7 +651,7 @@ class PushNotificationTest(BouncerTestCase): user=self.user_profile, ios_app_id=None) - self.remote_gcm_tokens = [u'dddd'] + self.remote_gcm_tokens = ['dddd'] for token in self.remote_gcm_tokens: RemotePushDeviceToken.objects.create( kind=RemotePushDeviceToken.GCM, @@ -1682,8 +1682,8 @@ class GCMSendTest(PushNotificationTest): def test_canonical_pushdevice_not_present(self, mock_warning: mock.MagicMock, mock_gcm: mock.MagicMock) -> None: res = {} - t1 = hex_to_b64(u'1111') - t2 = hex_to_b64(u'3333') + t1 = hex_to_b64('1111') + t2 = hex_to_b64('3333') res['canonical'] = {t1: t2} mock_gcm.json_request.return_value = res @@ -1692,8 +1692,8 @@ class GCMSendTest(PushNotificationTest): return PushDeviceToken.objects.filter( token=token, kind=PushDeviceToken.GCM).count() - self.assertEqual(get_count(u'1111'), 1) - self.assertEqual(get_count(u'3333'), 0) + self.assertEqual(get_count('1111'), 1) + self.assertEqual(get_count('3333'), 0) data = self.get_gcm_data() send_android_push_notification_to_user(self.user_profile, data, {}) @@ -1702,15 +1702,15 @@ class GCMSendTest(PushNotificationTest): "registered! Updating.") mock_warning.assert_called_once_with(msg % (t2, t1)) - self.assertEqual(get_count(u'1111'), 0) - self.assertEqual(get_count(u'3333'), 1) + self.assertEqual(get_count('1111'), 0) + self.assertEqual(get_count('3333'), 1) @mock.patch('zerver.lib.push_notifications.logger.info') def test_canonical_pushdevice_different(self, mock_info: mock.MagicMock, mock_gcm: mock.MagicMock) -> None: res = {} - old_token = hex_to_b64(u'1111') - new_token = hex_to_b64(u'2222') + old_token = hex_to_b64('1111') + new_token = hex_to_b64('2222') res['canonical'] = {old_token: new_token} mock_gcm.json_request.return_value = res @@ -1719,21 +1719,21 @@ class GCMSendTest(PushNotificationTest): return PushDeviceToken.objects.filter( token=token, kind=PushDeviceToken.GCM).count() - self.assertEqual(get_count(u'1111'), 1) - self.assertEqual(get_count(u'2222'), 1) + self.assertEqual(get_count('1111'), 1) + self.assertEqual(get_count('2222'), 1) data = self.get_gcm_data() send_android_push_notification_to_user(self.user_profile, data, {}) mock_info.assert_called_once_with( "GCM: Got canonical ref %s, dropping %s" % (new_token, old_token)) - self.assertEqual(get_count(u'1111'), 0) - self.assertEqual(get_count(u'2222'), 1) + self.assertEqual(get_count('1111'), 0) + self.assertEqual(get_count('2222'), 1) @mock.patch('zerver.lib.push_notifications.logger.info') def test_not_registered(self, mock_info: mock.MagicMock, mock_gcm: mock.MagicMock) -> None: res = {} - token = hex_to_b64(u'1111') + token = hex_to_b64('1111') res['errors'] = {'NotRegistered': [token]} mock_gcm.json_request.return_value = res @@ -1742,17 +1742,17 @@ class GCMSendTest(PushNotificationTest): return PushDeviceToken.objects.filter( token=token, kind=PushDeviceToken.GCM).count() - self.assertEqual(get_count(u'1111'), 1) + self.assertEqual(get_count('1111'), 1) data = self.get_gcm_data() send_android_push_notification_to_user(self.user_profile, data, {}) mock_info.assert_called_once_with("GCM: Removing %s" % (token,)) - self.assertEqual(get_count(u'1111'), 0) + self.assertEqual(get_count('1111'), 0) @mock.patch('zerver.lib.push_notifications.logger.warning') def test_failure(self, mock_warn: mock.MagicMock, mock_gcm: mock.MagicMock) -> None: res = {} - token = hex_to_b64(u'1111') + token = hex_to_b64('1111') res['errors'] = {'Failed': [token]} mock_gcm.json_request.return_value = res @@ -1792,7 +1792,7 @@ class TestClearOnRead(ZulipTestCase): for g in groups[:-1]: self.assertEqual(len(g), 1) self.assertEqual(sum(len(g) for g in groups), len(message_ids)) - self.assertEqual(set(id for g in groups for id in g), set(message_ids)) + self.assertEqual({id for g in groups for id in g}, set(message_ids)) class TestReceivesNotificationsFunctions(ZulipTestCase): def setUp(self) -> None: diff --git a/zerver/tests/test_queue_worker.py b/zerver/tests/test_queue_worker.py index bf0ec728f3..c1e2733ca9 100644 --- a/zerver/tests/test_queue_worker.py +++ b/zerver/tests/test_queue_worker.py @@ -340,7 +340,7 @@ class WorkerTest(ZulipTestCase): stream_to_address = encode_email_address(stream) data = [ dict( - message=u'\xf3test', + message='\xf3test', time=time.time(), rcpt_to=stream_to_address ) @@ -367,7 +367,7 @@ class WorkerTest(ZulipTestCase): stream_to_address = encode_email_address(stream) data = [ dict( - message=u'\xf3test', + message='\xf3test', time=time.time(), rcpt_to=stream_to_address ) @@ -394,7 +394,7 @@ class WorkerTest(ZulipTestCase): with self.settings(EMAIL_GATEWAY_PATTERN="%s@example.com"): address = 'mm' + ('x' * 32) + '@example.com' event = dict( - message=u'\xf3test', + message='\xf3test', time=time.time(), rcpt_to=address ) @@ -580,7 +580,7 @@ class WorkerTest(ZulipTestCase): "Problem handling data on queue unreliable_worker") self.assertEqual(processed, ['good', 'fine', 'back to normal']) - with open(fn, 'r') as f: + with open(fn) as f: line = f.readline().strip() events = ujson.loads(line.split('\t')[1]) self.assert_length(events, 1) @@ -617,7 +617,7 @@ class WorkerTest(ZulipTestCase): "Problem handling data on queue unreliable_loopworker") self.assertEqual(processed, ['good', 'fine']) - with open(fn, 'r') as f: + with open(fn) as f: line = f.readline().strip() events = ujson.loads(line.split('\t')[1]) self.assert_length(events, 4) diff --git a/zerver/tests/test_reactions.py b/zerver/tests/test_reactions.py index 5696a6d1f4..8aacb9dd21 100644 --- a/zerver/tests/test_reactions.py +++ b/zerver/tests/test_reactions.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import ujson from django.http import HttpResponse from typing import Any, Dict, List, Mapping @@ -356,7 +354,7 @@ class ReactionEventTest(ZulipTestCase): self.assert_json_success(result) pm_id = result.json()['id'] - expected_recipient_ids = set([pm_sender.id, pm_recipient.id]) + expected_recipient_ids = {pm_sender.id, pm_recipient.id} reaction_info = { 'emoji_name': 'smile' @@ -396,7 +394,7 @@ class ReactionEventTest(ZulipTestCase): content = result.json() pm_id = content['id'] - expected_recipient_ids = set([pm_sender.id, pm_recipient.id]) + expected_recipient_ids = {pm_sender.id, pm_recipient.id} reaction_info = { 'emoji_name': 'smile' @@ -815,7 +813,7 @@ class ReactionAPIEventTest(EmojiReactionBase): pm_recipient = self.example_user('othello') reaction_sender = pm_recipient pm_id = self.send_personal_message(pm_sender, pm_recipient) - expected_recipient_ids = set([pm_sender.id, pm_recipient.id]) + expected_recipient_ids = {pm_sender.id, pm_recipient.id} reaction_info = { 'emoji_name': 'hamburger', 'emoji_code': '1f354', @@ -852,7 +850,7 @@ class ReactionAPIEventTest(EmojiReactionBase): pm_recipient = self.example_user('othello') reaction_sender = pm_recipient pm_id = self.send_personal_message(pm_sender, pm_recipient) - expected_recipient_ids = set([pm_sender.id, pm_recipient.id]) + expected_recipient_ids = {pm_sender.id, pm_recipient.id} reaction_info = { 'emoji_name': 'hamburger', 'emoji_code': '1f354', diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 77b8953751..ae0d8db657 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -49,14 +49,14 @@ class RealmTest(ZulipTestCase): by checking the cache to ensure that the new value is there.""" self.example_user('hamlet') realm = get_realm('zulip') - new_name = u'Zed You Elle Eye Pea' + new_name = 'Zed You Elle Eye Pea' do_set_realm_property(realm, 'name', new_name) self.assertEqual(get_realm(realm.string_id).name, new_name) self.assert_user_profile_cache_gets_new_name(self.example_user('hamlet'), new_name) def test_update_realm_name_events(self) -> None: realm = get_realm('zulip') - new_name = u'Puliz' + new_name = 'Puliz' events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): do_set_realm_property(realm, 'name', new_name) @@ -70,7 +70,7 @@ class RealmTest(ZulipTestCase): def test_update_realm_description_events(self) -> None: realm = get_realm('zulip') - new_description = u'zulip dev group' + new_description = 'zulip dev group' events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): do_set_realm_property(realm, 'description', new_description) @@ -84,7 +84,7 @@ class RealmTest(ZulipTestCase): def test_update_realm_description(self) -> None: self.login('iago') - new_description = u'zulip dev group' + new_description = 'zulip dev group' data = dict(description=ujson.dumps(new_description)) events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): @@ -102,7 +102,7 @@ class RealmTest(ZulipTestCase): )) def test_realm_description_length(self) -> None: - new_description = u'A' * 1001 + new_description = 'A' * 1001 data = dict(description=ujson.dumps(new_description)) # create an admin user @@ -114,7 +114,7 @@ class RealmTest(ZulipTestCase): self.assertNotEqual(realm.description, new_description) def test_realm_name_length(self) -> None: - new_name = u'A' * (Realm.MAX_REALM_NAME_LENGTH + 1) + new_name = 'A' * (Realm.MAX_REALM_NAME_LENGTH + 1) data = dict(name=ujson.dumps(new_name)) # create an admin user @@ -715,12 +715,12 @@ class RealmAPITest(ZulipTestCase): bool_tests = [False, True] # type: List[bool] test_values = dict( - default_language=[u'de', u'en'], - default_code_block_language=[u'javascript', u''], - description=[u'Realm description', u'New description'], + default_language=['de', 'en'], + default_code_block_language=['javascript', ''], + description=['Realm description', 'New description'], digest_weekday=[0, 1, 2], message_retention_days=[10, 20], - name=[u'Zulip', u'New Name'], + name=['Zulip', 'New Name'], waiting_period_threshold=[10, 20], create_stream_policy=[Realm.POLICY_ADMINS_ONLY, Realm.POLICY_MEMBERS_ONLY, @@ -739,16 +739,16 @@ class RealmAPITest(ZulipTestCase): video_chat_provider=[ dict( video_chat_provider=ujson.dumps(Realm.VIDEO_CHAT_PROVIDERS['google_hangouts']['id']), - google_hangouts_domain=ujson.dumps(u'zulip.com') + google_hangouts_domain=ujson.dumps('zulip.com') ), dict( video_chat_provider=ujson.dumps(Realm.VIDEO_CHAT_PROVIDERS['jitsi_meet']['id']), ) ], - google_hangouts_domain=[u'zulip.com', u'zulip.org'], - zoom_api_secret=[u"abc", u"xyz"], - zoom_api_key=[u"abc", u"xyz"], - zoom_user_id=[u"example@example.com", u"example@example.org"] + google_hangouts_domain=['zulip.com', 'zulip.org'], + zoom_api_secret=["abc", "xyz"], + zoom_api_key=["abc", "xyz"], + zoom_user_id=["example@example.com", "example@example.org"] ) # type: Dict[str, Any] vals = test_values.get(name) diff --git a/zerver/tests/test_realm_domains.py b/zerver/tests/test_realm_domains.py index 901d5853b7..92bc0e1fdf 100644 --- a/zerver/tests/test_realm_domains.py +++ b/zerver/tests/test_realm_domains.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from django.core.exceptions import ValidationError from django.db.utils import IntegrityError diff --git a/zerver/tests/test_realm_emoji.py b/zerver/tests/test_realm_emoji.py index 5ff7c8ef5f..40c46ca16b 100644 --- a/zerver/tests/test_realm_emoji.py +++ b/zerver/tests/test_realm_emoji.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mock from zerver.lib.actions import do_create_realm, do_create_user, \ diff --git a/zerver/tests/test_realm_filters.py b/zerver/tests/test_realm_filters.py index 8870545ddc..90f3b8d167 100644 --- a/zerver/tests/test_realm_filters.py +++ b/zerver/tests/test_realm_filters.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import re from zerver.lib.actions import do_add_realm_filter @@ -109,9 +107,9 @@ class RealmFilterTest(ZulipTestCase): "#(?P[123])", "https://realm.com/my_realm_filter/%(id)s") filters_count = RealmFilter.objects.count() - result = self.client_delete("/json/realm/filters/{0}".format(filter_id + 1)) + result = self.client_delete("/json/realm/filters/{}".format(filter_id + 1)) self.assert_json_error(result, 'Filter not found') - result = self.client_delete("/json/realm/filters/{0}".format(filter_id)) + result = self.client_delete("/json/realm/filters/{}".format(filter_id)) self.assert_json_success(result) self.assertEqual(RealmFilter.objects.count(), filters_count - 1) diff --git a/zerver/tests/test_redis_utils.py b/zerver/tests/test_redis_utils.py index a0f844d731..cd17882d77 100644 --- a/zerver/tests/test_redis_utils.py +++ b/zerver/tests/test_redis_utils.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mock from zerver.lib.test_classes import ZulipTestCase diff --git a/zerver/tests/test_report.py b/zerver/tests/test_report.py index cfa9cb7c44..1c8dd91354 100644 --- a/zerver/tests/test_report.py +++ b/zerver/tests/test_report.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Any, Callable, Dict, Iterable, List, Tuple from django.test import override_settings @@ -121,7 +119,7 @@ class TestReport(ZulipTestCase): self.assert_json_success(result) report = m.call_args[0][1]['report'] - for k in set(params) - set(['ui_message', 'more_info']): + for k in set(params) - {'ui_message', 'more_info'}: self.assertEqual(report[k], params[k]) self.assertEqual(report['more_info'], dict(foo='bar', draft_content="'**xxxxx**'")) diff --git a/zerver/tests/test_retention.py b/zerver/tests/test_retention.py index 743429ac8d..e3d310d543 100644 --- a/zerver/tests/test_retention.py +++ b/zerver/tests/test_retention.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from datetime import datetime, timedelta from typing import Any, Dict, List, Optional from unittest import mock diff --git a/zerver/tests/test_service_bot_system.py b/zerver/tests/test_service_bot_system.py index 0aa4fe0414..0c1e61c0db 100644 --- a/zerver/tests/test_service_bot_system.py +++ b/zerver/tests/test_service_bot_system.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mock from typing import Any, Union, Mapping, Callable @@ -431,7 +429,7 @@ class TestServiceBotEventTriggers(ZulipTestCase): self.bot_profile.bot_type = bot_type self.bot_profile.save() - content = u'@**FooBot** foo bar!!!' + content = '@**FooBot** foo bar!!!' recipient = 'Denmark' trigger = 'mention' message_type = Recipient._type_names[Recipient.STREAM] @@ -469,7 +467,7 @@ class TestServiceBotEventTriggers(ZulipTestCase): self.send_stream_message( self.second_bot_profile, 'Denmark', - u'@**FooBot** foo bar!!!') + '@**FooBot** foo bar!!!') self.assertFalse(mock_queue_json_publish.called) @mock.patch('zerver.lib.actions.queue_json_publish') @@ -531,7 +529,7 @@ class TestServiceBotEventTriggers(ZulipTestCase): profile_ids.remove(trigger_event["user_profile_id"]) self.assertEqual(trigger_event["trigger"], "private_message") self.assertEqual(trigger_event["message"]["sender_email"], sender.email) - self.assertEqual(trigger_event["message"]["type"], u'private') + self.assertEqual(trigger_event["message"]["type"], 'private') mock_queue_json_publish.side_effect = check_values_passed self.send_huddle_message(sender, recipients, 'test') diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index f747fbe0f6..500ca53e65 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import datetime from email.utils import parseaddr @@ -672,7 +671,7 @@ class LoginTest(ZulipTestCase): You can log in even if your password contain non-ASCII characters. """ email = self.nonreg_email('test') - password = u"hümbüǵ" + password = "hümbüǵ" # Registering succeeds. self.register(email, password) @@ -1199,8 +1198,8 @@ earl-test@zulip.com""", ["Denmark"])) only sent to the new users. """ self.login('hamlet') - existing = [self.example_email("hamlet"), u"othello@zulip.com"] - new = [u"foo-test@zulip.com", u"bar-test@zulip.com"] + existing = [self.example_email("hamlet"), "othello@zulip.com"] + new = ["foo-test@zulip.com", "bar-test@zulip.com"] invitee_emails = "\n".join(existing + new) self.assert_json_error(self.invite(invitee_emails, ["Denmark"]), "Some of those addresses are already using Zulip, \ @@ -1365,7 +1364,7 @@ so we didn't send them an invitation. We did send invitations to everyone else!" self.login('hamlet') invitee = "alice-test@zulip.com" - stream_name = u"hümbüǵ" + stream_name = "hümbüǵ" # Make sure we're subscribed before inviting someone. self.subscribe(self.example_user("hamlet"), stream_name) @@ -2200,7 +2199,7 @@ class UserSignUpTest(InviteUserBase): password = "newpassword" timezone = "US/Mountain" realm = get_realm('zulip') - do_set_realm_property(realm, 'default_language', u"de") + do_set_realm_property(realm, 'default_language', "de") result = self.client_post('/accounts/home/', {'email': email}) self.assertEqual(result.status_code, 302) diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.py index 5280653973..275da44f19 100644 --- a/zerver/tests/test_slack_importer.py +++ b/zerver/tests/test_slack_importer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.utils.timezone import now as timezone_now @@ -440,7 +439,7 @@ class SlackImporter(ZulipTestCase): # We can't do an assertDictEqual since during the construction of Personal # recipients, slack_user_id_to_zulip_user_id are iterated in different order in Python 3.5 and 3.6. self.assertEqual(set(slack_recipient_name_to_zulip_recipient_id.keys()), slack_recipient_names) - self.assertEqual(set(slack_recipient_name_to_zulip_recipient_id.values()), set(i for i in range(11))) + self.assertEqual(set(slack_recipient_name_to_zulip_recipient_id.values()), {i for i in range(11)}) # functioning of zerver subscriptions are already tested in the helper functions # This is to check the concatenation of the output lists from the helper functions diff --git a/zerver/tests/test_slack_message_conversion.py b/zerver/tests/test_slack_message_conversion.py index 3e4afe8646..59ebc2a767 100644 --- a/zerver/tests/test_slack_message_conversion.py +++ b/zerver/tests/test_slack_message_conversion.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.data_import.slack_message_conversion import ( convert_to_zulip_markdown, get_user_full_name @@ -25,7 +24,7 @@ class SlackMessageConversion(ZulipTestCase): def load_slack_message_conversion_tests(self) -> Dict[Any, Any]: test_fixtures = {} with open(os.path.join(os.path.dirname(__file__), - 'fixtures/slack_message_conversion.json'), 'r') as f: + 'fixtures/slack_message_conversion.json')) as f: data = ujson.load(f) for test in data['regular_tests']: test_fixtures[test['name']] = test @@ -35,7 +34,7 @@ class SlackMessageConversion(ZulipTestCase): @slow("Aggregate of runs of individual slack message conversion tests") def test_message_conversion_fixtures(self) -> None: format_tests = self.load_slack_message_conversion_tests() - valid_keys = set(['name', "input", "conversion_output"]) + valid_keys = {'name', "input", "conversion_output"} for name, test in format_tests.items(): # Check that there aren't any unexpected keys as those are often typos diff --git a/zerver/tests/test_soft_deactivation.py b/zerver/tests/test_soft_deactivation.py index 3f2c7fac36..8917b1e09b 100644 --- a/zerver/tests/test_soft_deactivation.py +++ b/zerver/tests/test_soft_deactivation.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import mock from django.utils.timezone import now as timezone_now diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index feab5dbf3b..8dcdb6be8f 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from typing import Any, Dict, List, Mapping, Optional, Set from django.conf import settings @@ -111,8 +109,8 @@ class TestMiscStuff(ZulipTestCase): class TestCreateStreams(ZulipTestCase): def test_creating_streams(self) -> None: - stream_names = [u'new1', u'new2', u'new3'] - stream_descriptions = [u'des1', u'des2', u'des3'] + stream_names = ['new1', 'new2', 'new3'] + stream_descriptions = ['des1', 'des2', 'des3'] realm = get_realm('zulip') # Test stream creation events. @@ -476,7 +474,7 @@ class StreamAdminTest(ZulipTestCase): do_change_is_admin(user_profile, True) result = self.client_delete('/json/streams/999999999') - self.assert_json_error(result, u'Invalid stream id') + self.assert_json_error(result, 'Invalid stream id') def test_deactivate_stream_backend_requires_realm_admin(self) -> None: user_profile = self.example_user('hamlet') @@ -593,10 +591,10 @@ class StreamAdminTest(ZulipTestCase): with tornado_redirected_to_list(events): stream_id = stream_name2_exists.id result = self.client_patch('/json/streams/%d' % (stream_id,), - {'new_name': ujson.dumps(u'नया नाम'.encode('utf-8'))}) + {'new_name': ujson.dumps('नया नाम'.encode())}) self.assert_json_success(result) # While querying, system can handle unicode strings. - stream_name_uni_exists = get_stream(u'नया नाम', realm) + stream_name_uni_exists = get_stream('नया नाम', realm) self.assertTrue(stream_name_uni_exists) # Test case to handle changing of unicode stream name to newer name @@ -605,30 +603,30 @@ class StreamAdminTest(ZulipTestCase): with tornado_redirected_to_list(events): stream_id = stream_name_uni_exists.id result = self.client_patch('/json/streams/%d' % (stream_id,), - {'new_name': ujson.dumps(u'नाम में क्या रक्खा हे'.encode('utf-8'))}) + {'new_name': ujson.dumps('नाम में क्या रक्खा हे'.encode())}) self.assert_json_success(result) # While querying, system can handle unicode strings. - self.assertRaises(Stream.DoesNotExist, get_stream, u'नया नाम', realm) + self.assertRaises(Stream.DoesNotExist, get_stream, 'नया नाम', realm) - stream_name_new_uni_exists = get_stream(u'नाम में क्या रक्खा हे', realm) + stream_name_new_uni_exists = get_stream('नाम में क्या रक्खा हे', realm) self.assertTrue(stream_name_new_uni_exists) # Test case to change name from one language to other. with tornado_redirected_to_list(events): stream_id = stream_name_new_uni_exists.id result = self.client_patch('/json/streams/%d' % (stream_id,), - {'new_name': ujson.dumps(u'français'.encode('utf-8'))}) + {'new_name': ujson.dumps('français'.encode())}) self.assert_json_success(result) - stream_name_fr_exists = get_stream(u'français', realm) + stream_name_fr_exists = get_stream('français', realm) self.assertTrue(stream_name_fr_exists) # Test case to change name to mixed language name. with tornado_redirected_to_list(events): stream_id = stream_name_fr_exists.id result = self.client_patch('/json/streams/%d' % (stream_id,), - {'new_name': ujson.dumps(u'français name'.encode('utf-8'))}) + {'new_name': ujson.dumps('français name'.encode())}) self.assert_json_success(result) - stream_name_mixed_exists = get_stream(u'français name', realm) + stream_name_mixed_exists = get_stream('français name', realm) self.assertTrue(stream_name_mixed_exists) # Test case for notified users in private streams. @@ -956,7 +954,7 @@ class StreamAdminTest(ZulipTestCase): self.login_user(user_profile) # Set up the stream. - stream_name = u"hümbüǵ" + stream_name = "hümbüǵ" self.make_stream(stream_name, invite_only=invite_only) # Set up the principal to be unsubscribed. @@ -1178,7 +1176,7 @@ class StreamAdminTest(ZulipTestCase): self.login_user(admin) self.assertTrue(admin.is_realm_admin) - stream_name = u"hümbüǵ" + stream_name = "hümbüǵ" self.make_stream(stream_name) result = self.client_delete("/json/users/me/subscriptions", @@ -1202,7 +1200,7 @@ class DefaultStreamTest(ZulipTestCase): do_add_default_stream(stream) new_stream_names = self.get_default_stream_names(realm) added_stream_names = new_stream_names - orig_stream_names - self.assertEqual(added_stream_names, set(['Added Stream'])) + self.assertEqual(added_stream_names, {'Added Stream'}) # idempotentcy--2nd call to add_default_stream should be a noop do_add_default_stream(stream) self.assertEqual(self.get_default_stream_names(realm), new_stream_names) @@ -1517,7 +1515,7 @@ class DefaultStreamGroupTest(ZulipTestCase): {"group_name": 'x'*100, "description": description, "stream_names": ujson.dumps(stream_names)}) self.assert_json_error(result, "Default stream group name too long (limit: {} characters)" - .format((DefaultStreamGroup.MAX_NAME_LENGTH))) + .format(DefaultStreamGroup.MAX_NAME_LENGTH)) result = self.client_post('/json/default_stream_groups/create', {"group_name": "abc\000", "description": description, @@ -2095,7 +2093,7 @@ class SubscriptionAPITest(ZulipTestCase): are generated. """ self.assertNotEqual(len(self.streams), 0) # necessary for full test coverage - add_streams = [u"Verona2", u"Denmark5"] + add_streams = ["Verona2", "Denmark5"] self.assertNotEqual(len(add_streams), 0) # necessary for full test coverage events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): @@ -2113,7 +2111,7 @@ class SubscriptionAPITest(ZulipTestCase): are generated. """ self.assertNotEqual(len(self.streams), 0) - add_streams = [u"Verona2", u"Denmark5"] + add_streams = ["Verona2", "Denmark5"] self.assertNotEqual(len(add_streams), 0) events = [] # type: List[Mapping[str, Any]] other_params = { @@ -2255,9 +2253,9 @@ class SubscriptionAPITest(ZulipTestCase): """ Subscribing to a stream name with non-ASCII characters succeeds. """ - self.helper_check_subs_before_and_after_add(self.streams + [u"hümbüǵ"], {}, - [u"hümbüǵ"], self.streams, self.test_email, - self.streams + [u"hümbüǵ"], self.test_realm) + self.helper_check_subs_before_and_after_add(self.streams + ["hümbüǵ"], {}, + ["hümbüǵ"], self.streams, self.test_email, + self.streams + ["hümbüǵ"], self.test_realm) def test_subscriptions_add_too_long(self) -> None: """ @@ -2412,7 +2410,7 @@ class SubscriptionAPITest(ZulipTestCase): # verify that a welcome message was sent to the stream msg = self.get_last_message() self.assertEqual(msg.recipient.type, msg.recipient.STREAM) - self.assertEqual(msg.topic_name(), u'stream events') + self.assertEqual(msg.topic_name(), 'stream events') self.assertEqual(msg.sender.email, settings.NOTIFICATION_BOT) self.assertIn('Stream created by @_**', msg.content) @@ -2438,7 +2436,7 @@ class SubscriptionAPITest(ZulipTestCase): self.assertEqual(ev['event']['op'], 'add') self.assertEqual( set(ev['event']['subscriptions'][0]['subscribers']), - set([user1.id, user2.id]) + {user1.id, user2.id} ) else: # Check "peer_add" events for streams users were @@ -2467,7 +2465,7 @@ class SubscriptionAPITest(ZulipTestCase): self.assertEqual(add_event['users'], [get_user(self.test_email, self.test_realm).id]) self.assertEqual( set(add_event['event']['subscriptions'][0]['subscribers']), - set([user1.id, user2.id, self.test_user.id]) + {user1.id, user2.id, self.test_user.id} ) self.assertNotIn(self.example_user('polonius').id, add_peer_event['users']) @@ -2497,7 +2495,7 @@ class SubscriptionAPITest(ZulipTestCase): self.assertEqual(add_event['users'], [get_user(email3, realm3).id]) self.assertEqual( set(add_event['event']['subscriptions'][0]['subscribers']), - set([user1.id, user2.id, user3.id, self.test_user.id]) + {user1.id, user2.id, user3.id, self.test_user.id} ) # We don't send a peer_add event to othello @@ -2538,7 +2536,7 @@ class SubscriptionAPITest(ZulipTestCase): self.assertEqual(add_event['users'], [user_profile.id]) self.assertEqual( set(add_event['event']['subscriptions'][0]['subscribers']), - set([user_profile.id, existing_user_profile.id]) + {user_profile.id, existing_user_profile.id} ) # We don't send a peer_add event to othello, but we do send peer_add event to @@ -2877,7 +2875,7 @@ class SubscriptionAPITest(ZulipTestCase): non-ASCII characters. """ iago = self.example_user('iago') - self.assert_adding_subscriptions_for_principal(iago.email, get_realm('zulip'), [u"hümbüǵ"]) + self.assert_adding_subscriptions_for_principal(iago.email, get_realm('zulip'), ["hümbüǵ"]) def test_subscription_add_invalid_principal(self) -> None: """ @@ -3093,7 +3091,7 @@ class SubscriptionAPITest(ZulipTestCase): with mock.patch('zerver.models.Recipient.__str__', return_value='recip'): self.assertEqual(str(subscription), - u' -> recip>' % (user_profile.email, user_profile.realm)) self.assertIsNone(subscription.desktop_notifications) @@ -3429,7 +3427,7 @@ class StreamIdTest(ZulipTestCase): user = self.example_user('hamlet') self.login_user(user) result = self.client_get("/json/get_stream_id?stream=wrongname") - self.assert_json_error(result, u"Invalid stream name 'wrongname'") + self.assert_json_error(result, "Invalid stream name 'wrongname'") class InviteOnlyStreamTest(ZulipTestCase): def test_must_be_subbed_to_send(self) -> None: @@ -3856,7 +3854,7 @@ class GetSubscribersTest(ZulipTestCase): # Verify another user can't get the data. self.login('cordelia') result = self.client_get("/json/streams/%d/members" % (stream_id,)) - self.assert_json_error(result, u'Invalid stream id') + self.assert_json_error(result, 'Invalid stream id') # But an organization administrator can self.login('iago') @@ -3869,7 +3867,7 @@ class GetSubscribersTest(ZulipTestCase): """ stream_id = 99999999 result = self.client_get("/json/streams/%d/members" % (stream_id,)) - self.assert_json_error(result, u'Invalid stream id') + self.assert_json_error(result, 'Invalid stream id') def test_json_get_subscribers(self) -> None: """ diff --git a/zerver/tests/test_templates.py b/zerver/tests/test_templates.py index 5029c7c41b..3d86cd8399 100644 --- a/zerver/tests/test_templates.py +++ b/zerver/tests/test_templates.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from django.template.loader import get_template from zerver.lib.exceptions import InvalidMarkdownIncludeStatement diff --git a/zerver/tests/test_thumbnail.py b/zerver/tests/test_thumbnail.py index e0ff45ec40..593bbf144a 100644 --- a/zerver/tests/test_thumbnail.py +++ b/zerver/tests/test_thumbnail.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from zerver.lib.test_classes import ZulipTestCase diff --git a/zerver/tests/test_tornado.py b/zerver/tests/test_tornado.py index 16e4ed11f1..77d0c315c5 100644 --- a/zerver/tests/test_tornado.py +++ b/zerver/tests/test_tornado.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import ujson from django.conf import settings from django.db import close_old_connections diff --git a/zerver/tests/test_transfer.py b/zerver/tests/test_transfer.py index 4e8996a507..bb626cfa0f 100644 --- a/zerver/tests/test_transfer.py +++ b/zerver/tests/test_transfer.py @@ -56,8 +56,8 @@ class TransferUploadsToS3Test(ZulipTestCase): hamlet = self.example_user('hamlet') othello = self.example_user('othello') - upload_message_file(u'dummy1.txt', len(b'zulip1!'), u'text/plain', b'zulip1!', hamlet) - upload_message_file(u'dummy2.txt', len(b'zulip2!'), u'text/plain', b'zulip2!', othello) + upload_message_file('dummy1.txt', len(b'zulip1!'), 'text/plain', b'zulip1!', hamlet) + upload_message_file('dummy2.txt', len(b'zulip2!'), 'text/plain', b'zulip2!', othello) transfer_message_files_to_s3(1) diff --git a/zerver/tests/test_tutorial.py b/zerver/tests/test_tutorial.py index b4efb6e07d..1ac2f6e06f 100644 --- a/zerver/tests/test_tutorial.py +++ b/zerver/tests/test_tutorial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from zerver.lib.actions import internal_send_private_message diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.py index fa8a4a15d4..e5c1fcf2c1 100644 --- a/zerver/tests/test_typing.py +++ b/zerver/tests/test_typing.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import ujson from typing import Any, Mapping, List @@ -78,9 +76,9 @@ class TypingHappyPathTest(ZulipTestCase): def test_start_to_single_recipient(self) -> None: sender = self.example_user('hamlet') recipient_user = self.example_user('othello') - expected_recipients = set([sender, recipient_user]) - expected_recipient_emails = set([user.email for user in expected_recipients]) - expected_recipient_ids = set([user.id for user in expected_recipients]) + expected_recipients = {sender, recipient_user} + expected_recipient_emails = {user.email for user in expected_recipients} + expected_recipient_ids = {user.id for user in expected_recipients} params = dict( to=ujson.dumps([recipient_user.id]), @@ -97,9 +95,9 @@ class TypingHappyPathTest(ZulipTestCase): self.assertEqual(len(queries), 4) event = events[0]['event'] - event_recipient_emails = set(user['email'] for user in event['recipients']) + event_recipient_emails = {user['email'] for user in event['recipients']} event_user_ids = set(events[0]['users']) - event_recipient_user_ids = set(user['user_id'] for user in event['recipients']) + event_recipient_user_ids = {user['user_id'] for user in event['recipients']} self.assertEqual(expected_recipient_ids, event_recipient_user_ids) self.assertEqual(expected_recipient_ids, event_user_ids) @@ -111,9 +109,9 @@ class TypingHappyPathTest(ZulipTestCase): def test_start_to_multiple_recipients(self) -> None: sender = self.example_user('hamlet') recipient_users = [self.example_user('othello'), self.example_user('cordelia')] - expected_recipients = set(recipient_users) | set([sender]) - expected_recipient_emails = set([user.email for user in expected_recipients]) - expected_recipient_ids = set([user.id for user in expected_recipients]) + expected_recipients = set(recipient_users) | {sender} + expected_recipient_emails = {user.email for user in expected_recipients} + expected_recipient_ids = {user.id for user in expected_recipients} huddle_hash = get_huddle_hash(list(expected_recipient_ids)) self.assertFalse(Huddle.objects.filter(huddle_hash=huddle_hash).exists()) @@ -138,9 +136,9 @@ class TypingHappyPathTest(ZulipTestCase): self.assertFalse(Huddle.objects.filter(huddle_hash=huddle_hash).exists()) event = events[0]['event'] - event_recipient_emails = set(user['email'] for user in event['recipients']) + event_recipient_emails = {user['email'] for user in event['recipients']} event_user_ids = set(events[0]['users']) - event_recipient_user_ids = set(user['user_id'] for user in event['recipients']) + event_recipient_user_ids = {user['user_id'] for user in event['recipients']} self.assertEqual(expected_recipient_ids, event_recipient_user_ids) self.assertEqual(expected_recipient_ids, event_user_ids) @@ -156,8 +154,8 @@ class TypingHappyPathTest(ZulipTestCase): """ user = self.example_user('hamlet') email = user.email - expected_recipient_emails = set([email]) - expected_recipient_ids = set([user.id]) + expected_recipient_emails = {email} + expected_recipient_ids = {user.id} events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): result = self.api_post( @@ -172,9 +170,9 @@ class TypingHappyPathTest(ZulipTestCase): self.assertEqual(len(events), 1) event = events[0]['event'] - event_recipient_emails = set(user['email'] for user in event['recipients']) + event_recipient_emails = {user['email'] for user in event['recipients']} event_user_ids = set(events[0]['users']) - event_recipient_user_ids = set(user['user_id'] for user in event['recipients']) + event_recipient_user_ids = {user['user_id'] for user in event['recipients']} self.assertEqual(expected_recipient_ids, event_recipient_user_ids) self.assertEqual(expected_recipient_ids, event_user_ids) @@ -190,9 +188,9 @@ class TypingHappyPathTest(ZulipTestCase): """ sender = self.example_user('hamlet') recipient = self.example_user('othello') - expected_recipients = set([sender, recipient]) - expected_recipient_emails = set([user.email for user in expected_recipients]) - expected_recipient_ids = set([user.id for user in expected_recipients]) + expected_recipients = {sender, recipient} + expected_recipient_emails = {user.email for user in expected_recipients} + expected_recipient_ids = {user.id for user in expected_recipients} params = dict( to=ujson.dumps([recipient.id]), @@ -207,9 +205,9 @@ class TypingHappyPathTest(ZulipTestCase): self.assertEqual(len(events), 1) event = events[0]['event'] - event_recipient_emails = set(user['email'] for user in event['recipients']) + event_recipient_emails = {user['email'] for user in event['recipients']} event_user_ids = set(events[0]['users']) - event_recipient_user_ids = set(user['user_id'] for user in event['recipients']) + event_recipient_user_ids = {user['user_id'] for user in event['recipients']} self.assertEqual(expected_recipient_ids, event_recipient_user_ids) self.assertEqual(expected_recipient_ids, event_user_ids) @@ -225,8 +223,8 @@ class TypingHappyPathTest(ZulipTestCase): """ user = self.example_user('hamlet') email = user.email - expected_recipient_emails = set([email]) - expected_recipient_ids = set([user.id]) + expected_recipient_emails = {email} + expected_recipient_ids = {user.id} events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): @@ -240,9 +238,9 @@ class TypingHappyPathTest(ZulipTestCase): self.assertEqual(len(events), 1) event = events[0]['event'] - event_recipient_emails = set(user['email'] for user in event['recipients']) + event_recipient_emails = {user['email'] for user in event['recipients']} event_user_ids = set(events[0]['users']) - event_recipient_user_ids = set(user['user_id'] for user in event['recipients']) + event_recipient_user_ids = {user['user_id'] for user in event['recipients']} self.assertEqual(expected_recipient_ids, event_recipient_user_ids) self.assertEqual(expected_recipient_ids, event_user_ids) @@ -258,9 +256,9 @@ class TypingHappyPathTest(ZulipTestCase): """ sender = self.example_user('hamlet') recipient = self.example_user('othello') - expected_recipients = set([sender, recipient]) - expected_recipient_emails = set([user.email for user in expected_recipients]) - expected_recipient_ids = set([user.id for user in expected_recipients]) + expected_recipients = {sender, recipient} + expected_recipient_emails = {user.email for user in expected_recipients} + expected_recipient_ids = {user.id for user in expected_recipients} events = [] # type: List[Mapping[str, Any]] with tornado_redirected_to_list(events): @@ -274,9 +272,9 @@ class TypingHappyPathTest(ZulipTestCase): self.assertEqual(len(events), 1) event = events[0]['event'] - event_recipient_emails = set(user['email'] for user in event['recipients']) + event_recipient_emails = {user['email'] for user in event['recipients']} event_user_ids = set(events[0]['users']) - event_recipient_user_ids = set(user['user_id'] for user in event['recipients']) + event_recipient_user_ids = {user['user_id'] for user in event['recipients']} self.assertEqual(expected_recipient_ids, event_recipient_user_ids) self.assertEqual(expected_recipient_ids, event_user_ids) diff --git a/zerver/tests/test_unread.py b/zerver/tests/test_unread.py index 553c7f2673..ddcafcc3a7 100644 --- a/zerver/tests/test_unread.py +++ b/zerver/tests/test_unread.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*-AA - from typing import Any, List, Mapping from django.db import connection diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py index 68bc75dc35..d99d279cf9 100644 --- a/zerver/tests/test_upload.py +++ b/zerver/tests/test_upload.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.test import TestCase from unittest.mock import patch @@ -257,7 +256,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase): d1_attachment = Attachment.objects.get(path_id = d1_path_id) d1_attachment.create_time = two_week_ago d1_attachment.save() - self.assertEqual(str(d1_attachment), u'') + self.assertEqual(str(d1_attachment), '') d2_attachment = Attachment.objects.get(path_id = d2_path_id) d2_attachment.create_time = two_week_ago d2_attachment.save() @@ -476,7 +475,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase): uri = result.json()['uri'] fp_path_id = re.sub('/user_uploads/', '', uri) body = "First message ...[zulip.txt](http://{}/user_uploads/".format(host) + fp_path_id + ")" - with self.settings(CROSS_REALM_BOT_EMAILS = set((user_2.email, user_3.email))): + with self.settings(CROSS_REALM_BOT_EMAILS = {user_2.email, user_3.email}): internal_send_private_message( realm=r1, sender=get_system_bot(user_2.email), @@ -1418,7 +1417,7 @@ class LocalStorageTest(UploadSerializeMixin, ZulipTestCase): def test_file_upload_local(self) -> None: user_profile = self.example_user('hamlet') - uri = upload_message_file(u'dummy.txt', len(b'zulip!'), u'text/plain', b'zulip!', user_profile) + uri = upload_message_file('dummy.txt', len(b'zulip!'), 'text/plain', b'zulip!', user_profile) base = '/user_uploads/' self.assertEqual(base, uri[:len(base)]) @@ -1513,7 +1512,7 @@ class S3Test(ZulipTestCase): bucket = create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET)[0] user_profile = self.example_user('hamlet') - uri = upload_message_file(u'dummy.txt', len(b'zulip!'), u'text/plain', b'zulip!', user_profile) + uri = upload_message_file('dummy.txt', len(b'zulip!'), 'text/plain', b'zulip!', user_profile) base = '/user_uploads/' self.assertEqual(base, uri[:len(base)]) @@ -1534,7 +1533,7 @@ class S3Test(ZulipTestCase): bucket = create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET)[0] user_profile = self.example_user('hamlet') - uri = upload_message_file(u'dummy.txt', len(b'zulip!'), None, b'zulip!', user_profile) + uri = upload_message_file('dummy.txt', len(b'zulip!'), None, b'zulip!', user_profile) path_id = re.sub('/user_uploads/', '', uri) self.assertEqual(b"zulip!", bucket.get_key(path_id).get_contents_as_string()) @@ -1546,7 +1545,7 @@ class S3Test(ZulipTestCase): create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET) user_profile = self.example_user('hamlet') - uri = upload_message_file(u'dummy.txt', len(b'zulip!'), u'text/plain', b'zulip!', user_profile) + uri = upload_message_file('dummy.txt', len(b'zulip!'), 'text/plain', b'zulip!', user_profile) path_id = re.sub('/user_uploads/', '', uri) self.assertTrue(delete_message_image(path_id)) @@ -1689,7 +1688,7 @@ class S3Test(ZulipTestCase): create_s3_buckets(settings.S3_AUTH_UPLOADS_BUCKET) user_profile = self.example_user('hamlet') - uri = upload_message_file(u'dummy.txt', len(b'zulip!'), u'text/plain', b'zulip!', user_profile) + uri = upload_message_file('dummy.txt', len(b'zulip!'), 'text/plain', b'zulip!', user_profile) path_id = re.sub('/user_uploads/', '', uri) self.assertEqual(user_profile.realm_id, get_realm_for_filename(path_id)) @@ -1813,16 +1812,16 @@ class UploadTitleTests(TestCase): class SanitizeNameTests(TestCase): def test_file_name(self) -> None: - self.assertEqual(sanitize_name(u'test.txt'), u'test.txt') - self.assertEqual(sanitize_name(u'.hidden'), u'.hidden') - self.assertEqual(sanitize_name(u'.hidden.txt'), u'.hidden.txt') - self.assertEqual(sanitize_name(u'tarball.tar.gz'), u'tarball.tar.gz') - self.assertEqual(sanitize_name(u'.hidden_tarball.tar.gz'), u'.hidden_tarball.tar.gz') - self.assertEqual(sanitize_name(u'Testing{}*&*#().ta&&%$##&&r.gz'), u'Testing.tar.gz') - self.assertEqual(sanitize_name(u'*testingfile?*.txt'), u'testingfile.txt') - self.assertEqual(sanitize_name(u'snowman☃.txt'), u'snowman.txt') - self.assertEqual(sanitize_name(u'테스트.txt'), u'테스트.txt') - self.assertEqual(sanitize_name(u'~/."\\`\\?*"u0`000ssh/test.t**{}ar.gz'), u'.u0000sshtest.tar.gz') + self.assertEqual(sanitize_name('test.txt'), 'test.txt') + self.assertEqual(sanitize_name('.hidden'), '.hidden') + self.assertEqual(sanitize_name('.hidden.txt'), '.hidden.txt') + self.assertEqual(sanitize_name('tarball.tar.gz'), 'tarball.tar.gz') + self.assertEqual(sanitize_name('.hidden_tarball.tar.gz'), '.hidden_tarball.tar.gz') + self.assertEqual(sanitize_name('Testing{}*&*#().ta&&%$##&&r.gz'), 'Testing.tar.gz') + self.assertEqual(sanitize_name('*testingfile?*.txt'), 'testingfile.txt') + self.assertEqual(sanitize_name('snowman☃.txt'), 'snowman.txt') + self.assertEqual(sanitize_name('테스트.txt'), '테스트.txt') + self.assertEqual(sanitize_name('~/."\\`\\?*"u0`000ssh/test.t**{}ar.gz'), '.u0000sshtest.tar.gz') class UploadSpaceTests(UploadSerializeMixin, ZulipTestCase): @@ -1837,14 +1836,14 @@ class UploadSpaceTests(UploadSerializeMixin, ZulipTestCase): self.assertEqual(0, cache_get(get_realm_used_upload_space_cache_key(self.realm))[0]) data = b'zulip!' - upload_message_file(u'dummy.txt', len(data), u'text/plain', data, self.user_profile) + upload_message_file('dummy.txt', len(data), 'text/plain', data, self.user_profile) # notify_attachment_update function calls currently_used_upload_space_bytes which # updates the cache. self.assertEqual(len(data), cache_get(get_realm_used_upload_space_cache_key(self.realm))[0]) self.assertEqual(len(data), self.realm.currently_used_upload_space_bytes()) data2 = b'more-data!' - upload_message_file(u'dummy2.txt', len(data2), u'text/plain', data2, self.user_profile) + upload_message_file('dummy2.txt', len(data2), 'text/plain', data2, self.user_profile) self.assertEqual(len(data) + len(data2), cache_get(get_realm_used_upload_space_cache_key(self.realm))[0]) self.assertEqual(len(data) + len(data2), self.realm.currently_used_upload_space_bytes()) diff --git a/zerver/tests/test_urls.py b/zerver/tests/test_urls.py index 6d10ecb174..287ff70251 100644 --- a/zerver/tests/test_urls.py +++ b/zerver/tests/test_urls.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - import importlib import os import ujson diff --git a/zerver/tests/test_user_groups.py b/zerver/tests/test_user_groups.py index b7e53a0f82..872437f418 100644 --- a/zerver/tests/test_user_groups.py +++ b/zerver/tests/test_user_groups.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import ujson import mock @@ -35,8 +34,8 @@ class UserGroupTestCase(ZulipTestCase): self.create_user_group_for_test('support') user_groups = user_groups_in_realm(realm) self.assertEqual(len(user_groups), 2) - names = set([ug.name for ug in user_groups]) - self.assertEqual(names, set(['hamletcharacters', 'support'])) + names = {ug.name for ug in user_groups} + self.assertEqual(names, {'hamletcharacters', 'support'}) def test_user_groups_in_realm_serialized(self) -> None: realm = get_realm('zulip') diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py index 9f633f1521..6b49e0f9a0 100644 --- a/zerver/tests/test_users.py +++ b/zerver/tests/test_users.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from email.utils import parseaddr from typing import (Any, Dict, Iterable, List, Mapping, @@ -800,7 +798,7 @@ class UserProfileTest(ZulipTestCase): ] self.assertEqual(user_ids_to_users([], get_realm("zulip")), []) - self.assertEqual(set([user_profile.id for user_profile in user_ids_to_users(real_user_ids, get_realm("zulip"))]), + self.assertEqual({user_profile.id for user_profile in user_ids_to_users(real_user_ids, get_realm("zulip"))}, set(real_user_ids)) with self.assertRaises(JsonableError): user_ids_to_users([1234], get_realm("zephyr")) @@ -1084,7 +1082,7 @@ class ActivateTest(ZulipTestCase): self.assertEqual(len(outbox), 1) for message in outbox: to_fields = [parseaddr(to_field)[1] for to_field in message.to] - self.assertEqual(set([hamlet.delivery_email, iago.delivery_email]), set(to_fields)) + self.assertEqual({hamlet.delivery_email, iago.delivery_email}, set(to_fields)) self.assertEqual(ScheduledEmail.objects.count(), 0) class RecipientInfoTest(ZulipTestCase): diff --git a/zerver/tests/test_webhooks_common.py b/zerver/tests/test_webhooks_common.py index 188d83419a..b7b2b8f0bf 100644 --- a/zerver/tests/test_webhooks_common.py +++ b/zerver/tests/test_webhooks_common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from types import SimpleNamespace from mock import MagicMock, patch from typing import Dict diff --git a/zerver/tests/test_zcommand.py b/zerver/tests/test_zcommand.py index 26c27acaa8..31165272e2 100644 --- a/zerver/tests/test_zcommand.py +++ b/zerver/tests/test_zcommand.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from zerver.lib.test_classes import ( ZulipTestCase, ) diff --git a/zerver/tornado/autoreload.py b/zerver/tornado/autoreload.py index b0ff3d6fed..0a998aec82 100644 --- a/zerver/tornado/autoreload.py +++ b/zerver/tornado/autoreload.py @@ -49,7 +49,6 @@ incorrectly. # Tornado would crash itself by auto-reloading into a version of the # code that didn't work. -from __future__ import absolute_import, division, print_function import os import sys diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 1c485654b2..ff5e64d217 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -462,7 +462,7 @@ def load_event_queues(port: int) -> None: start = time.time() try: - with open(persistent_queue_filename(port), "r") as stored_queues: + with open(persistent_queue_filename(port)) as stored_queues: data = ujson.load(stored_queues) except FileNotFoundError: pass diff --git a/zerver/tornado/handlers.py b/zerver/tornado/handlers.py index 47375c8fab..3d3420610d 100644 --- a/zerver/tornado/handlers.py +++ b/zerver/tornado/handlers.py @@ -56,7 +56,7 @@ def finish_handler(handler_id: int, event_queue_id: str, events=contents, queue_id=event_queue_id), request, apply_markdown=apply_markdown) - except IOError as e: + except OSError as e: if str(e) != 'Stream is closed': logging.exception(err_msg) except AssertionError as e: diff --git a/zerver/views/development/integrations.py b/zerver/views/development/integrations.py index 5abfe8cb88..4ad97f2cd9 100644 --- a/zerver/views/development/integrations.py +++ b/zerver/views/development/integrations.py @@ -66,7 +66,7 @@ def get_fixtures(request: HttpResponse, for fixture in os.listdir(fixtures_dir): fixture_path = os.path.join(fixtures_dir, fixture) - with open(fixture_path, 'r') as f: + with open(fixture_path) as f: body = f.read() try: body = ujson.loads(body) @@ -127,7 +127,7 @@ def send_all_webhook_fixture_messages(request: HttpRequest, responses = [] for fixture in os.listdir(fixtures_dir): fixture_path = os.path.join(fixtures_dir, fixture) - with open(fixture_path, 'r') as f: + with open(fixture_path) as f: content = f.read() x = fixture.split(".") fixture_name, fixture_format = "".join(_ for _ in x[:-1]), x[-1] diff --git a/zerver/views/messages.py b/zerver/views/messages.py index ec3048c3ea..afbc1178c2 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -1195,7 +1195,7 @@ def create_mirrored_message_users(request: HttpRequest, user_profile: UserProfil raise InvalidMirrorInput("No sender") sender_email = request.POST["sender"].strip().lower() - referenced_users = set([sender_email]) + referenced_users = {sender_email} if request.POST['type'] == 'private': for email in recipients: referenced_users.add(email.lower()) diff --git a/zerver/views/portico.py b/zerver/views/portico.py index 0711455b7c..c1de237190 100644 --- a/zerver/views/portico.py +++ b/zerver/views/portico.py @@ -1,4 +1,3 @@ - from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.shortcuts import render diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 5b41e816e7..c284609672 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -94,7 +94,7 @@ def update_realm( if authentication_methods is not None and True not in list(authentication_methods.values()): return json_error(_("At least one authentication method must be enabled.")) if (video_chat_provider is not None and - video_chat_provider not in set(p['id'] for p in Realm.VIDEO_CHAT_PROVIDERS.values())): + video_chat_provider not in {p['id'] for p in Realm.VIDEO_CHAT_PROVIDERS.values()}): return json_error(_("Invalid video_chat_provider {}").format(video_chat_provider)) if video_chat_provider == Realm.VIDEO_CHAT_PROVIDERS['google_hangouts']['id']: try: diff --git a/zerver/views/registration.py b/zerver/views/registration.py index ce9ed68987..4f6689945d 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import List, Dict, Optional from django.utils.translation import ugettext as _ diff --git a/zerver/views/streams.py b/zerver/views/streams.py index 2f872903d6..00b19750b7 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -250,7 +250,7 @@ def remove_subscriptions_backend( ) -> HttpResponse: removing_someone_else = principals and \ - set(principals) != set((user_profile.email,)) + set(principals) != {user_profile.email} if removing_someone_else and not user_profile.is_realm_admin: # You can only unsubscribe other people from a stream if you are a realm @@ -264,10 +264,10 @@ def remove_subscriptions_backend( streams, __ = list_to_streams(streams_as_dict, user_profile) if principals: - people_to_unsub = set(principal_to_user_profile( - user_profile, principal) for principal in principals) + people_to_unsub = {principal_to_user_profile( + user_profile, principal) for principal in principals} else: - people_to_unsub = set([user_profile]) + people_to_unsub = {user_profile} result = dict(removed=[], not_removed=[]) # type: Dict[str, List[str]] (removed, not_subscribed) = bulk_remove_subscriptions(people_to_unsub, streams, @@ -359,9 +359,9 @@ def add_subscriptions_backend( assert user_profile.realm.invite_to_stream_policy == \ Realm.POLICY_FULL_MEMBERS_ONLY return json_error(_("Your account is too new to modify other users' subscriptions.")) - subscribers = set(principal_to_user_profile(user_profile, principal) for principal in principals) + subscribers = {principal_to_user_profile(user_profile, principal) for principal in principals} else: - subscribers = set([user_profile]) + subscribers = {user_profile} (subscribed, already_subscribed) = bulk_add_subscriptions(streams, subscribers, acting_user=user_profile, color_map=color_map) @@ -377,7 +377,7 @@ def add_subscriptions_backend( for (subscriber, stream) in already_subscribed: result["already_subscribed"][subscriber.email].append(stream.name) - bots = dict((subscriber.email, subscriber.is_bot) for subscriber in subscribers) + bots = {subscriber.email: subscriber.is_bot for subscriber in subscribers} newly_created_stream_names = {s.name for s in created_streams} diff --git a/zerver/views/thumbnail.py b/zerver/views/thumbnail.py index 787b545e60..2156d07720 100644 --- a/zerver/views/thumbnail.py +++ b/zerver/views/thumbnail.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # See https://zulip.readthedocs.io/en/latest/subsystems/thumbnailing.html from django.shortcuts import redirect from django.utils.translation import ugettext as _ diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index abcdaab8df..da38f124f3 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -142,7 +142,7 @@ def json_change_settings(request: HttpRequest, user_profile: UserProfile, return json_success(result) all_timezones = set(get_all_timezones()) -emojiset_choices = set([emojiset['key'] for emojiset in UserProfile.emojiset_choices()]) +emojiset_choices = {emojiset['key'] for emojiset in UserProfile.emojiset_choices()} @human_users_only @has_request_variables diff --git a/zerver/webhooks/airbrake/tests.py b/zerver/webhooks/airbrake/tests.py index cd75f97494..230707ee74 100644 --- a/zerver/webhooks/airbrake/tests.py +++ b/zerver/webhooks/airbrake/tests.py @@ -1,13 +1,12 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class AirbrakeHookTests(WebhookTestCase): STREAM_NAME = 'airbrake' - URL_TEMPLATE = u"/api/v1/external/airbrake?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/airbrake?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'airbrake' def test_airbrake_error_message(self) -> None: - expected_topic = u"ZulipIntegrationTest" - expected_message = u"[ZeroDivisionError](https://zulip.airbrake.io/projects/125209/groups/1705190192091077626): \"Error message from logger\" occurred." + expected_topic = "ZulipIntegrationTest" + expected_message = "[ZeroDivisionError](https://zulip.airbrake.io/projects/125209/groups/1705190192091077626): \"Error message from logger\" occurred." self.send_and_test_stream_message('error_message', expected_topic, expected_message) diff --git a/zerver/webhooks/alertmanager/tests.py b/zerver/webhooks/alertmanager/tests.py index 5395c365ad..2b0b4de746 100644 --- a/zerver/webhooks/alertmanager/tests.py +++ b/zerver/webhooks/alertmanager/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/ansibletower/tests.py b/zerver/webhooks/ansibletower/tests.py index 95462ed16c..75441903fb 100644 --- a/zerver/webhooks/ansibletower/tests.py +++ b/zerver/webhooks/ansibletower/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/appfollow/tests.py b/zerver/webhooks/appfollow/tests.py index 2825cab91b..5c43fb8b90 100644 --- a/zerver/webhooks/appfollow/tests.py +++ b/zerver/webhooks/appfollow/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.test import TestCase from zerver.lib.test_classes import WebhookTestCase @@ -7,18 +6,18 @@ from zerver.webhooks.appfollow.view import convert_markdown class AppFollowHookTests(WebhookTestCase): STREAM_NAME = 'appfollow' - URL_TEMPLATE = u"/api/v1/external/appfollow?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/appfollow?stream={stream}&api_key={api_key}" def test_sample(self) -> None: expected_topic = "Webhook integration was successful." - expected_message = u"""Webhook integration was successful. + expected_message = """Webhook integration was successful. Test User / Acme (Google Play)""" self.send_and_test_stream_message('sample', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_reviews(self) -> None: expected_topic = "Acme - Group chat" - expected_message = u"""Acme - Group chat + expected_message = """Acme - Group chat App Store, Acme Technologies, Inc. ★★★★★ United States **Great for Information Management** @@ -35,7 +34,7 @@ Acme enables me to manage the flow of information quite well. I only wish I coul self.URL_TEMPLATE = original_url_template + "&topic=foo" self.url = self.build_webhook_url() expected_topic = "foo" - expected_message = u"""Acme - Group chat + expected_message = """Acme - Group chat App Store, Acme Technologies, Inc. ★★★★★ United States **Great for Information Management** diff --git a/zerver/webhooks/appveyor/tests.py b/zerver/webhooks/appveyor/tests.py index c3a294492b..cd7e4ba396 100644 --- a/zerver/webhooks/appveyor/tests.py +++ b/zerver/webhooks/appveyor/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/basecamp/tests.py b/zerver/webhooks/basecamp/tests.py index d8a91a0986..3a14bbc332 100644 --- a/zerver/webhooks/basecamp/tests.py +++ b/zerver/webhooks/basecamp/tests.py @@ -1,131 +1,130 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class BasecampHookTests(WebhookTestCase): STREAM_NAME = 'basecamp' - URL_TEMPLATE = u"/api/v1/external/basecamp?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/basecamp?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'basecamp' EXPECTED_TOPIC = "Zulip HQ" def test_basecamp_makes_doc_active(self) -> None: - expected_message = u"Tomasz activated the document [New doc](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)." + expected_message = "Tomasz activated the document [New doc](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)." self._send_and_test_message('doc_active', expected_message) def test_basecamp_makes_doc_archived(self) -> None: - expected_message = u"Tomasz archived the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." + expected_message = "Tomasz archived the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." self._send_and_test_message('doc_archived', expected_message) def test_basecamp_makes_doc_changed_content(self) -> None: - expected_message = u"Tomasz changed content of the document [New doc edit](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)." + expected_message = "Tomasz changed content of the document [New doc edit](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)." self._send_and_test_message('doc_content_changed', expected_message) def test_basecamp_makes_doc_changed_title(self) -> None: - expected_message = u"Tomasz changed title of the document [New doc edit](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)." + expected_message = "Tomasz changed title of the document [New doc edit](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)." self._send_and_test_message('doc_title_changed', expected_message) def test_basecamp_makes_doc_publicized(self) -> None: - expected_message = u"Tomasz publicized the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." + expected_message = "Tomasz publicized the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." self._send_and_test_message('doc_publicized', expected_message) def test_basecamp_makes_doc_created(self) -> None: - expected_message = u"Tomasz created the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." + expected_message = "Tomasz created the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." self._send_and_test_message('doc_created', expected_message) def test_basecamp_makes_doc_trashed(self) -> None: - expected_message = u"Tomasz trashed the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." + expected_message = "Tomasz trashed the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." self._send_and_test_message('doc_trashed', expected_message) def test_basecamp_makes_doc_unarchived(self) -> None: - expected_message = u"Tomasz unarchived the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." + expected_message = "Tomasz unarchived the document [new doc](https://3.basecamp.com/3688623/buckets/2957043/documents/434455988)." self._send_and_test_message('doc_unarchive', expected_message) def test_basecamp_makes_questions_answer_archived(self) -> None: - expected_message = u"Tomasz archived the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question?](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)" + expected_message = "Tomasz archived the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question?](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)" self._send_and_test_message('questions_answer_archived', expected_message) def test_basecamp_makes_questions_answer_content_changed(self) -> None: - expected_message = u"Tomasz changed content of the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz changed content of the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('questions_answer_content_changed', expected_message) def test_basecamp_makes_questions_answer_created(self) -> None: - expected_message = u"Tomasz created the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz created the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('questions_answer_created', expected_message) def test_basecamp_makes_questions_answer_trashed(self) -> None: - expected_message = u"Tomasz trashed the [answer](https://3.basecamp.com/3688623/buckets/2957043/question_answers/432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz trashed the [answer](https://3.basecamp.com/3688623/buckets/2957043/question_answers/432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('questions_answer_trashed', expected_message) def test_basecamp_makes_questions_answer_unarchived(self) -> None: - expected_message = u"Tomasz unarchived the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz unarchived the [answer](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747/answers/2017-03-16#__recording_432529636) of the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('questions_answer_unarchived', expected_message) def test_basecamp_makes_question_archived(self) -> None: - expected_message = u"Tomasz archived the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz archived the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('question_archived', expected_message) def test_basecamp_makes_question_created(self) -> None: - expected_message = u"Tomasz created the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz created the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('question_created', expected_message) def test_basecamp_makes_question_trashed(self) -> None: - expected_message = u"Tomasz trashed the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz trashed the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('question_trashed', expected_message) def test_basecamp_makes_question_unarchived(self) -> None: - expected_message = u"Tomasz unarchived the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." + expected_message = "Tomasz unarchived the question [Question](https://3.basecamp.com/3688623/buckets/2957043/questions/432527747)." self._send_and_test_message('question_unarchived', expected_message) def test_basecamp_makes_message_archived(self) -> None: - expected_message = u"Tomasz archived the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." + expected_message = "Tomasz archived the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." self._send_and_test_message('message_archived', expected_message) def test_basecamp_makes_message_content_change(self) -> None: - expected_message = u"Tomasz changed content of the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." + expected_message = "Tomasz changed content of the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." self._send_and_test_message('message_content_changed', expected_message) def test_basecamp_makes_message_created(self) -> None: - expected_message = u"Tomasz created the message [Message Title](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." + expected_message = "Tomasz created the message [Message Title](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." self._send_and_test_message('message_created', expected_message) def test_basecamp_makes_message_title_change(self) -> None: - expected_message = u"Tomasz changed subject of the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." + expected_message = "Tomasz changed subject of the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." self._send_and_test_message('message_title_changed', expected_message) def test_basecamp_makes_message_trashed(self) -> None: - expected_message = u"Tomasz trashed the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." + expected_message = "Tomasz trashed the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." self._send_and_test_message('message_trashed', expected_message) def test_basecamp_makes_message_unarchived(self) -> None: - expected_message = u"Tomasz unarchived the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." + expected_message = "Tomasz unarchived the message [Message Title new](https://3.basecamp.com/3688623/buckets/2957043/messages/430680605)." self._send_and_test_message('message_unarchived', expected_message) def test_basecamp_makes_todo_list_created(self) -> None: - expected_message = u"Tomasz created the todo list [NEW TO DO LIST](https://3.basecamp.com/3688623/buckets/2957043/todolists/427050190)." + expected_message = "Tomasz created the todo list [NEW TO DO LIST](https://3.basecamp.com/3688623/buckets/2957043/todolists/427050190)." self._send_and_test_message('todo_list_created', expected_message) def test_basecamp_makes_todo_list_description_changed(self) -> None: - expected_message = u"Tomasz changed description of the todo list [NEW TO DO LIST](https://3.basecamp.com/3688623/buckets/2957043/todolists/427050190)." + expected_message = "Tomasz changed description of the todo list [NEW TO DO LIST](https://3.basecamp.com/3688623/buckets/2957043/todolists/427050190)." self._send_and_test_message('todo_list_description_changed', expected_message) def test_basecamp_makes_todo_list_modified(self) -> None: - expected_message = u"Tomasz changed name of the todo list [NEW Name TO DO LIST](https://3.basecamp.com/3688623/buckets/2957043/todolists/427050190)." + expected_message = "Tomasz changed name of the todo list [NEW Name TO DO LIST](https://3.basecamp.com/3688623/buckets/2957043/todolists/427050190)." self._send_and_test_message('todo_list_name_changed', expected_message) def test_basecamp_makes_todo_assignment_changed(self) -> None: - expected_message = u"Tomasz changed assignment of the todo task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." + expected_message = "Tomasz changed assignment of the todo task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." self._send_and_test_message('todo_assignment_changed', expected_message) def test_basecamp_makes_todo_completed(self) -> None: - expected_message = u"Tomasz completed the todo task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." + expected_message = "Tomasz completed the todo task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." self._send_and_test_message('todo_completed', expected_message) def test_basecamp_makes_todo_created(self) -> None: - expected_message = u"Tomasz created the todo task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." + expected_message = "Tomasz created the todo task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." self._send_and_test_message('todo_created', expected_message) def test_basecamp_makes_comment_created(self) -> None: - expected_message = u"Tomasz created the [comment](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624#__recording_427058780) of the task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." + expected_message = "Tomasz created the [comment](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624#__recording_427058780) of the task [New task](https://3.basecamp.com/3688623/buckets/2957043/todos/427055624)." self._send_and_test_message('comment_created', expected_message) def _send_and_test_message(self, fixture_name: str, expected_message: str) -> None: diff --git a/zerver/webhooks/beanstalk/tests.py b/zerver/webhooks/beanstalk/tests.py index e7e9f49540..5c54b76d26 100644 --- a/zerver/webhooks/beanstalk/tests.py +++ b/zerver/webhooks/beanstalk/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Dict from mock import MagicMock, patch @@ -9,7 +8,7 @@ from zerver.lib.webhooks.git import COMMITS_LIMIT class BeanstalkHookTests(WebhookTestCase): STREAM_NAME = 'commits' - URL_TEMPLATE = u"/api/v1/external/beanstalk?stream={stream}" + URL_TEMPLATE = "/api/v1/external/beanstalk?stream={stream}" def test_git_single(self) -> None: expected_topic = "work-test / master" diff --git a/zerver/webhooks/beanstalk/view.py b/zerver/webhooks/beanstalk/view.py index 903fdea2c1..9488fb40f6 100644 --- a/zerver/webhooks/beanstalk/view.py +++ b/zerver/webhooks/beanstalk/view.py @@ -51,7 +51,7 @@ def beanstalk_decoder(view_func: ViewFuncT) -> ViewFuncT: if auth_type.lower() == "basic": email, api_key = base64.b64decode(encoded_value).decode('utf-8').split(":") email = email.replace('%40', '@') - credentials = u"%s:%s" % (email, api_key) + credentials = "%s:%s" % (email, api_key) encoded_credentials = base64.b64encode(credentials.encode('utf-8')).decode('utf8') # type: str request.META['HTTP_AUTHORIZATION'] = "Basic " + encoded_credentials diff --git a/zerver/webhooks/beeminder/tests.py b/zerver/webhooks/beeminder/tests.py index 676ed5278a..5e6540053f 100644 --- a/zerver/webhooks/beeminder/tests.py +++ b/zerver/webhooks/beeminder/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Any from unittest.mock import patch @@ -7,12 +6,12 @@ from zerver.lib.test_classes import WebhookTestCase class BeeminderHookTests(WebhookTestCase): STREAM_NAME = 'beeminder' - URL_TEMPLATE = u"/api/v1/external/beeminder?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/beeminder?api_key={api_key}&stream={stream}" @patch('zerver.webhooks.beeminder.view.time.time') def test_beeminder_derail(self, time: Any) -> None: time.return_value = 1517739100 # 5.6 hours from fixture value - expected_topic = u"beekeeper" + expected_topic = "beekeeper" expected_message = """ You are going to derail from goal **gainweight** in **5.6 hours**. You need **+2 in 7 days (60)** to avoid derailing. * Pledge: **0$** :relieved: @@ -26,7 +25,7 @@ You are going to derail from goal **gainweight** in **5.6 hours**. You need **+2 @patch('zerver.webhooks.beeminder.view.time.time') def test_beeminder_derail_worried(self, time: Any) -> None: time.return_value = 1517739100 # 5.6 hours from fixture value - expected_topic = u"beekeeper" + expected_topic = "beekeeper" expected_message = """ You are going to derail from goal **gainweight** in **5.6 hours**. You need **+2 in 7 days (60)** to avoid derailing. * Pledge: **5$** :worried: diff --git a/zerver/webhooks/beeminder/view.py b/zerver/webhooks/beeminder/view.py index 0d1fc28538..45dcfac3ef 100644 --- a/zerver/webhooks/beeminder/view.py +++ b/zerver/webhooks/beeminder/view.py @@ -34,7 +34,7 @@ def api_beeminder_webhook(request: HttpRequest, user_profile: UserProfile, else: expression = ':relieved:' - topic = u'beekeeper' + topic = 'beekeeper' body = MESSAGE_TEMPLATE.format( goal_name=goal_name, time=time_remain, diff --git a/zerver/webhooks/bitbucket/tests.py b/zerver/webhooks/bitbucket/tests.py index 6dddc1dd33..a19b5fedee 100644 --- a/zerver/webhooks/bitbucket/tests.py +++ b/zerver/webhooks/bitbucket/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Dict, Union from mock import MagicMock, patch @@ -10,22 +9,22 @@ class BitbucketHookTests(WebhookTestCase): STREAM_NAME = 'bitbucket' URL_TEMPLATE = "/api/v1/external/bitbucket?stream={stream}" FIXTURE_DIR_NAME = 'bitbucket' - EXPECTED_TOPIC = u"Repository name" - EXPECTED_TOPIC_BRANCH_EVENTS = u"Repository name / master" + EXPECTED_TOPIC = "Repository name" + EXPECTED_TOPIC_BRANCH_EVENTS = "Repository name / master" def test_bitbucket_on_push_event(self) -> None: fixture_name = 'push' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) - commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' - expected_message = u"kolaszek pushed 1 commit to branch master.\n\n{}".format(commit_info) + commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' + expected_message = "kolaszek pushed 1 commit to branch master.\n\n{}".format(commit_info) self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_push_event_without_user_info(self) -> None: fixture_name = 'push_without_user_info' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) - commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' - expected_message = u"Someone pushed 1 commit to branch master. Commits by eeshangarg (1).\n\n{}".format(commit_info) + commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' + expected_message = "Someone pushed 1 commit to branch master. Commits by eeshangarg (1).\n\n{}".format(commit_info) self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) @@ -33,16 +32,16 @@ class BitbucketHookTests(WebhookTestCase): fixture_name = 'push' self.url = self.build_webhook_url(payload=self.get_body(fixture_name), branches='master,development') - commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' - expected_message = u"kolaszek pushed 1 commit to branch master.\n\n{}".format(commit_info) + commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' + expected_message = "kolaszek pushed 1 commit to branch master.\n\n{}".format(commit_info) self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_push_commits_above_limit_event(self) -> None: fixture_name = 'push_commits_above_limit' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) - commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n' - expected_message = u"kolaszek pushed 50 commits to branch master.\n\n{}[and 30 more commit(s)]".format(commit_info * 20) + commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n' + expected_message = "kolaszek pushed 50 commits to branch master.\n\n{}[and 30 more commit(s)]".format(commit_info * 20) self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) @@ -50,22 +49,22 @@ class BitbucketHookTests(WebhookTestCase): fixture_name = 'push_commits_above_limit' self.url = self.build_webhook_url(payload=self.get_body(fixture_name), branches='master,development') - commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n' - expected_message = u"kolaszek pushed 50 commits to branch master.\n\n{}[and 30 more commit(s)]".format(commit_info * 20) + commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n' + expected_message = "kolaszek pushed 50 commits to branch master.\n\n{}[and 30 more commit(s)]".format(commit_info * 20) self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_force_push_event(self) -> None: fixture_name = 'force_push' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) - expected_message = u"kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name)." + expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name)." self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC, expected_message) def test_bitbucket_on_force_push_event_without_user_info(self) -> None: fixture_name = 'force_push_without_user_info' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) - expected_message = u"Someone [force pushed](https://bitbucket.org/kolaszek/repository-name/)." + expected_message = "Someone [force pushed](https://bitbucket.org/kolaszek/repository-name/)." self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC, expected_message) diff --git a/zerver/webhooks/bitbucket/view.py b/zerver/webhooks/bitbucket/view.py index f3e8e74523..57982e7847 100644 --- a/zerver/webhooks/bitbucket/view.py +++ b/zerver/webhooks/bitbucket/view.py @@ -24,7 +24,7 @@ def api_bitbucket_webhook(request: HttpRequest, user_profile: UserProfile, 'name': commit.get('author') or payload.get('user'), 'sha': commit.get('raw_node'), 'message': commit.get('message'), - 'url': u'{}{}commits/{}'.format( + 'url': '{}{}commits/{}'.format( payload.get('canon_url'), repository.get('absolute_url'), commit.get('raw_node')) @@ -36,7 +36,7 @@ def api_bitbucket_webhook(request: HttpRequest, user_profile: UserProfile, # Bitbucket doesn't give us enough information to really give # a useful message :/ subject = repository['name'] - content = (u"%s [force pushed](%s)." + content = ("%s [force pushed](%s)." % (payload.get('user', 'Someone'), payload['canon_url'] + repository['absolute_url'])) else: diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket2/tests.py index ff2864bf82..24ca2fda9d 100644 --- a/zerver/webhooks/bitbucket2/tests.py +++ b/zerver/webhooks/bitbucket2/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -8,47 +7,47 @@ class Bitbucket2HookTests(WebhookTestCase): STREAM_NAME = 'bitbucket2' URL_TEMPLATE = "/api/v1/external/bitbucket2?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'bitbucket2' - EXPECTED_TOPIC = u"Repository name" - EXPECTED_TOPIC_PR_EVENTS = u"Repository name / PR #1 new commit" - EXPECTED_TOPIC_ISSUE_EVENTS = u"Repository name / Issue #1 Bug" - EXPECTED_TOPIC_BRANCH_EVENTS = u"Repository name / master" + EXPECTED_TOPIC = "Repository name" + EXPECTED_TOPIC_PR_EVENTS = "Repository name / PR #1 new commit" + EXPECTED_TOPIC_ISSUE_EVENTS = "Repository name / Issue #1 Bug" + EXPECTED_TOPIC_BRANCH_EVENTS = "Repository name / master" def test_bitbucket2_on_push_event(self) -> None: - commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' - expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{}".format(commit_info) + commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' + expected_message = "kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{}".format(commit_info) self.send_and_test_stream_message('push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers(self) -> None: - commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' - expected_message = u"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*2) + commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' + expected_message = """kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*2) self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None: - commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' - expected_message = u"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*9) + commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' + expected_message = """kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*9) self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' - expected_message = u"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*2) + commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' + expected_message = """kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*2) self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' - expected_message = u"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*9) + commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' + expected_message = """kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*9) self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_event_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' - expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{}".format(commit_info) + commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' + expected_message = "kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{}".format(commit_info) self.send_and_test_stream_message('push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_above_limit_event(self) -> None: commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n' - expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{}[and more commit(s)]".format( + expected_message = "kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{}[and more commit(s)]".format( (commit_info * 5), ) self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) @@ -56,70 +55,70 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_push_commits_above_limit_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n' - expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{}[and more commit(s)]".format( + expected_message = "kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{}[and more commit(s)]".format( (commit_info * 5), ) self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_force_push_event(self) -> None: - expected_message = u"kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12." + expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12." self.send_and_test_stream_message('force_push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_force_push_event_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_message = u"kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12." + expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12." self.send_and_test_stream_message('force_push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_remove_branch_event(self) -> None: - expected_message = u"kolaszek deleted branch master." + expected_message = "kolaszek deleted branch master." self.send_and_test_stream_message('remove_branch', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_fork_event(self) -> None: - expected_message = u"User Tomasz(login: kolaszek) forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)." + expected_message = "User Tomasz(login: kolaszek) forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)." self.send_and_test_stream_message('fork', self.EXPECTED_TOPIC, expected_message) def test_bitbucket2_on_commit_comment_created_event(self) -> None: - expected_message = u"kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74#comment-3354963) on [32c4ea1](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74):\n~~~ quote\nNice fix!\n~~~" + expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74#comment-3354963) on [32c4ea1](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74):\n~~~ quote\nNice fix!\n~~~" self.send_and_test_stream_message('commit_comment_created', self.EXPECTED_TOPIC, expected_message) def test_bitbucket2_on_commit_status_changed_event(self) -> None: - expected_message = u"[System mybuildtool](https://my-build-tool.com/builds/MY-PROJECT/BUILD-777) changed status of [9fec847](https://bitbucket.org/kolaszek/repository-name/commits/9fec847784abb10b2fa567ee63b85bd238955d0e) to SUCCESSFUL." + expected_message = "[System mybuildtool](https://my-build-tool.com/builds/MY-PROJECT/BUILD-777) changed status of [9fec847](https://bitbucket.org/kolaszek/repository-name/commits/9fec847784abb10b2fa567ee63b85bd238955d0e) to SUCCESSFUL." self.send_and_test_stream_message('commit_status_changed', self.EXPECTED_TOPIC, expected_message) def test_bitbucket2_on_issue_created_event(self) -> None: - expected_message = u"kolaszek created [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~" + expected_message = "kolaszek created [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~" self.send_and_test_stream_message('issue_created', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_bitbucket2_on_issue_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_topic = u"notifications" - expected_message = u"kolaszek created [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~" + expected_topic = "notifications" + expected_message = "kolaszek created [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~" self.send_and_test_stream_message('issue_created', expected_topic, expected_message) def test_bitbucket2_on_issue_updated_event(self) -> None: - expected_message = u"kolaszek updated [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." + expected_message = "kolaszek updated [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." self.send_and_test_stream_message('issue_updated', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_bitbucket2_on_issue_commented_event(self) -> None: - expected_message = u"kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." + expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." self.send_and_test_stream_message('issue_commented', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_bitbucket2_on_issue_commented_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_topic = u"notifications" - expected_message = u"kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." + expected_topic = "notifications" + expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." self.send_and_test_stream_message('issue_commented', expected_topic, expected_message) def test_bitbucket2_on_pull_request_created_event(self) -> None: - expected_message = u"kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" + expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:created' } self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_created_without_reviewer_username_event(self) -> None: - expected_message = u"kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" + expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:created' } @@ -128,22 +127,22 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_pull_request_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_topic = u"notifications" - expected_message = u"kolaszek created [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" + expected_topic = "notifications" + expected_message = "kolaszek created [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:created' } self.send_and_test_stream_message('pull_request_created_or_updated', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_updated_event(self) -> None: - expected_message = u"kolaszek updated [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" + expected_message = "kolaszek updated [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:updated' } self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_approved_event(self) -> None: - expected_message = u"kolaszek approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." + expected_message = "kolaszek approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:approved' } @@ -151,36 +150,36 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_pull_request_approved_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_topic = u"notifications" - expected_message = u"kolaszek approved [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." + expected_topic = "notifications" + expected_message = "kolaszek approved [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:approved' } self.send_and_test_stream_message('pull_request_approved_or_unapproved', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_unapproved_event(self) -> None: - expected_message = u"kolaszek unapproved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." + expected_message = "kolaszek unapproved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:unapproved' } self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_declined_event(self) -> None: - expected_message = u"kolaszek rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." + expected_message = "kolaszek rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:rejected' } self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_fulfilled_event(self) -> None: - expected_message = u"kolaszek merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." + expected_message = "kolaszek merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:fulfilled' } self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_created_event(self) -> None: - expected_message = u"kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" + expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_created' } @@ -188,15 +187,15 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_pull_request_comment_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_topic = u"notifications" - expected_message = u"kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" + expected_topic = "notifications" + expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_created' } self.send_and_test_stream_message('pull_request_comment_action', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_updated_event(self) -> None: - expected_message = u"kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" + expected_message = "kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_updated' } @@ -204,43 +203,43 @@ class Bitbucket2HookTests(WebhookTestCase): def test_bitbucket2_on_pull_request_comment_updated_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_topic = u"notifications" - expected_message = u"kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" + expected_topic = "notifications" + expected_message = "kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_updated' } self.send_and_test_stream_message('pull_request_comment_action', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_deleted_event(self) -> None: - expected_message = u"kolaszek deleted a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" + expected_message = "kolaszek deleted a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_deleted' } self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_repo_updated_event(self) -> None: - expected_message = u"eeshangarg changed the website of the **new-name** repo to **http://zulipchat.com**.\neeshangarg changed the name of the **new-name** repo from **test-repo** to **new-name**.\neeshangarg changed the language of the **new-name** repo to **python**.\neeshangarg changed the full name of the **new-name** repo from **webhooktest/test-repo** to **webhooktest/new-name**.\neeshangarg changed the description of the **new-name** repo to **Random description.**" - expected_topic = u"new-name" + expected_message = "eeshangarg changed the website of the **new-name** repo to **http://zulipchat.com**.\neeshangarg changed the name of the **new-name** repo from **test-repo** to **new-name**.\neeshangarg changed the language of the **new-name** repo to **python**.\neeshangarg changed the full name of the **new-name** repo from **webhooktest/test-repo** to **webhooktest/new-name**.\neeshangarg changed the description of the **new-name** repo to **Random description.**" + expected_topic = "new-name" kwargs = {"HTTP_X_EVENT_KEY": 'repo:updated'} self.send_and_test_stream_message('repo_updated', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_push_one_tag_event(self) -> None: - expected_message = u"kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." + expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:push' } self.send_and_test_stream_message('push_one_tag', self.EXPECTED_TOPIC, expected_message, **kwargs) def test_bitbucket2_on_push_remove_tag_event(self) -> None: - expected_message = u"kolaszek removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." + expected_message = "kolaszek removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:push' } self.send_and_test_stream_message('push_remove_tag', self.EXPECTED_TOPIC, expected_message, **kwargs) def test_bitbucket2_on_push_more_than_one_tag_event(self) -> None: - expected_message = u"kolaszek pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})." + expected_message = "kolaszek pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})." kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:push' } @@ -282,7 +281,7 @@ class Bitbucket2HookTests(WebhookTestCase): kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:push' } - expected_message = u"kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." + expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." self.send_and_test_stream_message('more_than_one_push_event', self.EXPECTED_TOPIC, expected_message, **kwargs) diff --git a/zerver/webhooks/bitbucket2/view.py b/zerver/webhooks/bitbucket2/view.py index c72d5ab205..8deb3cc711 100644 --- a/zerver/webhooks/bitbucket2/view.py +++ b/zerver/webhooks/bitbucket2/view.py @@ -218,7 +218,7 @@ def get_fork_body(payload: Dict[str, Any]) -> str: def get_commit_comment_body(payload: Dict[str, Any]) -> str: comment = payload['comment'] - action = u'[commented]({})'.format(comment['links']['html']['href']) + action = '[commented]({})'.format(comment['links']['html']['href']) return get_commits_comment_action_message( get_user_username(payload), action, diff --git a/zerver/webhooks/bitbucket3/tests.py b/zerver/webhooks/bitbucket3/tests.py index f2983063d3..ee48fb7c25 100644 --- a/zerver/webhooks/bitbucket3/tests.py +++ b/zerver/webhooks/bitbucket3/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/buildbot/tests.py b/zerver/webhooks/buildbot/tests.py index c1cd787259..17fc613b3a 100644 --- a/zerver/webhooks/buildbot/tests.py +++ b/zerver/webhooks/buildbot/tests.py @@ -3,7 +3,7 @@ from zerver.lib.test_classes import WebhookTestCase class BuildbotHookTests(WebhookTestCase): STREAM_NAME = "buildbot" - URL_TEMPLATE = u"/api/v1/external/buildbot?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/buildbot?api_key={api_key}&stream={stream}" FIXTURE_DIR_NAME = "buildbot" def test_build_started(self) -> None: diff --git a/zerver/webhooks/circleci/tests.py b/zerver/webhooks/circleci/tests.py index 057b1881ff..fb142cda81 100644 --- a/zerver/webhooks/circleci/tests.py +++ b/zerver/webhooks/circleci/tests.py @@ -1,28 +1,27 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class CircleCiHookTests(WebhookTestCase): STREAM_NAME = 'circleci' - URL_TEMPLATE = u"/api/v1/external/circleci?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/circleci?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'circleci' def test_circleci_build_in_success_status(self) -> None: - expected_topic = u"RepoName" - expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch succeeded." + expected_topic = "RepoName" + expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch succeeded." self.send_and_test_stream_message('build_passed', expected_topic, expected_message) def test_circleci_build_in_failed_status(self) -> None: - expected_topic = u"RepoName" - expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch failed." + expected_topic = "RepoName" + expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch failed." self.send_and_test_stream_message('build_failed', expected_topic, expected_message) def test_circleci_build_in_failed_status_when_previous_build_failed_too(self) -> None: - expected_topic = u"RepoName" - expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch is still failing." + expected_topic = "RepoName" + expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch is still failing." self.send_and_test_stream_message('build_failed_when_previous_build_failed', expected_topic, expected_message) def test_circleci_build_in_success_status_when_previous_build_failed_too(self) -> None: - expected_topic = u"RepoName" - expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch fixed." + expected_topic = "RepoName" + expected_message = "[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch fixed." self.send_and_test_stream_message('build_passed_when_previous_build_failed', expected_topic, expected_message) diff --git a/zerver/webhooks/circleci/view.py b/zerver/webhooks/circleci/view.py index df450e5a36..68977c3cb3 100644 --- a/zerver/webhooks/circleci/view.py +++ b/zerver/webhooks/circleci/view.py @@ -9,8 +9,8 @@ from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile -CIRCLECI_TOPIC_TEMPLATE = u'{repository_name}' -CIRCLECI_MESSAGE_TEMPLATE = u'[Build]({build_url}) triggered by {username} on {branch} branch {status}.' +CIRCLECI_TOPIC_TEMPLATE = '{repository_name}' +CIRCLECI_MESSAGE_TEMPLATE = '[Build]({build_url}) triggered by {username} on {branch} branch {status}.' FAILED_STATUS = 'failed' @@ -40,7 +40,7 @@ def get_body(payload: Dict[str, Any]) -> str: def get_status(payload: Dict[str, Any]) -> str: status = payload['status'] if payload['previous'] and payload['previous']['status'] == FAILED_STATUS and status == FAILED_STATUS: - return u'is still failing' + return 'is still failing' if status == 'success': - return u'succeeded' + return 'succeeded' return status diff --git a/zerver/webhooks/clubhouse/tests.py b/zerver/webhooks/clubhouse/tests.py index de2cb25ce6..438cf5d476 100644 --- a/zerver/webhooks/clubhouse/tests.py +++ b/zerver/webhooks/clubhouse/tests.py @@ -11,124 +11,124 @@ class ClubhouseWebhookTest(WebhookTestCase): FIXTURE_DIR_NAME = 'clubhouse' def test_story_create(self) -> None: - expected_message = u"New story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) of type **feature** was created." + expected_message = "New story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) of type **feature** was created." self.send_and_test_stream_message( 'story_create', "Add cool feature!", expected_message ) def test_story_delete(self) -> None: - expected_message = u"The story **New random story** was deleted." + expected_message = "The story **New random story** was deleted." self.send_and_test_stream_message("story_delete", "New random story", expected_message) def test_epic_story_create(self) -> None: - expected_message = u"New story [An epic story!](https://app.clubhouse.io/zulip/story/23) was created and added to the epic **New Cool Epic!**." + expected_message = "New story [An epic story!](https://app.clubhouse.io/zulip/story/23) was created and added to the epic **New Cool Epic!**." self.send_and_test_stream_message( 'epic_create_story', "An epic story!", expected_message ) def test_epic_delete(self) -> None: - expected_message = u"The epic **Clubhouse Fork** was deleted." + expected_message = "The epic **Clubhouse Fork** was deleted." self.send_and_test_stream_message("epic_delete", "Clubhouse Fork", expected_message) def test_story_archive(self) -> None: - expected_message = u"The story [Story 2](https://app.clubhouse.io/zulip/story/9) was archived." + expected_message = "The story [Story 2](https://app.clubhouse.io/zulip/story/9) was archived." self.send_and_test_stream_message('story_archive', "Story 2", expected_message) def test_epic_archive(self) -> None: - expected_message = u"The epic **Zulip is epic!** was archived." + expected_message = "The epic **Zulip is epic!** was archived." self.send_and_test_stream_message('epic_archive', 'Zulip is epic!', expected_message) def test_story_unarchive(self) -> None: - expected_message = u"The story [Story 2](https://app.clubhouse.io/zulip/story/9) was unarchived." + expected_message = "The story [Story 2](https://app.clubhouse.io/zulip/story/9) was unarchived." self.send_and_test_stream_message('story_unarchive', "Story 2", expected_message) def test_epic_create(self) -> None: - expected_message = u"New epic **New Epic!**(to do) was created." + expected_message = "New epic **New Epic!**(to do) was created." self.send_and_test_stream_message('epic_create', "New Epic!", expected_message) def test_epic_update_add_comment(self) -> None: - expected_message = u"New comment added to the epic **New Cool Epic!**:\n``` quote\nAdded a comment on this Epic!\n```" + expected_message = "New comment added to the epic **New Cool Epic!**:\n``` quote\nAdded a comment on this Epic!\n```" self.send_and_test_stream_message('epic_update_add_comment', "New Cool Epic!", expected_message) def test_story_update_add_comment(self) -> None: - expected_message = u"New comment added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11):\n``` quote\nJust leaving a comment here!\n```" + expected_message = "New comment added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11):\n``` quote\nJust leaving a comment here!\n```" self.send_and_test_stream_message('story_update_add_comment', "Add cool feature!", expected_message) def test_epic_update_add_description(self) -> None: - expected_message = u"New description added to the epic **New Cool Epic!**:\n``` quote\nAdded a description!\n```" + expected_message = "New description added to the epic **New Cool Epic!**:\n``` quote\nAdded a description!\n```" self.send_and_test_stream_message('epic_update_add_description', "New Cool Epic!", expected_message) def test_epic_update_remove_description(self) -> None: - expected_message = u"Description for the epic **New Cool Epic!** was removed." + expected_message = "Description for the epic **New Cool Epic!** was removed." self.send_and_test_stream_message('epic_update_remove_description', "New Cool Epic!", expected_message) def test_epic_update_change_description(self) -> None: - expected_message = u"Description for the epic **New Cool Epic!** was changed from:\n``` quote\nAdded a description!\n```\nto\n``` quote\nChanged a description!\n```" + expected_message = "Description for the epic **New Cool Epic!** was changed from:\n``` quote\nAdded a description!\n```\nto\n``` quote\nChanged a description!\n```" self.send_and_test_stream_message('epic_update_change_description', "New Cool Epic!", expected_message) def test_story_update_add_description(self) -> None: - expected_message = u"New description added to the story [Story 2](https://app.clubhouse.io/zulip/story/9):\n``` quote\nAdded a description.\n```" + expected_message = "New description added to the story [Story 2](https://app.clubhouse.io/zulip/story/9):\n``` quote\nAdded a description.\n```" self.send_and_test_stream_message('story_update_add_description', "Story 2", expected_message) def test_story_update_remove_description(self) -> None: - expected_message = u"Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed." + expected_message = "Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed." self.send_and_test_stream_message('story_update_remove_description', "Add cool feature!", expected_message) def test_story_update_change_description(self) -> None: - expected_message = u"Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nWe should probably add this cool feature!\n```\nto\n``` quote\nWe should probably add this cool feature! Just edited this. :)\n```" + expected_message = "Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nWe should probably add this cool feature!\n```\nto\n``` quote\nWe should probably add this cool feature! Just edited this. :)\n```" self.send_and_test_stream_message('story_update_description', "Add cool feature!", expected_message) def test_epic_update_change_state(self) -> None: - expected_message = u"State of the epic **New Cool Epic!** was changed from **to do** to **in progress**." + expected_message = "State of the epic **New Cool Epic!** was changed from **to do** to **in progress**." self.send_and_test_stream_message('epic_update_change_state', "New Cool Epic!", expected_message) def test_story_update_change_state(self) -> None: - expected_message = u"State of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **Unscheduled** to **Ready for Review**." + expected_message = "State of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **Unscheduled** to **Ready for Review**." self.send_and_test_stream_message('story_update_change_state', "Add cool feature!", expected_message) def test_epic_update_change_name(self) -> None: - expected_message = u"The name of the epic **New Cool Epic!** was changed from:\n``` quote\nNew Epic!\n```\nto\n``` quote\nNew Cool Epic!\n```" + expected_message = "The name of the epic **New Cool Epic!** was changed from:\n``` quote\nNew Epic!\n```\nto\n``` quote\nNew Cool Epic!\n```" self.send_and_test_stream_message('epic_update_change_title', "New Cool Epic!", expected_message) def test_story_update_change_name(self) -> None: - expected_message = u"The name of the story [Add super cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nAdd cool feature!\n```\nto\n``` quote\nAdd super cool feature!\n```" + expected_message = "The name of the story [Add super cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nAdd cool feature!\n```\nto\n``` quote\nAdd super cool feature!\n```" self.send_and_test_stream_message('story_update_change_title', "Add super cool feature!", expected_message) def test_story_update_add_owner(self) -> None: - expected_message = u"New owner added to the story [A new story by Shakespeare!](https://app.clubhouse.io/zulip/story/26)." + expected_message = "New owner added to the story [A new story by Shakespeare!](https://app.clubhouse.io/zulip/story/26)." self.send_and_test_stream_message('story_update_add_owner', 'A new story by Shakespeare!', expected_message) def test_story_task_created(self) -> None: - expected_message = u"Task **Added a new task** was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." + expected_message = "Task **Added a new task** was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." self.send_and_test_stream_message('story_task_create', "Add cool feature!", expected_message) def test_story_task_deleted(self) -> None: - expected_message = u"Task **Added a new task** was removed from the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." + expected_message = "Task **Added a new task** was removed from the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." self.send_and_test_stream_message('story_task_delete', "Add cool feature!", expected_message) def test_story_task_completed(self) -> None: - expected_message = u"Task **A new task for this story** ([Add cool feature!](https://app.clubhouse.io/zulip/story/11)) was completed. :tada:" + expected_message = "Task **A new task for this story** ([Add cool feature!](https://app.clubhouse.io/zulip/story/11)) was completed. :tada:" self.send_and_test_stream_message('story_task_complete', "Add cool feature!", expected_message) @@ -141,38 +141,38 @@ class ClubhouseWebhookTest(WebhookTestCase): self.assert_json_success(result) def test_story_epic_changed(self) -> None: - expected_message = (u"The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from **Release 1.9**" - u" to **Clubhouse Fork**.") + expected_message = ("The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from **Release 1.9**" + " to **Clubhouse Fork**.") self.send_and_test_stream_message('story_update_change_epic', "Add cool feature!", expected_message) def test_story_epic_added(self) -> None: - expected_message = u"The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was added to the epic **Release 1.9**." + expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was added to the epic **Release 1.9**." self.send_and_test_stream_message('story_update_add_epic', "Add cool feature!", expected_message) def test_story_epic_removed(self) -> None: - expected_message = u"The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed from the epic **Release 1.9**." + expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed from the epic **Release 1.9**." self.send_and_test_stream_message('story_update_remove_epic', "Add cool feature!", expected_message) def test_story_estimate_changed(self) -> None: - expected_message = u"The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points." + expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points." self.send_and_test_stream_message('story_update_change_estimate', "Add cool feature!", expected_message) def test_story_estimate_added(self) -> None: - expected_message = u"The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points." + expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points." self.send_and_test_stream_message('story_update_add_estimate', "Add cool feature!", expected_message) def test_story_estimate_removed(self) -> None: - expected_message = u"The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to *Unestimated*." + expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to *Unestimated*." self.send_and_test_stream_message('story_update_remove_estimate', "Add cool feature!", expected_message) def test_story_file_attachment_added(self) -> None: - expected_message = u"A file attachment `zuliprc` was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." + expected_message = "A file attachment `zuliprc` was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." self.send_and_test_stream_message('story_update_add_attachment', "Add cool feature!", expected_message) @@ -185,12 +185,12 @@ class ClubhouseWebhookTest(WebhookTestCase): self.assert_json_success(result) def test_story_label_added(self) -> None: - expected_message = u"The label **mockup** was added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23)." + expected_message = "The label **mockup** was added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23)." self.send_and_test_stream_message('story_update_add_label', "An epic story!", expected_message) def test_story_label_added_label_name_in_actions(self) -> None: - expected_message = u"The label **sad** was added to the story [An emotional story!](https://app.clubhouse.io/zulip/story/28)." + expected_message = "The label **sad** was added to the story [An emotional story!](https://app.clubhouse.io/zulip/story/28)." self.send_and_test_stream_message('story_update_add_label_name_in_action', 'An emotional story!', expected_message) @@ -204,17 +204,17 @@ class ClubhouseWebhookTest(WebhookTestCase): self.assert_json_success(result) def test_story_update_project(self) -> None: - expected_message = u"The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from the **Backend** project to **Devops**." + expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from the **Backend** project to **Devops**." self.send_and_test_stream_message('story_update_change_project', "Add cool feature!", expected_message) def test_story_update_type(self) -> None: - expected_message = u"The type of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **feature** to **bug**." + expected_message = "The type of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **feature** to **bug**." self.send_and_test_stream_message('story_update_change_type', "Add cool feature!", expected_message) def test_story_update_add_github_pull_request(self) -> None: - expected_message = u"New GitHub PR [#10](https://github.com/eeshangarg/Scheduler/pull/10) opened for story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/28) (Unscheduled -> Ready for Review)." + expected_message = "New GitHub PR [#10](https://github.com/eeshangarg/Scheduler/pull/10) opened for story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/28) (Unscheduled -> Ready for Review)." self.send_and_test_stream_message('story_update_add_github_pull_request', 'Testing pull requests with Story', expected_message) diff --git a/zerver/webhooks/codeship/tests.py b/zerver/webhooks/codeship/tests.py index 00edc936c6..4ffc331fc7 100644 --- a/zerver/webhooks/codeship/tests.py +++ b/zerver/webhooks/codeship/tests.py @@ -1,37 +1,36 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class CodeshipHookTests(WebhookTestCase): STREAM_NAME = 'codeship' - URL_TEMPLATE = u"/api/v1/external/codeship?stream={stream}&api_key={api_key}" - TOPIC = u"codeship/docs" + URL_TEMPLATE = "/api/v1/external/codeship?stream={stream}&api_key={api_key}" + TOPIC = "codeship/docs" FIXTURE_DIR_NAME = 'codeship' def test_codeship_build_in_testing_status_message(self) -> None: """ Tests if codeship testing status is mapped correctly """ - expected_message = u"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started." + expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started." self.send_and_test_stream_message('testing_build', self.TOPIC, expected_message) def test_codeship_build_in_error_status_message(self) -> None: """ Tests if codeship error status is mapped correctly """ - expected_message = u"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed." + expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed." self.send_and_test_stream_message('error_build', self.TOPIC, expected_message) def test_codeship_build_in_success_status_message(self) -> None: """ Tests if codeship success status is mapped correctly """ - expected_message = u"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded." + expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded." self.send_and_test_stream_message('success_build', self.TOPIC, expected_message) def test_codeship_build_in_other_status_status_message(self) -> None: """ Tests if codeship other status is mapped correctly """ - expected_message = u"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status." + expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status." self.send_and_test_stream_message('other_status_build', self.TOPIC, expected_message) diff --git a/zerver/webhooks/crashlytics/tests.py b/zerver/webhooks/crashlytics/tests.py index 99f9ea9742..c5e81db25c 100644 --- a/zerver/webhooks/crashlytics/tests.py +++ b/zerver/webhooks/crashlytics/tests.py @@ -1,18 +1,17 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class CrashlyticsHookTests(WebhookTestCase): STREAM_NAME = 'crashlytics' - URL_TEMPLATE = u"/api/v1/external/crashlytics?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/crashlytics?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'crashlytics' def test_crashlytics_verification_message(self) -> None: - expected_topic = u"Setup" - expected_message = u"Webhook has been successfully configured." + expected_topic = "Setup" + expected_message = "Webhook has been successfully configured." self.send_and_test_stream_message('verification', expected_topic, expected_message) def test_crashlytics_build_in_success_status(self) -> None: - expected_topic = u"123: Issue Title" - expected_message = u"[Issue](http://crashlytics.com/full/url/to/issue) impacts at least 16 device(s)." + expected_topic = "123: Issue Title" + expected_message = "[Issue](http://crashlytics.com/full/url/to/issue) impacts at least 16 device(s)." self.send_and_test_stream_message('issue_message', expected_topic, expected_message) diff --git a/zerver/webhooks/delighted/tests.py b/zerver/webhooks/delighted/tests.py index be3d197af3..200f4d440d 100644 --- a/zerver/webhooks/delighted/tests.py +++ b/zerver/webhooks/delighted/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/deskdotcom/tests.py b/zerver/webhooks/deskdotcom/tests.py index f067472e20..3bcc603552 100644 --- a/zerver/webhooks/deskdotcom/tests.py +++ b/zerver/webhooks/deskdotcom/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase # Tests for the Desk.com webhook integration. @@ -18,37 +17,37 @@ class DeskDotComHookTests(WebhookTestCase): def test_static_text_message(self) -> None: - expected_topic = u"static text notification" - expected_message = u"This is a custom action." + expected_topic = "static text notification" + expected_message = "This is a custom action." self.api_stream_message(self.test_user, 'static_text', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_case_updated_message(self) -> None: - expected_topic = u"case updated notification" - expected_message = (u"Case 2 updated. " - u"Link: " - u"I have a question") + expected_topic = "case updated notification" + expected_message = ("Case 2 updated. " + "Link: " + "I have a question") self.api_stream_message(self.test_user, 'case_updated', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_unicode_text_italian(self) -> None: - expected_topic = u"case updated notification" - expected_message = (u"Case 2 updated. " - u"Link: " - u"Il mio hovercraft è pieno di anguille.") + expected_topic = "case updated notification" + expected_message = ("Case 2 updated. " + "Link: " + "Il mio hovercraft è pieno di anguille.") self.api_stream_message(self.test_user, 'unicode_text_italian', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_unicode_text_japanese(self) -> None: - expected_topic = u"case updated notification" - expected_message = (u"Case 2 updated. " - u"Link: " - u"私のホバークラフトは鰻でいっぱいです") + expected_topic = "case updated notification" + expected_message = ("Case 2 updated. " + "Link: " + "私のホバークラフトは鰻でいっぱいです") self.api_stream_message(self.test_user, 'unicode_text_japanese', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/dialogflow/tests.py b/zerver/webhooks/dialogflow/tests.py index 0899f50536..910262a32b 100644 --- a/zerver/webhooks/dialogflow/tests.py +++ b/zerver/webhooks/dialogflow/tests.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class DialogflowHookTests(WebhookTestCase): - URL_TEMPLATE = u"/api/v1/external/dialogflow?api_key={api_key}&email=AARON@zulip.com" + URL_TEMPLATE = "/api/v1/external/dialogflow?api_key={api_key}&email=AARON@zulip.com" def test_dialogflow_default(self) -> None: self.url = self.build_webhook_url( @@ -11,7 +10,7 @@ class DialogflowHookTests(WebhookTestCase): username="aaron", user_ip="127.0.0.1" ) - expected_message = u"Today the weather in Delhi: Sunny, And the tempreture is 65F" + expected_message = "Today the weather in Delhi: Sunny, And the tempreture is 65F" self.send_and_test_private_message('default', expected_message, content_type="application/json") @@ -22,7 +21,7 @@ class DialogflowHookTests(WebhookTestCase): username="aaron", user_ip="127.0.0.1" ) - expected_message = u"The weather sure looks great !" + expected_message = "The weather sure looks great !" self.send_and_test_private_message('weather_app', expected_message, content_type="application/json") @@ -33,7 +32,7 @@ class DialogflowHookTests(WebhookTestCase): username="aaron", user_ip="127.0.0.1" ) - expected_message = u"Weather in New Delhi is nice!" + expected_message = "Weather in New Delhi is nice!" self.send_and_test_private_message('alternate_result', expected_message, content_type="application/json") @@ -44,7 +43,7 @@ class DialogflowHookTests(WebhookTestCase): username="aaron", user_ip="127.0.0.1" ) - expected_message = u"403 - Access Denied" + expected_message = "403 - Access Denied" self.send_and_test_private_message('error_status', expected_message, content_type="application/json") @@ -55,7 +54,7 @@ class DialogflowHookTests(WebhookTestCase): username="aaron", user_ip="127.0.0.1" ) - expected_message = u"DialogFlow couldn't process your query." + expected_message = "DialogFlow couldn't process your query." self.send_and_test_private_message('exception', expected_message, content_type="application/json") diff --git a/zerver/webhooks/dialogflow/view.py b/zerver/webhooks/dialogflow/view.py index f76ab644da..a22fd18148 100644 --- a/zerver/webhooks/dialogflow/view.py +++ b/zerver/webhooks/dialogflow/view.py @@ -22,14 +22,14 @@ def api_dialogflow_webhook(request: HttpRequest, user_profile: UserProfile, if not result: alternate_result = payload["alternateResult"]["fulfillment"]["speech"] if not alternate_result: - body = u"DialogFlow couldn't process your query." + body = "DialogFlow couldn't process your query." else: body = alternate_result else: body = result else: error_status = payload["status"]["errorDetails"] - body = u"{} - {}".format(status, error_status) + body = "{} - {}".format(status, error_status) profile = get_user_profile_by_email(email) check_send_private_message(user_profile, request.client, profile, body) diff --git a/zerver/webhooks/dropbox/tests.py b/zerver/webhooks/dropbox/tests.py index 1a725b5ae2..61d558a0f4 100644 --- a/zerver/webhooks/dropbox/tests.py +++ b/zerver/webhooks/dropbox/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase from zerver.lib.users import get_api_key @@ -9,8 +8,8 @@ class DropboxHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'dropbox' def test_file_updated(self) -> None: - expected_topic = u"Dropbox" - expected_message = u"File has been updated on Dropbox!" + expected_topic = "Dropbox" + expected_message = "File has been updated on Dropbox!" self.send_and_test_stream_message('file_updated', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/errbit/tests.py b/zerver/webhooks/errbit/tests.py index 0ea05074bd..9104730f72 100644 --- a/zerver/webhooks/errbit/tests.py +++ b/zerver/webhooks/errbit/tests.py @@ -1,13 +1,12 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class ErrBitHookTests(WebhookTestCase): STREAM_NAME = 'errbit' - URL_TEMPLATE = u"/api/v1/external/errbit?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/errbit?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'errbit' def test_errbit_error_message(self) -> None: - expected_topic = u"ZulipIntegrationTest / ErrbitEnvName" - expected_message = u"[IllegalStateException](https://errbit.example.com/apps/5e1ed1ff1a603f3916f4f0de/problems/5e1fe93e1a603f3916f4f0e3): \"Invalid state error\" occurred." + expected_topic = "ZulipIntegrationTest / ErrbitEnvName" + expected_message = "[IllegalStateException](https://errbit.example.com/apps/5e1ed1ff1a603f3916f4f0de/problems/5e1fe93e1a603f3916f4f0e3): \"Invalid state error\" occurred." self.send_and_test_stream_message('error_message', expected_topic, expected_message) diff --git a/zerver/webhooks/flock/tests.py b/zerver/webhooks/flock/tests.py index 24763e8a3f..3cb3c08e74 100644 --- a/zerver/webhooks/flock/tests.py +++ b/zerver/webhooks/flock/tests.py @@ -1,86 +1,85 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class FlockHookTests(WebhookTestCase): STREAM_NAME = 'test' - URL_TEMPLATE = u"/api/v1/external/flock?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/flock?api_key={api_key}&stream={stream}" def test_flock_message(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"This is the welcome message!" + expected_topic = "Flock notifications" + expected_message = "This is the welcome message!" self.send_and_test_stream_message('messages', expected_topic, expected_message, content_type="application/json") def test_flock_reply(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"It's interesting how high productivity will go..." + expected_topic = "Flock notifications" + expected_message = "It's interesting how high productivity will go..." self.send_and_test_stream_message('reply', expected_topic, expected_message, content_type="application/json") def test_flock_note(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"Shared a note" + expected_topic = "Flock notifications" + expected_message = "Shared a note" self.send_and_test_stream_message('note', expected_topic, expected_message, content_type="application/json") def test_flock_reply_note(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"This is reply to Note." + expected_topic = "Flock notifications" + expected_message = "This is reply to Note." self.send_and_test_stream_message('reply_note', expected_topic, expected_message, content_type="application/json") def test_flock_reply_pinned(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"This is reply to pinned message." + expected_topic = "Flock notifications" + expected_message = "This is reply to pinned message." self.send_and_test_stream_message('reply_pinned', expected_topic, expected_message, content_type="application/json") def test_flock_reply_reminder(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"This is a reply to Reminder." + expected_topic = "Flock notifications" + expected_message = "This is a reply to Reminder." self.send_and_test_stream_message('reply_reminder', expected_topic, expected_message, content_type="application/json") def test_flock_reply_todo(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"This is a reply to Todo notification." + expected_topic = "Flock notifications" + expected_message = "This is a reply to Todo notification." self.send_and_test_stream_message('reply_todo', expected_topic, expected_message, content_type="application/json") def test_flock_pinned(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"Rishabh rawat pinned an item to the conversation" + expected_topic = "Flock notifications" + expected_message = "Rishabh rawat pinned an item to the conversation" self.send_and_test_stream_message('pinned', expected_topic, expected_message, content_type="application/json") def test_flock_reminder(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"Rishabh rawat wanted me to remind All" + expected_topic = "Flock notifications" + expected_message = "Rishabh rawat wanted me to remind All" self.send_and_test_stream_message('reminder', expected_topic, expected_message, content_type="application/json") def test_flock_todo(self) -> None: - expected_topic = u"Flock notifications" - expected_message = u"Rishabh rawat added a to-do in New List 1 list" + expected_topic = "Flock notifications" + expected_message = "Rishabh rawat added a to-do in New List 1 list" self.send_and_test_stream_message('todo', expected_topic, expected_message, diff --git a/zerver/webhooks/flock/view.py b/zerver/webhooks/flock/view.py index 45a3b0f52c..c85f39c3b2 100644 --- a/zerver/webhooks/flock/view.py +++ b/zerver/webhooks/flock/view.py @@ -22,7 +22,7 @@ def api_flock_webhook(request: HttpRequest, user_profile: UserProfile, message_body = payload["notification"] topic = 'Flock notifications' - body = u"{}".format(message_body) + body = "{}".format(message_body) check_send_webhook_message(request, user_profile, topic, body) diff --git a/zerver/webhooks/freshdesk/tests.py b/zerver/webhooks/freshdesk/tests.py index cd3707af61..d4937d6335 100644 --- a/zerver/webhooks/freshdesk/tests.py +++ b/zerver/webhooks/freshdesk/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -6,14 +5,14 @@ from zerver.lib.test_classes import WebhookTestCase class FreshdeskHookTests(WebhookTestCase): STREAM_NAME = 'freshdesk' - URL_TEMPLATE = u"/api/v1/external/freshdesk?stream={stream}" + URL_TEMPLATE = "/api/v1/external/freshdesk?stream={stream}" def test_ticket_creation(self) -> None: """ Messages are generated on ticket creation through Freshdesk's "Dispatch'r" service. """ - expected_topic = u"#11: Test ticket subject ☃" + expected_topic = "#11: Test ticket subject ☃" expected_message = """ Requester ☃ Bob created [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11): @@ -34,7 +33,7 @@ Test ticket description ☃. Messages are generated when a ticket's status changes through Freshdesk's "Observer" service. """ - expected_topic = u"#11: Test ticket subject ☃" + expected_topic = "#11: Test ticket subject ☃" expected_message = """ Requester Bob updated [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11): @@ -62,7 +61,7 @@ Requester Bob updated [ticket #11](http://test1234zz Messages are generated when a ticket's priority changes through Freshdesk's "Observer" service. """ - expected_topic = u"#11: Test ticket subject" + expected_topic = "#11: Test ticket subject" expected_message = """ Requester Bob updated [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11): @@ -92,7 +91,7 @@ Requester Bob updated [ticket #11](http://test1234zz Messages are generated when a note gets added to a ticket through Freshdesk's "Observer" service. """ - expected_topic = u"#11: Test ticket subject" + expected_topic = "#11: Test ticket subject" expected_message = """ Requester Bob added a {} note to \ [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11). @@ -112,7 +111,7 @@ Requester Bob added a {} note to \ descriptions Zulip markdown-friendly while still doing our best to preserve links and images. """ - expected_topic = u"#12: Not enough ☃ guinea pigs" + expected_topic = "#12: Not enough ☃ guinea pigs" expected_message = """ Requester \u2603 Bob created [ticket #12](http://test1234zzz.freshdesk.com/helpdesk/tickets/12):\n\n``` quote\nThere are too many cat pictures on the internet \u2603. We need more guinea pigs.\nExhibit 1:\n\n \n\n[guinea_pig.png](http://cdn.freshdesk.com/data/helpdesk/attachments/production/12744808/original/guinea_pig.png)\n```\n\n* **Type**: Problem\n* **Priority**: Urgent\n* **Status**: Open """.strip() diff --git a/zerver/webhooks/gci/tests.py b/zerver/webhooks/gci/tests.py index 8e294f452c..fae99a76eb 100644 --- a/zerver/webhooks/gci/tests.py +++ b/zerver/webhooks/gci/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,61 +7,61 @@ class GoogleCodeInTests(WebhookTestCase): FIXTURE_DIR_NAME = 'gci' def test_abandon_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**student-yqqtag** abandoned the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' + expected_topic = 'student-yqqtag' + expected_message = '**student-yqqtag** abandoned the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' self.send_and_test_stream_message('task_abandoned_by_student', expected_topic, expected_message) def test_comment_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**student-yqqtag** commented on the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' + expected_topic = 'student-yqqtag' + expected_message = '**student-yqqtag** commented on the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' self.send_and_test_stream_message('student_commented_on_task', expected_topic, expected_message) def test_submit_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**student-yqqtag** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' + expected_topic = 'student-yqqtag' + expected_message = '**student-yqqtag** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' self.send_and_test_stream_message('task_submitted_by_student', expected_topic, expected_message) def test_claim_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**student-yqqtag** claimed the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' + expected_topic = 'student-yqqtag' + expected_message = '**student-yqqtag** claimed the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' self.send_and_test_stream_message('task_claimed_by_student', expected_topic, expected_message) def test_approve_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' + expected_topic = 'student-yqqtag' + expected_message = '**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' self.send_and_test_stream_message('task_approved_by_mentor', expected_topic, expected_message) def test_approve_pending_pc_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) (pending parental consent).' + expected_topic = 'student-yqqtag' + expected_message = '**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) (pending parental consent).' self.send_and_test_stream_message('task_approved_by_mentor_pending_parental_consent', expected_topic, expected_message) def test_needswork_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**eeshangarg** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/5136918324969472/) for more work.' + expected_topic = 'student-yqqtag' + expected_message = '**eeshangarg** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/5136918324969472/) for more work.' self.send_and_test_stream_message('task_submitted_by_mentor_for_more_work', expected_topic, expected_message) def test_extend_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**eeshangarg** extended the deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) by 1.0 day(s).' + expected_topic = 'student-yqqtag' + expected_message = '**eeshangarg** extended the deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) by 1.0 day(s).' self.send_and_test_stream_message('task_deadline_extended_by_mentor', expected_topic, expected_message) def test_unassign_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'**eeshangarg** unassigned **student-yqqtag** from the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' + expected_topic = 'student-yqqtag' + expected_message = '**eeshangarg** unassigned **student-yqqtag** from the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' self.send_and_test_stream_message('student_unassigned_by_mentor', expected_topic, expected_message) def test_outoftime_event_message(self) -> None: - expected_topic = u'student-yqqtag' - expected_message = u'The deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6694926301528064/) has passed.' + expected_topic = 'student-yqqtag' + expected_message = 'The deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6694926301528064/) has passed.' self.send_and_test_stream_message('task_deadline_has_passed', expected_topic, expected_message) diff --git a/zerver/webhooks/gci/view.py b/zerver/webhooks/gci/view.py index 4fc3eddf40..a493e51369 100644 --- a/zerver/webhooks/gci/view.py +++ b/zerver/webhooks/gci/view.py @@ -8,8 +8,8 @@ from zerver.lib.response import json_success from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile -GCI_MESSAGE_TEMPLATE = u'**{actor}** {action} the task [{task_name}]({task_url}).' -GCI_TOPIC_TEMPLATE = u'{student_name}' +GCI_MESSAGE_TEMPLATE = '**{actor}** {action} the task [{task_name}]({task_url}).' +GCI_TOPIC_TEMPLATE = '{student_name}' def build_instance_url(instance_id: str) -> str: @@ -95,7 +95,7 @@ def get_unassign_event_body(payload: Dict[str, Any]) -> str: ) def get_outoftime_event_body(payload: Dict[str, Any]) -> str: - return u'The deadline for the task [{task_name}]({task_url}) has passed.'.format( + return 'The deadline for the task [{task_name}]({task_url}) has passed.'.format( task_name=payload['task_definition_name'], task_url=build_instance_url(payload['task_instance']), ) @@ -132,7 +132,7 @@ def get_event(payload: Dict[str, Any]) -> Optional[str]: if event in EVENTS_FUNCTION_MAPPER: return event - raise UnknownEventType(u"Event '{}' is unknown and cannot be handled".format(event)) # nocoverage + raise UnknownEventType("Event '{}' is unknown and cannot be handled".format(event)) # nocoverage def get_body_based_on_event(event: str) -> Any: return EVENTS_FUNCTION_MAPPER[event] diff --git a/zerver/webhooks/gitea/tests.py b/zerver/webhooks/gitea/tests.py index 05a36b0d32..911b55e47c 100644 --- a/zerver/webhooks/gitea/tests.py +++ b/zerver/webhooks/gitea/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -10,8 +9,8 @@ class GiteaHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'gitea' def test_multiple_commits(self) -> None: - expected_topic = u"test / d" - expected_message = u"""kostekIV [pushed](https://try.gitea.io/kostekIV/test/compare/21138d2ca0ce18f8e037696fdbe1b3f0c211f630...2ec0c971d04723523aa20f2b378f8b419b47d4ec) 5 commits to branch d. + expected_topic = "test / d" + expected_message = """kostekIV [pushed](https://try.gitea.io/kostekIV/test/compare/21138d2ca0ce18f8e037696fdbe1b3f0c211f630...2ec0c971d04723523aa20f2b378f8b419b47d4ec) 5 commits to branch d. * commit ([2ec0c97](https://try.gitea.io/kostekIV/test/commit/2ec0c971d04723523aa20f2b378f8b419b47d4ec)) * commit ([6cb1701](https://try.gitea.io/kostekIV/test/commit/6cb1701c8b0114ad716f4cd49153076e7109cb85)) @@ -21,78 +20,78 @@ class GiteaHookTests(WebhookTestCase): self.send_and_test_stream_message('push__5_commits', expected_topic, expected_message) def test_new_branch(self) -> None: - expected_topic = u"test / test-branch" - expected_message = u"kostekIV created [test-branch](https://try.gitea.io/kostekIV/test/src/test-branch) branch." + expected_topic = "test / test-branch" + expected_message = "kostekIV created [test-branch](https://try.gitea.io/kostekIV/test/src/test-branch) branch." self.send_and_test_stream_message('create__branch', expected_topic, expected_message) def test_pull_request_opened(self) -> None: - expected_topic = u"test / PR #1905 New pr" - expected_message = u"""kostekIV opened [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`.""" + expected_topic = "test / PR #1905 New pr" + expected_message = """kostekIV opened [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`.""" self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) def test_pull_request_merged(self) -> None: - expected_topic = u"test / PR #1905 New pr" - expected_message = u"""kostekIV merged [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`.""" + expected_topic = "test / PR #1905 New pr" + expected_message = """kostekIV merged [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`.""" self.send_and_test_stream_message('pull_request__merged', expected_topic, expected_message) def test_pull_request_edited(self) -> None: - expected_topic = u"test / PR #1906 test 2" - expected_message = u"""kostekIV edited [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" + expected_topic = "test / PR #1906 test 2" + expected_message = """kostekIV edited [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" self.send_and_test_stream_message('pull_request__edited', expected_topic, expected_message) def test_pull_request_reopened(self) -> None: - expected_topic = u"test / PR #1906 test 2" - expected_message = u"""kostekIV reopened [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" + expected_topic = "test / PR #1906 test 2" + expected_message = """kostekIV reopened [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" self.send_and_test_stream_message('pull_request__reopened', expected_topic, expected_message) def test_pull_request_closed(self) -> None: - expected_topic = u"test / PR #1906 test 2" - expected_message = u"""kostekIV closed [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" + expected_topic = "test / PR #1906 test 2" + expected_message = """kostekIV closed [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" self.send_and_test_stream_message('pull_request__closed', expected_topic, expected_message) def test_pull_request_assigned(self) -> None: - expected_topic = u"test / PR #1906 test 2" - expected_message = u"""kostekIV assigned [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) (assigned to kostekIV) from `d` to `master`.""" + expected_topic = "test / PR #1906 test 2" + expected_message = """kostekIV assigned [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) (assigned to kostekIV) from `d` to `master`.""" self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message) def test_issues_opened(self) -> None: - expected_topic = u"test / Issue #3 Test issue" - expected_message = u"""kostekIV opened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest body\n~~~""" + expected_topic = "test / Issue #3 Test issue" + expected_message = """kostekIV opened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest body\n~~~""" self.send_and_test_stream_message('issues__opened', expected_topic, expected_message) def test_issues_edited(self) -> None: - expected_topic = u"test / Issue #3 Test issue 2" - expected_message = u"""kostekIV edited [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" + expected_topic = "test / Issue #3 Test issue 2" + expected_message = """kostekIV edited [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" self.send_and_test_stream_message('issues__edited', expected_topic, expected_message) def test_issues_closed(self) -> None: - expected_topic = u"test / Issue #3 Test issue 2" - expected_message = u"""kostekIV closed [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" + expected_topic = "test / Issue #3 Test issue 2" + expected_message = """kostekIV closed [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" self.send_and_test_stream_message('issues__closed', expected_topic, expected_message) def test_issues_assigned(self) -> None: - expected_topic = u"test / Issue #3 Test issue" - expected_message = u"""kostekIV assigned [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" + expected_topic = "test / Issue #3 Test issue" + expected_message = """kostekIV assigned [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" self.send_and_test_stream_message('issues__assigned', expected_topic, expected_message) def test_issues_reopened(self) -> None: - expected_topic = u"test / Issue #3 Test issue 2" - expected_message = u"""kostekIV reopened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" + expected_topic = "test / Issue #3 Test issue 2" + expected_message = """kostekIV reopened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" self.send_and_test_stream_message('issues__reopened', expected_topic, expected_message) def test_issue_comment_new(self) -> None: - expected_topic = u"test / Issue #3 Test issue" - expected_message = u"""kostekIV [commented](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\ntest comment\n~~~""" + expected_topic = "test / Issue #3 Test issue" + expected_message = """kostekIV [commented](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\ntest comment\n~~~""" self.send_and_test_stream_message('issue_comment__new', expected_topic, expected_message) def test_issue_comment_in_pr(self) -> None: - expected_topic = u"test / Issue #1 dummy" - expected_message = u"""kostekIV [commented](https://try.gitea.io/kostekIV/test/pulls/1/files#issuecomment-24399) on [Issue #1](https://try.gitea.io/kostekIV/test/issues/1):\n\n~~~ quote\ntest comment\n~~~""" + expected_topic = "test / Issue #1 dummy" + expected_message = """kostekIV [commented](https://try.gitea.io/kostekIV/test/pulls/1/files#issuecomment-24399) on [Issue #1](https://try.gitea.io/kostekIV/test/issues/1):\n\n~~~ quote\ntest comment\n~~~""" self.send_and_test_stream_message('issue_comment__in_pr', expected_topic, expected_message) def test_issue_comment_edited(self) -> None: - expected_topic = u"test / Issue #3 Test issue 2" - expected_message = u"""kostekIV edited a [comment](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit test comment\n~~~""" + expected_topic = "test / Issue #3 Test issue 2" + expected_message = """kostekIV edited a [comment](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit test comment\n~~~""" self.send_and_test_stream_message('issue_comment__edited', expected_topic, expected_message) diff --git a/zerver/webhooks/gitea/view.py b/zerver/webhooks/gitea/view.py index 510f76e96e..95f6b5d922 100644 --- a/zerver/webhooks/gitea/view.py +++ b/zerver/webhooks/gitea/view.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # vim:fenc=utf-8 from typing import Any, Dict, Optional diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py index 68a5da0fb8..f357fbefd5 100644 --- a/zerver/webhooks/github/tests.py +++ b/zerver/webhooks/github/tests.py @@ -8,77 +8,77 @@ class GithubWebhookTest(WebhookTestCase): STREAM_NAME = 'github' URL_TEMPLATE = "/api/v1/external/github?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'github' - EXPECTED_TOPIC_REPO_EVENTS = u"public-repo" - EXPECTED_TOPIC_ISSUE_EVENTS = u"public-repo / Issue #2 Spelling error in the README file" - EXPECTED_TOPIC_PR_EVENTS = u"public-repo / PR #1 Update the README with new information" - EXPECTED_TOPIC_DEPLOYMENT_EVENTS = u"public-repo / Deployment on production" - EXPECTED_TOPIC_ORGANIZATION_EVENTS = u"baxterandthehackers organization" - EXPECTED_TOPIC_BRANCH_EVENTS = u"public-repo / changes" - EXPECTED_TOPIC_WIKI_EVENTS = u"public-repo / Wiki Pages" + EXPECTED_TOPIC_REPO_EVENTS = "public-repo" + EXPECTED_TOPIC_ISSUE_EVENTS = "public-repo / Issue #2 Spelling error in the README file" + EXPECTED_TOPIC_PR_EVENTS = "public-repo / PR #1 Update the README with new information" + EXPECTED_TOPIC_DEPLOYMENT_EVENTS = "public-repo / Deployment on production" + EXPECTED_TOPIC_ORGANIZATION_EVENTS = "baxterandthehackers organization" + EXPECTED_TOPIC_BRANCH_EVENTS = "public-repo / changes" + EXPECTED_TOPIC_WIKI_EVENTS = "public-repo / Wiki Pages" def test_ping_event(self) -> None: - expected_message = u"GitHub webhook has been successfully configured by TomaszKolek." + expected_message = "GitHub webhook has been successfully configured by TomaszKolek." self.send_and_test_stream_message('ping', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_star_event(self) -> None: - expected_message = u"Codertocat starred the repository." - expected_topic = u"Hello-World" + expected_message = "Codertocat starred the repository." + expected_topic = "Hello-World" self.send_and_test_stream_message('star', expected_topic, expected_message) def test_ping_organization_event(self) -> None: - expected_message = u"GitHub webhook has been successfully configured by eeshangarg." + expected_message = "GitHub webhook has been successfully configured by eeshangarg." self.send_and_test_stream_message('ping__organization', 'zulip-test-org', expected_message) def test_push_delete_branch(self) -> None: - expected_message = u"eeshangarg [deleted](https://github.com/eeshangarg/public-repo/compare/2e8cf535fb38...000000000000) the branch feature." - self.send_and_test_stream_message('push__delete_branch', u"public-repo / feature", expected_message) + expected_message = "eeshangarg [deleted](https://github.com/eeshangarg/public-repo/compare/2e8cf535fb38...000000000000) the branch feature." + self.send_and_test_stream_message('push__delete_branch', "public-repo / feature", expected_message) def test_push_local_branch_without_commits(self) -> None: - expected_message = u"eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/feature) the branch feature." - self.send_and_test_stream_message('push__local_branch_without_commits', u"public-repo / feature", expected_message) + expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/feature) the branch feature." + self.send_and_test_stream_message('push__local_branch_without_commits', "public-repo / feature", expected_message) def test_push_1_commit(self) -> None: - expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))" + expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))" self.send_and_test_stream_message('push__1_commit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_1_commit_without_username(self) -> None: - expected_message = u"eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/0383613da871...2e8cf535fb38) 1 commit to branch changes. Commits by John Snow (1).\n\n* Update the README ([2e8cf53](https://github.com/eeshangarg/public-repo/commit/2e8cf535fb38a3dab2476cdf856efda904ad4c94))" + expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/0383613da871...2e8cf535fb38) 1 commit to branch changes. Commits by John Snow (1).\n\n* Update the README ([2e8cf53](https://github.com/eeshangarg/public-repo/commit/2e8cf535fb38a3dab2476cdf856efda904ad4c94))" self.send_and_test_stream_message('push__1_commit_without_username', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_1_commit_filtered_by_branches(self) -> None: self.url = self.build_webhook_url('master,changes') - expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))" + expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))" self.send_and_test_stream_message('push__1_commit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_multiple_comitters(self) -> None: - commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' - expected_message = u"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 5) + commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' + expected_message = """baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 5) self.send_and_test_stream_message('push__multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_multiple_comitters_with_others(self) -> None: - commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' - expected_message = u"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 9) + commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' + expected_message = """baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 9) self.send_and_test_stream_message('push__multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_multiple_comitters_filtered_by_branches(self) -> None: self.url = self.build_webhook_url('master,changes') - commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' - expected_message = u"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 5) + commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' + expected_message = """baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 5) self.send_and_test_stream_message('push__multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_multiple_comitters_with_others_filtered_by_branches(self) -> None: self.url = self.build_webhook_url('master,changes') - commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' - expected_message = u"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 9) + commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' + expected_message = """baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 9) self.send_and_test_stream_message('push__multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_push_50_commits(self) -> None: commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n" - expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{}[and 30 more commit(s)]".format( + expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{}[and 30 more commit(s)]".format( commit_info * COMMITS_LIMIT ) self.send_and_test_stream_message('push__50_commits', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) @@ -86,214 +86,214 @@ class GithubWebhookTest(WebhookTestCase): def test_push_50_commits_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,changes') commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n" - expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{}[and 30 more commit(s)]".format( + expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{}[and 30 more commit(s)]".format( commit_info * COMMITS_LIMIT ) self.send_and_test_stream_message('push__50_commits', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_commit_comment_msg(self) -> None: - expected_message = u"baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394) on [9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b):\n~~~ quote\nThis is a really good change! :+1:\n~~~" + expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394) on [9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b):\n~~~ quote\nThis is a really good change! :+1:\n~~~" self.send_and_test_stream_message('commit_comment', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_create_msg(self) -> None: - expected_message = u"baxterthehacker created tag 0.0.1." + expected_message = "baxterthehacker created tag 0.0.1." self.send_and_test_stream_message('create', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_delete_msg(self) -> None: - expected_message = u"baxterthehacker deleted tag simple-tag." + expected_message = "baxterthehacker deleted tag simple-tag." self.send_and_test_stream_message('delete', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_deployment_msg(self) -> None: - expected_message = u"baxterthehacker created new deployment." + expected_message = "baxterthehacker created new deployment." self.send_and_test_stream_message('deployment', self.EXPECTED_TOPIC_DEPLOYMENT_EVENTS, expected_message) def test_deployment_status_msg(self) -> None: - expected_message = u"Deployment changed status to success." + expected_message = "Deployment changed status to success." self.send_and_test_stream_message('deployment_status', self.EXPECTED_TOPIC_DEPLOYMENT_EVENTS, expected_message) def test_fork_msg(self) -> None: - expected_message = u"baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)." + expected_message = "baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)." self.send_and_test_stream_message('fork', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_issue_comment_msg(self) -> None: - expected_message = u"baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~" + expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~" self.send_and_test_stream_message('issue_comment', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_issue_comment_deleted_msg(self) -> None: - expected_topic = u"Scheduler / Issue #5 This is a new issue" - expected_message = u"eeshangarg deleted a [comment](https://github.com/eeshangarg/Scheduler/issues/5#issuecomment-425164194) on [Issue #5](https://github.com/eeshangarg/Scheduler/issues/5):\n\n~~~ quote\nThis is a comment on this new issue.\n~~~" + expected_topic = "Scheduler / Issue #5 This is a new issue" + expected_message = "eeshangarg deleted a [comment](https://github.com/eeshangarg/Scheduler/issues/5#issuecomment-425164194) on [Issue #5](https://github.com/eeshangarg/Scheduler/issues/5):\n\n~~~ quote\nThis is a comment on this new issue.\n~~~" self.send_and_test_stream_message('issue_comment__deleted', expected_topic, expected_message) def test_issue_comment_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~" + expected_topic = "notifications" + expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~" self.send_and_test_stream_message('issue_comment', expected_topic, expected_message) def test_issue_msg(self) -> None: - expected_message = u"baxterthehacker opened [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~" + expected_message = "baxterthehacker opened [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~" self.send_and_test_stream_message('issues', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_issue_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker opened [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~" + expected_topic = "notifications" + expected_message = "baxterthehacker opened [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~" self.send_and_test_stream_message('issues', expected_topic, expected_message) def test_membership_msg(self) -> None: - expected_message = u"baxterthehacker added [kdaigle](https://github.com/kdaigle) to the Contractors team." + expected_message = "baxterthehacker added [kdaigle](https://github.com/kdaigle) to the Contractors team." self.send_and_test_stream_message('membership', self.EXPECTED_TOPIC_ORGANIZATION_EVENTS, expected_message) def test_membership_removal_msg(self) -> None: - expected_message = u"baxterthehacker removed [kdaigle](https://github.com/kdaigle) from the Contractors team." + expected_message = "baxterthehacker removed [kdaigle](https://github.com/kdaigle) from the Contractors team." self.send_and_test_stream_message('membership__removal', self.EXPECTED_TOPIC_ORGANIZATION_EVENTS, expected_message) def test_member_msg(self) -> None: - expected_message = u"baxterthehacker added [octocat](https://github.com/octocat) to [public-repo](https://github.com/baxterthehacker/public-repo)." + expected_message = "baxterthehacker added [octocat](https://github.com/octocat) to [public-repo](https://github.com/baxterthehacker/public-repo)." self.send_and_test_stream_message('member', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_pull_request_opened_msg(self) -> None: - expected_message = u"baxterthehacker opened [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~" + expected_message = "baxterthehacker opened [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~" self.send_and_test_stream_message('pull_request__opened', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_opened_with_preassigned_assignee_msg(self) -> None: - expected_topic = u"Scheduler / PR #4 Improve README" - expected_message = u"eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4) (assigned to eeshangarg) from `improve-readme-2` to `master`." + expected_topic = "Scheduler / PR #4 Improve README" + expected_message = "eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4) (assigned to eeshangarg) from `improve-readme-2` to `master`." self.send_and_test_stream_message('pull_request__opened_with_preassigned_assignee', expected_topic, expected_message) def test_pull_request_opened_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker opened [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~" + expected_topic = "notifications" + expected_message = "baxterthehacker opened [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~" self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) def test_pull_request_synchronized_msg(self) -> None: - expected_message = u"baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`." + expected_message = "baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`." self.send_and_test_stream_message('pull_request__synchronized', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_closed_msg(self) -> None: - expected_message = u"baxterthehacker closed without merge [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." + expected_message = "baxterthehacker closed without merge [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." self.send_and_test_stream_message('pull_request__closed', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_closed_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker closed without merge [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1)." + expected_topic = "notifications" + expected_message = "baxterthehacker closed without merge [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1)." self.send_and_test_stream_message('pull_request__closed', expected_topic, expected_message) def test_pull_request_merged_msg(self) -> None: - expected_message = u"baxterthehacker merged [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." + expected_message = "baxterthehacker merged [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." self.send_and_test_stream_message('pull_request__merged', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_public_msg(self) -> None: - expected_message = u"baxterthehacker made [the repository](https://github.com/baxterthehacker/public-repo) public." + expected_message = "baxterthehacker made [the repository](https://github.com/baxterthehacker/public-repo) public." self.send_and_test_stream_message('public', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_wiki_pages_msg(self) -> None: - expected_message = u"jasonrudolph:\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)" + expected_message = "jasonrudolph:\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)" self.send_and_test_stream_message('gollum__wiki_pages', self.EXPECTED_TOPIC_WIKI_EVENTS, expected_message) def test_watch_msg(self) -> None: - expected_message = u"baxterthehacker starred [the repository](https://github.com/baxterthehacker/public-repo)." + expected_message = "baxterthehacker starred [the repository](https://github.com/baxterthehacker/public-repo)." self.send_and_test_stream_message('watch__repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_repository_msg(self) -> None: - expected_message = u"baxterthehacker created [the repository](https://github.com/baxterandthehackers/public-repo)." + expected_message = "baxterthehacker created [the repository](https://github.com/baxterandthehackers/public-repo)." self.send_and_test_stream_message('repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_team_add_msg(self) -> None: - expected_message = u"[The repository](https://github.com/baxterandthehackers/public-repo) was added to team github." + expected_message = "[The repository](https://github.com/baxterandthehackers/public-repo) was added to team github." self.send_and_test_stream_message('team_add', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_release_msg(self) -> None: - expected_message = u"baxterthehacker published [release for tag 0.0.1](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1)." + expected_message = "baxterthehacker published [release for tag 0.0.1](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1)." self.send_and_test_stream_message('release', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_page_build_msg(self) -> None: - expected_message = u"Github Pages build, triggered by baxterthehacker, has finished building." + expected_message = "Github Pages build, triggered by baxterthehacker, has finished building." self.send_and_test_stream_message('page_build', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_status_msg(self) -> None: - expected_message = u"[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to success." + expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to success." self.send_and_test_stream_message('status', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_status_with_target_url_msg(self) -> None: - expected_message = u"[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to [success](https://example.com/build/status)." + expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to [success](https://example.com/build/status)." self.send_and_test_stream_message('status__with_target_url', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_pull_request_review_msg(self) -> None: - expected_message = u"baxterthehacker submitted [PR Review](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)." + expected_message = "baxterthehacker submitted [PR Review](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)." self.send_and_test_stream_message('pull_request_review', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_review_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker submitted [PR Review for #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)." + expected_topic = "notifications" + expected_message = "baxterthehacker submitted [PR Review for #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)." self.send_and_test_stream_message('pull_request_review', expected_topic, expected_message) def test_pull_request_review_comment_msg(self) -> None: - expected_message = u"baxterthehacker created [PR Review Comment](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~" + expected_message = "baxterthehacker created [PR Review Comment](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~" self.send_and_test_stream_message('pull_request_review_comment', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_review_comment_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker created [PR Review Comment on #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~" + expected_topic = "notifications" + expected_message = "baxterthehacker created [PR Review Comment on #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~" self.send_and_test_stream_message('pull_request_review_comment', expected_topic, expected_message) def test_push_tag_msg(self) -> None: - expected_message = u"baxterthehacker pushed tag abc." + expected_message = "baxterthehacker pushed tag abc." self.send_and_test_stream_message('push__tag', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) def test_pull_request_edited_msg(self) -> None: - expected_message = u"baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`." + expected_message = "baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`." self.send_and_test_stream_message('pull_request__edited', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_assigned_msg(self) -> None: - expected_message = u"baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." + expected_message = "baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." self.send_and_test_stream_message('pull_request__assigned', self.EXPECTED_TOPIC_PR_EVENTS, expected_message) def test_pull_request_assigned_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"baxterthehacker assigned [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." + expected_topic = "notifications" + expected_message = "baxterthehacker assigned [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message) def test_pull_request_unassigned_msg(self) -> None: - expected_message = u"eeshangarg unassigned [PR #1](https://github.com/zulip-test-org/helloworld/pull/1)." + expected_message = "eeshangarg unassigned [PR #1](https://github.com/zulip-test-org/helloworld/pull/1)." self.send_and_test_stream_message('pull_request__unassigned', 'helloworld / PR #1 Mention that Zulip rocks!', expected_message) def test_pull_request_review_requested_msg(self) -> None: - expected_message = u"**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." + expected_message = "**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." self.send_and_test_stream_message('pull_request__review_requested', 'Scheduler / PR #1 This is just a test commit', expected_message) def test_pull_request_review_requested_singular_key_msg(self) -> None: - expected_message = u"**eeshangarg** requested [rishig](https://github.com/rishig) for a review on [PR #6](https://github.com/eeshangarg/Scheduler/pull/6)." + expected_message = "**eeshangarg** requested [rishig](https://github.com/rishig) for a review on [PR #6](https://github.com/eeshangarg/Scheduler/pull/6)." self.send_and_test_stream_message('pull_request__review_requested_singular_key', 'Scheduler / PR #6 Mention how awesome this project is in ...', expected_message) def test_pull_request_review_requested_multiple_reviwers_msg(self) -> None: - expected_message = u"**eeshangarg** requested [showell](https://github.com/showell) and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." + expected_message = "**eeshangarg** requested [showell](https://github.com/showell) and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." self.send_and_test_stream_message('pull_request__review_requested_multiple_reviewers', 'Scheduler / PR #1 This is just a test commit', expected_message) def test_pull_request__review_requested_team_reviewer_msg(self) -> None: - expected_message = u"**singhsourabh** requested [shreyaskargit](https://github.com/shreyaskargit), [bajaj99prashant](https://github.com/bajaj99prashant), [review-team](https://github.com/orgs/test-org965/teams/review-team), [authority](https://github.com/orgs/test-org965/teams/authority) and [management](https://github.com/orgs/test-org965/teams/management) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4)." + expected_message = "**singhsourabh** requested [shreyaskargit](https://github.com/shreyaskargit), [bajaj99prashant](https://github.com/bajaj99prashant), [review-team](https://github.com/orgs/test-org965/teams/review-team), [authority](https://github.com/orgs/test-org965/teams/authority) and [management](https://github.com/orgs/test-org965/teams/management) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4)." self.send_and_test_stream_message('pull_request__review_requested_team_reviewer', 'webhook-test / PR #4 testing webhook', expected_message) def test_pull_request_review_requested_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1 This is just a test commit](https://github.com/eeshangarg/Scheduler/pull/1)." + expected_topic = "notifications" + expected_message = "**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1 This is just a test commit](https://github.com/eeshangarg/Scheduler/pull/1)." self.send_and_test_stream_message('pull_request__review_requested', expected_topic, expected_message) def test_check_run(self) -> None: - expected_topic = u"hello-world / checks" - expected_message = u""" + expected_topic = "hello-world / checks" + expected_message = """ Check [randscape](http://github.com/github/hello-world/runs/4) completed (success). ([d6fde92](http://github.com/github/hello-world/commit/d6fde92930d4715a2b49857d24b940956b26d2d3)) """.strip() self.send_and_test_stream_message('check_run__completed', expected_topic, expected_message) diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py index 793c5b6de1..22c946a903 100644 --- a/zerver/webhooks/github/view.py +++ b/zerver/webhooks/github/view.py @@ -80,7 +80,7 @@ def get_membership_body(payload: Dict[str, Any]) -> str: member = payload['member'] team_name = payload['team']['name'] - return u"{sender} {action} [{username}]({html_url}) {preposition} the {team_name} team.".format( + return "{sender} {action} [{username}]({html_url}) {preposition} the {team_name} team.".format( sender=get_sender_name(payload), action=action, username=member['login'], @@ -90,7 +90,7 @@ def get_membership_body(payload: Dict[str, Any]) -> str: ) def get_member_body(payload: Dict[str, Any]) -> str: - return u"{} {} [{}]({}) to [{}]({}).".format( + return "{} {} [{}]({}) to [{}]({}).".format( get_sender_name(payload), payload['action'], payload['member']['login'], @@ -137,25 +137,25 @@ def get_issue_comment_body(payload: Dict[str, Any], def get_fork_body(payload: Dict[str, Any]) -> str: forkee = payload['forkee'] - return u"{} forked [{}]({}).".format( + return "{} forked [{}]({}).".format( get_sender_name(payload), forkee['name'], forkee['html_url'] ) def get_deployment_body(payload: Dict[str, Any]) -> str: - return u'{} created new deployment.'.format( + return '{} created new deployment.'.format( get_sender_name(payload), ) def get_change_deployment_status_body(payload: Dict[str, Any]) -> str: - return u'Deployment changed status to {}.'.format( + return 'Deployment changed status to {}.'.format( payload['deployment_status']['state'], ) def get_create_or_delete_body(payload: Dict[str, Any], action: str) -> str: ref_type = payload['ref_type'] - return u'{} {} {} {}.'.format( + return '{} {} {} {}.'.format( get_sender_name(payload), action, ref_type, @@ -166,7 +166,7 @@ def get_commit_comment_body(payload: Dict[str, Any]) -> str: comment = payload['comment'] comment_url = comment['html_url'] commit_url = comment_url.split('#', 1)[0] - action = u'[commented]({})'.format(comment_url) + action = '[commented]({})'.format(comment_url) return get_commits_comment_action_message( get_sender_name(payload), action, @@ -199,43 +199,43 @@ def get_push_commits_body(payload: Dict[str, Any]) -> str: ) def get_public_body(payload: Dict[str, Any]) -> str: - return u"{} made [the repository]({}) public.".format( + return "{} made [the repository]({}) public.".format( get_sender_name(payload), payload['repository']['html_url'], ) def get_wiki_pages_body(payload: Dict[str, Any]) -> str: - wiki_page_info_template = u"* {action} [{title}]({url})\n" - wiki_info = u'' + wiki_page_info_template = "* {action} [{title}]({url})\n" + wiki_info = '' for page in payload['pages']: wiki_info += wiki_page_info_template.format( action=page['action'], title=page['title'], url=page['html_url'], ) - return u"{}:\n{}".format(get_sender_name(payload), wiki_info.rstrip()) + return "{}:\n{}".format(get_sender_name(payload), wiki_info.rstrip()) def get_watch_body(payload: Dict[str, Any]) -> str: - return u"{} starred [the repository]({}).".format( + return "{} starred [the repository]({}).".format( get_sender_name(payload), payload['repository']['html_url'] ) def get_repository_body(payload: Dict[str, Any]) -> str: - return u"{} {} [the repository]({}).".format( + return "{} {} [the repository]({}).".format( get_sender_name(payload), payload.get('action'), payload['repository']['html_url'] ) def get_add_team_body(payload: Dict[str, Any]) -> str: - return u"[The repository]({}) was added to team {}.".format( + return "[The repository]({}) was added to team {}.".format( payload['repository']['html_url'], payload['team']['name'] ) def get_release_body(payload: Dict[str, Any]) -> str: - return u"{} {} [release for tag {}]({}).".format( + return "{} {} [release for tag {}]({}).".format( get_sender_name(payload), payload['action'], payload['release']['tag_name'], @@ -257,7 +257,7 @@ def get_page_build_body(payload: Dict[str, Any]) -> str: CONTENT_MESSAGE_TEMPLATE.format(message=build['error']['message']) ) - return u"Github Pages build, triggered by {}, {}.".format( + return "Github Pages build, triggered by {}, {}.".format( payload['build']['pusher']['login'], action ) @@ -270,7 +270,7 @@ def get_status_body(payload: Dict[str, Any]) -> str: ) else: status = payload['state'] - return u"[{}]({}) changed its status to {}.".format( + return "[{}]({}) changed its status to {}.".format( payload['sha'][:7], # TODO payload['commit']['html_url'], status @@ -412,12 +412,12 @@ def get_subject_based_on_type(payload: Dict[str, Any], event: str) -> str: title=payload['issue']['title'] ) elif event.startswith('deployment'): - return u"{} / Deployment on {}".format( + return "{} / Deployment on {}".format( get_repository_name(payload), payload['deployment']['environment'] ) elif event == 'membership': - return u"{} organization".format(payload['organization']['login']) + return "{} organization".format(payload['organization']['login']) elif event == 'push_commits': return TOPIC_WITH_BRANCH_TEMPLATE.format( repo=get_repository_name(payload), @@ -432,7 +432,7 @@ def get_subject_based_on_type(payload: Dict[str, Any], event: str) -> str: if payload.get('repository') is None: return get_organization_name(payload) elif event == 'check_run': - return u"{} / checks".format(get_repository_name(payload)) + return "{} / checks".format(get_repository_name(payload)) return get_repository_name(payload) diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.py index fdf4c56cf3..c718b41887 100644 --- a/zerver/webhooks/gitlab/tests.py +++ b/zerver/webhooks/gitlab/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -12,41 +11,41 @@ class GitlabHookTests(WebhookTestCase): def test_push_event_specified_topic(self) -> None: self.url = self.build_webhook_url("topic=Specific%20topic") - expected_topic = u"Specific topic" - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" + expected_topic = "Specific topic" + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" self.send_and_test_stream_message('push_hook', expected_topic, expected_message) def test_push_event_message(self) -> None: - expected_topic = u"my-awesome-project / tomek" - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" + expected_topic = "my-awesome-project / tomek" + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" self.send_and_test_stream_message('push_hook', expected_topic, expected_message) def test_push_local_branch_without_commits(self) -> None: - expected_topic = u"my-awesome-project / changes" - expected_message = u"Eeshan Garg [pushed](https://gitlab.com/eeshangarg/my-awesome-project/compare/0000000000000000000000000000000000000000...68d7a5528cf423dfaac37dd62a56ac9cc8a884e3) the branch changes." + expected_topic = "my-awesome-project / changes" + expected_message = "Eeshan Garg [pushed](https://gitlab.com/eeshangarg/my-awesome-project/compare/0000000000000000000000000000000000000000...68d7a5528cf423dfaac37dd62a56ac9cc8a884e3) the branch changes." self.send_and_test_stream_message('push_hook__push_local_branch_without_commits', expected_topic, expected_message) def test_push_event_message_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,tomek') - expected_topic = u"my-awesome-project / tomek" - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" + expected_topic = "my-awesome-project / tomek" + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" self.send_and_test_stream_message('push_hook', expected_topic, expected_message) def test_push_multiple_committers(self) -> None: - expected_topic = u"my-awesome-project / tomek" - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek. Commits by Ben (1) and Tomasz Kolek (1).\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" + expected_topic = "my-awesome-project / tomek" + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek. Commits by Ben (1) and Tomasz Kolek (1).\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" self.send_and_test_stream_message('push_hook__push_multiple_committers', expected_topic, expected_message) def test_push_multiple_committers_with_others(self) -> None: - expected_topic = u"my-awesome-project / tomek" - commit_info = u"* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))\n" - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 7 commits to branch tomek. Commits by Ben (3), baxterthehacker (2), James (1) and others (1).\n\n{}* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))".format(commit_info * 6) + expected_topic = "my-awesome-project / tomek" + commit_info = "* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))\n" + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 7 commits to branch tomek. Commits by Ben (3), baxterthehacker (2), James (1) and others (1).\n\n{}* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))".format(commit_info * 6) self.send_and_test_stream_message('push_hook__push_multiple_committers_with_others', expected_topic, expected_message) def test_push_commits_more_than_limit_event_message(self) -> None: - expected_topic = u"my-awesome-project / tomek" - commits_info = u'* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{}[and {} more commit(s)]".format( + expected_topic = "my-awesome-project / tomek" + commits_info = '* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 50 - COMMITS_LIMIT, ) @@ -54,23 +53,23 @@ class GitlabHookTests(WebhookTestCase): def test_push_commits_more_than_limit_message_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,tomek') - expected_topic = u"my-awesome-project / tomek" - commits_info = u'* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' - expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{}[and {} more commit(s)]".format( + expected_topic = "my-awesome-project / tomek" + commits_info = '* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' + expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 50 - COMMITS_LIMIT, ) self.send_and_test_stream_message('push_hook__push_commits_more_than_limit', expected_topic, expected_message) def test_remove_branch_event_message(self) -> None: - expected_topic = u"my-awesome-project / tomek" - expected_message = u"Tomasz Kolek deleted branch tomek." + expected_topic = "my-awesome-project / tomek" + expected_message = "Tomasz Kolek deleted branch tomek." self.send_and_test_stream_message('push_hook__remove_branch', expected_topic, expected_message) def test_add_tag_event_message(self) -> None: - expected_topic = u"my-awesome-project" - expected_message = u"Tomasz Kolek pushed tag xyz." + expected_topic = "my-awesome-project" + expected_message = "Tomasz Kolek pushed tag xyz." self.send_and_test_stream_message( 'tag_push_hook__add_tag', @@ -80,8 +79,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_remove_tag_event_message(self) -> None: - expected_topic = u"my-awesome-project" - expected_message = u"Tomasz Kolek removed tag xyz." + expected_topic = "my-awesome-project" + expected_message = "Tomasz Kolek removed tag xyz." self.send_and_test_stream_message( 'tag_push_hook__remove_tag', @@ -89,8 +88,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_issue_without_assignee_event_message(self) -> None: - expected_topic = u"my-awesome-project / Issue #1 Issue title" - expected_message = u"Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~" + expected_topic = "my-awesome-project / Issue #1 Issue title" + expected_message = "Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~" self.send_and_test_stream_message( 'issue_hook__issue_created_without_assignee', @@ -98,8 +97,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_confidential_issue_without_assignee_event_message(self) -> None: - expected_subject = u"testing / Issue #1 Testing" - expected_message = u"Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nTesting\n~~~" + expected_subject = "testing / Issue #1 Testing" + expected_message = "Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nTesting\n~~~" self.send_and_test_stream_message( 'issue_hook__confidential_issue_created_without_assignee', @@ -108,8 +107,8 @@ class GitlabHookTests(WebhookTestCase): def test_create_issue_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek created [Issue #1 Issue title](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~" + expected_topic = "notifications" + expected_message = "Tomasz Kolek created [Issue #1 Issue title](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~" self.send_and_test_stream_message( 'issue_hook__issue_created_without_assignee', @@ -117,8 +116,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_issue_with_assignee_event_message(self) -> None: - expected_topic = u"my-awesome-project / Issue #1 Issue title" - expected_message = u"Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1) (assigned to Tomasz Kolek):\n\n~~~ quote\nIssue description\n~~~" + expected_topic = "my-awesome-project / Issue #1 Issue title" + expected_message = "Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1) (assigned to Tomasz Kolek):\n\n~~~ quote\nIssue description\n~~~" self.send_and_test_stream_message( 'issue_hook__issue_created_with_assignee', @@ -126,8 +125,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_issue_with_two_assignees_event_message(self) -> None: - expected_subject = u"Zulip GitLab Test / Issue #2 Zulip Test Issue 2" - expected_message = u"Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds and eeshangarg):\n\n~~~ quote\nZulip Test Issue 2\n~~~" + expected_subject = "Zulip GitLab Test / Issue #2 Zulip Test Issue 2" + expected_message = "Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds and eeshangarg):\n\n~~~ quote\nZulip Test Issue 2\n~~~" self.send_and_test_stream_message( 'issue_hook__issue_created_with_two_assignees', @@ -135,8 +134,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_issue_with_three_assignees_event_message(self) -> None: - expected_subject = u"Zulip GitLab Test / Issue #2 Zulip Test Issue 2" - expected_message = u"Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds, eeshangarg and timabbott):\n\n~~~ quote\nZulip Test Issue 2\n~~~" + expected_subject = "Zulip GitLab Test / Issue #2 Zulip Test Issue 2" + expected_message = "Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds, eeshangarg and timabbott):\n\n~~~ quote\nZulip Test Issue 2\n~~~" self.send_and_test_stream_message( 'issue_hook__issue_created_with_three_assignees', @@ -144,8 +143,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_confidential_issue_with_assignee_event_message(self) -> None: - expected_subject = u"testing / Issue #2 Testing" - expected_message = u"Joe Bloggs created [Issue #2](https://gitlab.example.co.uk/joe.bloggs/testing/issues/2) (assigned to joe.bloggs):\n\n~~~ quote\nTesting\n~~~" + expected_subject = "testing / Issue #2 Testing" + expected_message = "Joe Bloggs created [Issue #2](https://gitlab.example.co.uk/joe.bloggs/testing/issues/2) (assigned to joe.bloggs):\n\n~~~ quote\nTesting\n~~~" self.send_and_test_stream_message( 'issue_hook__confidential_issue_created_with_assignee', @@ -153,8 +152,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_issue_with_hidden_comment_in_description(self) -> None: - expected_topic = u"public-repo / Issue #3 New Issue with hidden comment" - expected_message = u"Eeshan Garg created [Issue #3](https://gitlab.com/eeshangarg/public-repo/issues/3):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~" + expected_topic = "public-repo / Issue #3 New Issue with hidden comment" + expected_message = "Eeshan Garg created [Issue #3](https://gitlab.com/eeshangarg/public-repo/issues/3):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~" self.send_and_test_stream_message( 'issue_hook__issue_created_with_hidden_comment_in_description', @@ -162,8 +161,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_confidential_issue_with_hidden_comment_in_description(self) -> None: - expected_subject = u"testing / Issue #1 Testing" - expected_message = u"Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~" + expected_subject = "testing / Issue #1 Testing" + expected_message = "Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~" self.send_and_test_stream_message( 'issue_hook__confidential_issue_created_with_hidden_comment_in_description', @@ -171,16 +170,16 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_create_issue_with_null_description(self) -> None: - expected_topic = u"my-awesome-project / Issue #7 Issue without description" - expected_message = u"Eeshan Garg created [Issue #7](https://gitlab.com/eeshangarg/my-awesome-project/issues/7)." + expected_topic = "my-awesome-project / Issue #7 Issue without description" + expected_message = "Eeshan Garg created [Issue #7](https://gitlab.com/eeshangarg/my-awesome-project/issues/7)." self.send_and_test_stream_message( 'issue_hook__issue_opened_with_null_description', expected_topic, expected_message) def test_update_issue_event_message(self) -> None: - expected_topic = u"my-awesome-project / Issue #1 Issue title_new" - expected_message = u"Tomasz Kolek updated [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." + expected_topic = "my-awesome-project / Issue #1 Issue title_new" + expected_message = "Tomasz Kolek updated [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." self.send_and_test_stream_message( 'issue_hook__issue_updated', @@ -188,8 +187,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_update_confidential_issue_event_message(self) -> None: - expected_subject = u"testing / Issue #1 Testing" - expected_message = u"Joe Bloggs updated [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." + expected_subject = "testing / Issue #1 Testing" + expected_message = "Joe Bloggs updated [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." self.send_and_test_stream_message( 'issue_hook__confidential_issue_updated', @@ -198,8 +197,8 @@ class GitlabHookTests(WebhookTestCase): def test_update_issue_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek updated [Issue #1 Issue title_new](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." + expected_topic = "notifications" + expected_message = "Tomasz Kolek updated [Issue #1 Issue title_new](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." self.send_and_test_stream_message( 'issue_hook__issue_updated', @@ -207,8 +206,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_close_issue_event_message(self) -> None: - expected_topic = u"my-awesome-project / Issue #1 Issue title_new" - expected_message = u"Tomasz Kolek closed [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." + expected_topic = "my-awesome-project / Issue #1 Issue title_new" + expected_message = "Tomasz Kolek closed [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." self.send_and_test_stream_message( 'issue_hook__issue_closed', @@ -216,8 +215,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_close_confidential_issue_event_message(self) -> None: - expected_subject = u"testing / Issue #1 Testing Test" - expected_message = u"Joe Bloggs closed [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." + expected_subject = "testing / Issue #1 Testing Test" + expected_message = "Joe Bloggs closed [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." self.send_and_test_stream_message( 'issue_hook__confidential_issue_closed', @@ -225,8 +224,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_reopen_issue_event_message(self) -> None: - expected_topic = u"my-awesome-project / Issue #1 Issue title_new" - expected_message = u"Tomasz Kolek reopened [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." + expected_topic = "my-awesome-project / Issue #1 Issue title_new" + expected_message = "Tomasz Kolek reopened [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." self.send_and_test_stream_message( 'issue_hook__issue_reopened', @@ -234,8 +233,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_reopen_confidential_issue_event_message(self) -> None: - expected_subject = u"testing / Issue #1 Testing Test" - expected_message = u"Joe Bloggs reopened [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." + expected_subject = "testing / Issue #1 Testing Test" + expected_message = "Joe Bloggs reopened [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." self.send_and_test_stream_message( 'issue_hook__confidential_issue_reopened', @@ -243,8 +242,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_note_commit_event_message(self) -> None: - expected_topic = u"my-awesome-project" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7#note_14169211) on [66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7):\n~~~ quote\nnice commit\n~~~" + expected_topic = "my-awesome-project" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7#note_14169211) on [66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7):\n~~~ quote\nnice commit\n~~~" self.send_and_test_stream_message( 'note_hook__commit_note', @@ -252,8 +251,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_note_merge_request_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #1 Tomek" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" + expected_topic = "my-awesome-project / MR #1 Tomek" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" self.send_and_test_stream_message( 'note_hook__merge_request_note', @@ -262,8 +261,8 @@ class GitlabHookTests(WebhookTestCase): def test_note_merge_request_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1 Tomek](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" + expected_topic = "notifications" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1 Tomek](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" self.send_and_test_stream_message( 'note_hook__merge_request_note', @@ -271,8 +270,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_note_issue_event_message(self) -> None: - expected_topic = u"my-awesome-project / Issue #2 abc" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~" + expected_topic = "my-awesome-project / Issue #2 abc" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~" self.send_and_test_stream_message( 'note_hook__issue_note', @@ -280,8 +279,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_note_confidential_issue_event_message(self) -> None: - expected_subject = u"Test / Issue #3 Test" - expected_message = u"Joe Bloggs [commented](https://gitlab.com/joebloggs/test/issues/3#note_101638770) on [Issue #3](https://gitlab.com/joebloggs/test/issues/3):\n\n~~~ quote\nTest\n~~~" + expected_subject = "Test / Issue #3 Test" + expected_message = "Joe Bloggs [commented](https://gitlab.com/joebloggs/test/issues/3#note_101638770) on [Issue #3](https://gitlab.com/joebloggs/test/issues/3):\n\n~~~ quote\nTest\n~~~" self.send_and_test_stream_message( 'note_hook__confidential_issue_note', @@ -290,8 +289,8 @@ class GitlabHookTests(WebhookTestCase): def test_note_issue_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2 abc](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~" + expected_topic = "notifications" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2 abc](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~" self.send_and_test_stream_message( 'note_hook__issue_note', @@ -299,8 +298,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_note_snippet_event_message(self) -> None: - expected_topic = u"my-awesome-project / Snippet #2 test" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~" + expected_topic = "my-awesome-project / Snippet #2 test" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~" self.send_and_test_stream_message( 'note_hook__snippet_note', @@ -309,8 +308,8 @@ class GitlabHookTests(WebhookTestCase): def test_note_snippet_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2 test](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~" + expected_topic = "notifications" + expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2 test](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~" self.send_and_test_stream_message( 'note_hook__snippet_note', @@ -318,8 +317,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_merge_request_created_without_assignee_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #2 NEW MR" - expected_message = u"Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" + expected_topic = "my-awesome-project / MR #2 NEW MR" + expected_message = "Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" self.send_and_test_stream_message( 'merge_request_hook__merge_request_created_without_assignee', @@ -328,8 +327,8 @@ class GitlabHookTests(WebhookTestCase): def test_merge_request_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" + expected_topic = "notifications" + expected_message = "Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" self.send_and_test_stream_message( 'merge_request_hook__merge_request_created_without_assignee', @@ -337,16 +336,16 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_merge_request_created_with_assignee_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #3 New Merge Request" - expected_message = u"Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" + expected_topic = "my-awesome-project / MR #3 New Merge Request" + expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" self.send_and_test_stream_message( 'merge_request_hook__merge_request_created_with_assignee', expected_topic, expected_message) def test_merge_request_closed_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #2 NEW MR" - expected_message = u"Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." + expected_topic = "my-awesome-project / MR #2 NEW MR" + expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." self.send_and_test_stream_message( 'merge_request_hook__merge_request_closed', @@ -355,8 +354,8 @@ class GitlabHookTests(WebhookTestCase): def test_merge_request_closed_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." + expected_topic = "notifications" + expected_message = "Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." self.send_and_test_stream_message( 'merge_request_hook__merge_request_closed', @@ -364,8 +363,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_merge_request_reopened_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #1 Update the README with author ..." - expected_message = u"Eeshan Garg reopened [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." + expected_topic = "my-awesome-project / MR #1 Update the README with author ..." + expected_message = "Eeshan Garg reopened [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." self.send_and_test_stream_message( 'merge_request_hook__merge_request_reopened', @@ -373,8 +372,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_merge_request_approved_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #1 Update the README with author ..." - expected_message = u"Eeshan Garg approved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." + expected_topic = "my-awesome-project / MR #1 Update the README with author ..." + expected_message = "Eeshan Garg approved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." self.send_and_test_stream_message( 'merge_request_hook__merge_request_approved', @@ -382,24 +381,24 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_merge_request_updated_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #3 New Merge Request" - expected_message = u"Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\nupdated desc\n~~~" + expected_topic = "my-awesome-project / MR #3 New Merge Request" + expected_message = "Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\nupdated desc\n~~~" self.send_and_test_stream_message( 'merge_request_hook__merge_request_updated', expected_topic, expected_message) def test_merge_request_added_commit_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #3 New Merge Request" - expected_message = u"Tomasz Kolek added commit(s) to [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." + expected_topic = "my-awesome-project / MR #3 New Merge Request" + expected_message = "Tomasz Kolek added commit(s) to [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." self.send_and_test_stream_message( 'merge_request_hook__merge_request_added_commit', expected_topic, expected_message) def test_merge_request_merged_event_message(self) -> None: - expected_topic = u"my-awesome-project / MR #3 New Merge Request" - expected_message = u"Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." + expected_topic = "my-awesome-project / MR #3 New Merge Request" + expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." self.send_and_test_stream_message( 'merge_request_hook__merge_request_merged', @@ -407,8 +406,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_wiki_page_opened_event_message(self) -> None: - expected_topic = u"my-awesome-project" - expected_message = u"Tomasz Kolek created [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." + expected_topic = "my-awesome-project" + expected_message = "Tomasz Kolek created [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." self.send_and_test_stream_message( 'wiki_page_hook__wiki_page_opened', @@ -416,8 +415,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_wiki_page_edited_event_message(self) -> None: - expected_topic = u"my-awesome-project" - expected_message = u"Tomasz Kolek updated [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." + expected_topic = "my-awesome-project" + expected_message = "Tomasz Kolek updated [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." self.send_and_test_stream_message( 'wiki_page_hook__wiki_page_edited', @@ -425,8 +424,8 @@ class GitlabHookTests(WebhookTestCase): expected_message) def test_build_created_event_message(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Build job_name from test stage was created." + expected_topic = "my-awesome-project / master" + expected_message = "Build job_name from test stage was created." self.send_and_test_stream_message( 'build_created', @@ -436,8 +435,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_build_started_event_message(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Build job_name from test stage started." + expected_topic = "my-awesome-project / master" + expected_message = "Build job_name from test stage started." self.send_and_test_stream_message( 'build_started', @@ -447,8 +446,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_build_succeeded_event_message(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Build job_name from test stage changed status to success." + expected_topic = "my-awesome-project / master" + expected_message = "Build job_name from test stage changed status to success." self.send_and_test_stream_message( 'build_succeeded', @@ -458,8 +457,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_build_created_event_message_legacy_event_name(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Build job_name from test stage was created." + expected_topic = "my-awesome-project / master" + expected_message = "Build job_name from test stage was created." self.send_and_test_stream_message( 'build_created', @@ -469,8 +468,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_build_started_event_message_legacy_event_name(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Build job_name from test stage started." + expected_topic = "my-awesome-project / master" + expected_message = "Build job_name from test stage started." self.send_and_test_stream_message( 'build_started', @@ -480,8 +479,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_build_succeeded_event_message_legacy_event_name(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Build job_name from test stage changed status to success." + expected_topic = "my-awesome-project / master" + expected_message = "Build job_name from test stage changed status to success." self.send_and_test_stream_message( 'build_succeeded', @@ -491,8 +490,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_pipeline_succeeded_event_message(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Pipeline changed status to success with build(s):\n* job_name2 - success\n* job_name - success." + expected_topic = "my-awesome-project / master" + expected_message = "Pipeline changed status to success with build(s):\n* job_name2 - success\n* job_name - success." self.send_and_test_stream_message( 'pipeline_hook__pipeline_succeeded', @@ -501,8 +500,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_pipeline_started_event_message(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Pipeline started with build(s):\n* job_name - running\n* job_name2 - pending." + expected_topic = "my-awesome-project / master" + expected_message = "Pipeline started with build(s):\n* job_name - running\n* job_name2 - pending." self.send_and_test_stream_message( 'pipeline_hook__pipeline_started', @@ -511,8 +510,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_pipeline_pending_event_message(self) -> None: - expected_topic = u"my-awesome-project / master" - expected_message = u"Pipeline was created with build(s):\n* job_name2 - pending\n* job_name - created." + expected_topic = "my-awesome-project / master" + expected_message = "Pipeline was created with build(s):\n* job_name2 - pending\n* job_name - created." self.send_and_test_stream_message( 'pipeline_hook__pipeline_pending', @@ -521,8 +520,8 @@ class GitlabHookTests(WebhookTestCase): ) def test_issue_type_test_payload(self) -> None: - expected_topic = u'public-repo' - expected_message = u"Webhook for **public-repo** has been configured successfully! :tada:" + expected_topic = 'public-repo' + expected_message = "Webhook for **public-repo** has been configured successfully! :tada:" self.send_and_test_stream_message( 'test_hook__issue_test_payload', diff --git a/zerver/webhooks/gitlab/view.py b/zerver/webhooks/gitlab/view.py index 0f3d7307fa..558badd687 100644 --- a/zerver/webhooks/gitlab/view.py +++ b/zerver/webhooks/gitlab/view.py @@ -32,7 +32,7 @@ def get_push_event_body(payload: Dict[str, Any]) -> str: return get_normal_push_event_body(payload) def get_normal_push_event_body(payload: Dict[str, Any]) -> str: - compare_url = u'{}/compare/{}...{}'.format( + compare_url = '{}/compare/{}...{}'.format( get_repository_homepage(payload), payload['before'], payload['after'] @@ -152,7 +152,7 @@ def get_objects_assignee(payload: Dict[str, Any]) -> Optional[str]: def get_commented_commit_event_body(payload: Dict[str, Any]) -> str: comment = payload['object_attributes'] - action = u'[commented]({})'.format(comment['url']) + action = '[commented]({})'.format(comment['url']) return get_commits_comment_action_message( get_issue_user_name(payload), action, @@ -164,8 +164,8 @@ def get_commented_commit_event_body(payload: Dict[str, Any]) -> str: def get_commented_merge_request_event_body(payload: Dict[str, Any], include_title: Optional[bool]=False) -> str: comment = payload['object_attributes'] - action = u'[commented]({}) on'.format(comment['url']) - url = u'{}/merge_requests/{}'.format( + action = '[commented]({}) on'.format(comment['url']) + url = '{}/merge_requests/{}'.format( payload['project'].get('web_url'), payload['merge_request'].get('iid') ) @@ -183,8 +183,8 @@ def get_commented_merge_request_event_body(payload: Dict[str, Any], def get_commented_issue_event_body(payload: Dict[str, Any], include_title: Optional[bool]=False) -> str: comment = payload['object_attributes'] - action = u'[commented]({}) on'.format(comment['url']) - url = u'{}/issues/{}'.format( + action = '[commented]({}) on'.format(comment['url']) + url = '{}/issues/{}'.format( payload['project'].get('web_url'), payload['issue'].get('iid') ) @@ -202,8 +202,8 @@ def get_commented_issue_event_body(payload: Dict[str, Any], def get_commented_snippet_event_body(payload: Dict[str, Any], include_title: Optional[bool]=False) -> str: comment = payload['object_attributes'] - action = u'[commented]({}) on'.format(comment['url']) - url = u'{}/snippets/{}'.format( + action = '[commented]({}) on'.format(comment['url']) + url = '{}/snippets/{}'.format( payload['project'].get('web_url'), payload['snippet'].get('id') ) @@ -219,7 +219,7 @@ def get_commented_snippet_event_body(payload: Dict[str, Any], ) def get_wiki_page_event_body(payload: Dict[str, Any], action: str) -> str: - return u"{} {} [Wiki Page \"{}\"]({}).".format( + return "{} {} [Wiki Page \"{}\"]({}).".format( get_issue_user_name(payload), action, payload['object_attributes'].get('title'), @@ -234,14 +234,14 @@ def get_build_hook_event_body(payload: Dict[str, Any]) -> str: action = 'started' else: action = 'changed status to {}'.format(build_status) - return u"Build {} from {} stage {}.".format( + return "Build {} from {} stage {}.".format( payload.get('build_name'), payload.get('build_stage'), action ) def get_test_event_body(payload: Dict[str, Any]) -> str: - return u"Webhook for **{repo}** has been configured successfully! :tada:".format( + return "Webhook for **{repo}** has been configured successfully! :tada:".format( repo=get_repo_name(payload)) def get_pipeline_event_body(payload: Dict[str, Any]) -> str: @@ -253,10 +253,10 @@ def get_pipeline_event_body(payload: Dict[str, Any]) -> str: else: action = 'changed status to {}'.format(pipeline_status) - builds_status = u"" + builds_status = "" for build in payload['builds']: - builds_status += u"* {} - {}\n".format(build.get('name'), build.get('status')) - return u"Pipeline {} with build(s):\n{}.".format(action, builds_status[:-1]) + builds_status += "* {} - {}\n".format(build.get('name'), build.get('status')) + return "Pipeline {} with build(s):\n{}.".format(action, builds_status[:-1]) def get_repo_name(payload: Dict[str, Any]) -> str: return payload['project']['name'] @@ -335,11 +335,11 @@ def get_body_based_on_event(event: str) -> Any: def get_subject_based_on_event(event: str, payload: Dict[str, Any]) -> str: if event == 'Push Hook': - return u"{} / {}".format(get_repo_name(payload), get_branch_name(payload)) + return "{} / {}".format(get_repo_name(payload), get_branch_name(payload)) elif event == 'Job Hook' or event == 'Build Hook': - return u"{} / {}".format(payload['repository'].get('name'), get_branch_name(payload)) + return "{} / {}".format(payload['repository'].get('name'), get_branch_name(payload)) elif event == 'Pipeline Hook': - return u"{} / {}".format( + return "{} / {}".format( get_repo_name(payload), payload['object_attributes'].get('ref').replace('refs/heads/', '')) elif event.startswith('Merge Request Hook'): diff --git a/zerver/webhooks/gocd/tests.py b/zerver/webhooks/gocd/tests.py index 1f79a7c0a5..0a760ab35f 100644 --- a/zerver/webhooks/gocd/tests.py +++ b/zerver/webhooks/gocd/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -9,11 +8,11 @@ class GocdHookTests(WebhookTestCase): TOPIC = 'https://github.com/gocd/gocd' def test_gocd_message(self) -> None: - expected_message = (u"Author: Balaji B \n" - u"Build status: Passed :thumbs_up:\n" - u"Details: [build log](https://ci.example.com" - u"/go/tab/pipeline/history/pipelineName)\n" - u"Comment: my hola mundo changes") + expected_message = ("Author: Balaji B \n" + "Build status: Passed :thumbs_up:\n" + "Details: [build log](https://ci.example.com" + "/go/tab/pipeline/history/pipelineName)\n" + "Comment: my hola mundo changes") self.send_and_test_stream_message( 'pipeline', @@ -23,11 +22,11 @@ class GocdHookTests(WebhookTestCase): ) def test_failed_message(self) -> None: - expected_message = (u"Author: User Name \n" - u"Build status: Failed :thumbs_down:\n" - u"Details: [build log](https://ci.example.com" - u"/go/tab/pipeline/history/pipelineName)\n" - u"Comment: my hola mundo changes") + expected_message = ("Author: User Name \n" + "Build status: Failed :thumbs_down:\n" + "Details: [build log](https://ci.example.com" + "/go/tab/pipeline/history/pipelineName)\n" + "Comment: my hola mundo changes") self.send_and_test_stream_message( 'pipeline_failed', diff --git a/zerver/webhooks/gocd/view.py b/zerver/webhooks/gocd/view.py index 935b24cd14..f7a7e4a3e7 100644 --- a/zerver/webhooks/gocd/view.py +++ b/zerver/webhooks/gocd/view.py @@ -12,10 +12,10 @@ from zerver.lib.webhooks.common import check_send_webhook_message from zerver.models import UserProfile MESSAGE_TEMPLATE = ( - u'Author: {}\n' - u'Build status: {} {}\n' - u'Details: [build log]({})\n' - u'Comment: {}' + 'Author: {}\n' + 'Build status: {} {}\n' + 'Details: [build log]({})\n' + 'Comment: {}' ) @api_key_only_webhook_view('Gocd') @@ -35,7 +35,7 @@ def api_gocd_webhook(request: HttpRequest, user_profile: UserProfile, build_details_file = os.path.join(os.path.dirname(__file__), 'fixtures/build_details.json') - with open(build_details_file, 'r') as f: + with open(build_details_file) as f: contents = json.load(f) build_link = contents["build_details"]["_links"]["pipeline"]["href"] diff --git a/zerver/webhooks/gogs/tests.py b/zerver/webhooks/gogs/tests.py index 7887ab839a..f3a311bf84 100644 --- a/zerver/webhooks/gogs/tests.py +++ b/zerver/webhooks/gogs/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -11,37 +10,37 @@ class GogsHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'gogs' def test_push(self) -> None: - expected_topic = u"try-git / master" - expected_message = u"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1). + expected_topic = "try-git / master" + expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1). * Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""" self.send_and_test_stream_message('push', expected_topic, expected_message) def test_push_multiple_committers(self) -> None: - commit_info = u'* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' - expected_topic = u"try-git / master" - expected_message = u"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""".format(commit_info) + commit_info = '* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' + expected_topic = "try-git / master" + expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""".format(commit_info) self.send_and_test_stream_message('push__commits_multiple_committers', expected_topic, expected_message) def test_push_multiple_committers_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - commit_info = u'* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' - expected_topic = u"try-git / master" - expected_message = u"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""".format(commit_info) + commit_info = '* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' + expected_topic = "try-git / master" + expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""".format(commit_info) self.send_and_test_stream_message('push__commits_multiple_committers', expected_topic, expected_message) def test_push_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_topic = u"try-git / master" - expected_message = u"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1). + expected_topic = "try-git / master" + expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1). * Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""" self.send_and_test_stream_message('push', expected_topic, expected_message) def test_push_commits_more_than_limits(self) -> None: - expected_topic = u"try-git / master" + expected_topic = "try-git / master" commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n" - expected_message = u"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{}[and {} more commit(s)]".format( + expected_message = "john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 30 - COMMITS_LIMIT ) @@ -49,93 +48,93 @@ class GogsHookTests(WebhookTestCase): def test_push_commits_more_than_limits_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_topic = u"try-git / master" + expected_topic = "try-git / master" commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n" - expected_message = u"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{}[and {} more commit(s)]".format( + expected_message = "john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 30 - COMMITS_LIMIT ) self.send_and_test_stream_message('push__commits_more_than_limits', expected_topic, expected_message) def test_new_branch(self) -> None: - expected_topic = u"try-git / my_feature" - expected_message = u"john created [my_feature](http://localhost:3000/john/try-git/src/my_feature) branch." + expected_topic = "try-git / my_feature" + expected_message = "john created [my_feature](http://localhost:3000/john/try-git/src/my_feature) branch." self.send_and_test_stream_message('create__branch', expected_topic, expected_message) def test_pull_request_opened(self) -> None: - expected_topic = u"try-git / PR #1 Title Text for Pull Request" - expected_message = u"""john opened [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" + expected_topic = "try-git / PR #1 Title Text for Pull Request" + expected_message = """john opened [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) def test_pull_request_opened_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_topic = u"notifications" - expected_message = u"""john opened [PR #1 Title Text for Pull Request](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" + expected_topic = "notifications" + expected_message = """john opened [PR #1 Title Text for Pull Request](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) def test_pull_request_closed(self) -> None: - expected_topic = u"try-git / PR #1 Title Text for Pull Request" - expected_message = u"""john closed [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" + expected_topic = "try-git / PR #1 Title Text for Pull Request" + expected_message = """john closed [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" self.send_and_test_stream_message('pull_request__closed', expected_topic, expected_message) def test_pull_request_merged(self) -> None: - expected_topic = u"try-git / PR #2 Title Text for Pull Request" - expected_message = u"""john merged [PR #2](http://localhost:3000/john/try-git/pulls/2) from `feature` to `master`.""" + expected_topic = "try-git / PR #2 Title Text for Pull Request" + expected_message = """john merged [PR #2](http://localhost:3000/john/try-git/pulls/2) from `feature` to `master`.""" self.send_and_test_stream_message('pull_request__merged', expected_topic, expected_message) def test_pull_request_reopened(self) -> None: - expected_topic = u"test / PR #1349 reopened" - expected_message = u"""kostekIV reopened [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" + expected_topic = "test / PR #1349 reopened" + expected_message = """kostekIV reopened [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" self.send_and_test_stream_message('pull_request__reopened', expected_topic, expected_message) def test_pull_request_edited(self) -> None: - expected_topic = u"test / PR #1349 Test" - expected_message = u"""kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" + expected_topic = "test / PR #1349 Test" + expected_message = """kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" self.send_and_test_stream_message('pull_request__edited', expected_topic, expected_message) def test_pull_request_assigned(self) -> None: - expected_topic = u"test / PR #1349 Test" - expected_message = u"""kostekIV assigned [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" + expected_topic = "test / PR #1349 Test" + expected_message = """kostekIV assigned [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message) def test_pull_request_synchronized(self) -> None: - expected_topic = u"test / PR #1349 Test" - expected_message = u"""kostekIV synchronized [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" + expected_topic = "test / PR #1349 Test" + expected_message = """kostekIV synchronized [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" self.send_and_test_stream_message('pull_request__synchronized', expected_topic, expected_message) def test_issues_opened(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV opened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV opened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~""" self.send_and_test_stream_message('issues__opened', expected_topic, expected_message) def test_issues_reopened(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV reopened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV reopened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~""" self.send_and_test_stream_message('issues__reopened', expected_topic, expected_message) def test_issues_edited(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV edited [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest edit\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV edited [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest edit\n~~~""" self.send_and_test_stream_message('issues__edited', expected_topic, expected_message) def test_issues_assignee(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV assigned [Issue #3](https://try.gogs.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV assigned [Issue #3](https://try.gogs.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest\n~~~""" self.send_and_test_stream_message('issues__assigned', expected_topic, expected_message) def test_issues_closed(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV closed [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nClosed #3\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV closed [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nClosed #3\n~~~""" self.send_and_test_stream_message('issues__closed', expected_topic, expected_message) def test_issue_comment_new(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV [commented](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3635) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest comment\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV [commented](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3635) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest comment\n~~~""" self.send_and_test_stream_message('issue_comment__new', expected_topic, expected_message) def test_issue_comment_edited(self) -> None: - expected_topic = u"test / Issue #3 New test issue" - expected_message = u"""kostekIV edited a [comment](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3634) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit comment\n~~~""" + expected_topic = "test / Issue #3 New test issue" + expected_message = """kostekIV edited a [comment](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3634) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit comment\n~~~""" self.send_and_test_stream_message('issue_comment__edited', expected_topic, expected_message) @patch('zerver.webhooks.gogs.view.check_send_webhook_message') diff --git a/zerver/webhooks/gogs/view.py b/zerver/webhooks/gogs/view.py index edee495a1f..865279ccf6 100644 --- a/zerver/webhooks/gogs/view.py +++ b/zerver/webhooks/gogs/view.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # vim:fenc=utf-8 from typing import Any, Callable, Dict, Optional diff --git a/zerver/webhooks/gosquared/tests.py b/zerver/webhooks/gosquared/tests.py index b290a399e6..1d3e1538ca 100644 --- a/zerver/webhooks/gosquared/tests.py +++ b/zerver/webhooks/gosquared/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase from zerver.webhooks.gosquared.view import CHAT_MESSAGE_TEMPLATE @@ -11,7 +10,7 @@ class GoSquaredHookTests(WebhookTestCase): # Note: Include a test function per each distinct message condition your integration supports def test_traffic_message(self) -> None: expected_topic = "GoSquared - requestb.in" - expected_message = u"[requestb.in](https://www.gosquared.com/now/GSN-595854-T) has 33 visitors online." + expected_message = "[requestb.in](https://www.gosquared.com/now/GSN-595854-T) has 33 visitors online." self.send_and_test_stream_message('traffic_spike', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/greenhouse/tests.py b/zerver/webhooks/greenhouse/tests.py index f648c8e3c5..fb598dd2b0 100644 --- a/zerver/webhooks/greenhouse/tests.py +++ b/zerver/webhooks/greenhouse/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/groove/tests.py b/zerver/webhooks/groove/tests.py index 76e8cd6787..6330ead88a 100644 --- a/zerver/webhooks/groove/tests.py +++ b/zerver/webhooks/groove/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -9,7 +8,7 @@ class GrooveHookTests(WebhookTestCase): # This test simulates the condition when a new ticket comes. def test_groove_ticket_started(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ Test Name submitted new ticket [#9: Test Subject](https://ghostfox.groovehq.com/groove_client/tickets/68659446): @@ -24,7 +23,7 @@ The content of the body goes here. # This simulates the condition when a ticket # is assigned to an agent. def test_groove_ticket_assigned_agent_only(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com." self.send_and_test_stream_message('ticket_assigned__agent_only', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -32,7 +31,7 @@ The content of the body goes here. # This simulates the condition when a ticket # is assigned to an agent in a group. def test_groove_ticket_assigned_agent_and_group(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com from group2." self.send_and_test_stream_message('ticket_assigned__agent_and_group', expected_topic, expected_message, @@ -41,7 +40,7 @@ The content of the body goes here. # This simulates the condition when a ticket # is assigned to a group. def test_groove_ticket_assigned_group_only(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (pending) assigned to group2." self.send_and_test_stream_message('ticket_assigned__group_only', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -57,7 +56,7 @@ The content of the body goes here. # This simulates the notification when an agent replied to a ticket. def test_groove_agent_replied(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ agent@example.com replied to [ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295): @@ -71,7 +70,7 @@ Hello , This is a reply from an agent to a ticket # This simulates the condition when a customer replied to a ticket. def test_groove_customer_replied(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ rambo@example.com replied to [ticket #440](https://ghostfox.groovehq.com/groove_client/tickets/68666538): @@ -85,7 +84,7 @@ Hello agent, thanks for getting back. This is how a reply from customer looks li # This simulates the condition when an agent left a note. def test_groove_note_added(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ anotheragent@example.com left a note on [ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295): diff --git a/zerver/webhooks/harbor/tests.py b/zerver/webhooks/harbor/tests.py index b8175774ff..39366744cd 100644 --- a/zerver/webhooks/harbor/tests.py +++ b/zerver/webhooks/harbor/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class HarborHookTests(WebhookTestCase): STREAM_NAME = "harbor" - URL_TEMPLATE = u"/api/v1/external/harbor?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/harbor?api_key={api_key}&stream={stream}" def test_push_image(self) -> None: expected_topic = "example/test" diff --git a/zerver/webhooks/harbor/view.py b/zerver/webhooks/harbor/view.py index 4dfaa73e71..e096b98a07 100644 --- a/zerver/webhooks/harbor/view.py +++ b/zerver/webhooks/harbor/view.py @@ -43,7 +43,7 @@ def handle_push_image_event(payload: Dict[str, Any], image_name = payload["event_data"]["repository"]["repo_full_name"] image_tag = payload["event_data"]["resources"][0]["tag"] - return u"{author} pushed image `{image_name}:{image_tag}`".format( + return "{author} pushed image `{image_name}:{image_tag}`".format( author=operator_username, image_name=image_name, image_tag=image_tag @@ -68,12 +68,12 @@ Image scan completed for `{image_name}:{image_tag}`. Vulnerabilities by severity def handle_scanning_completed_event(payload: Dict[str, Any], user_profile: UserProfile, operator_username: str) -> str: - scan_results = u"" + scan_results = "" scan_summaries = payload["event_data"]["resources"][0]["scan_overview"]["components"]["summary"] summaries_sorted = sorted( scan_summaries, key=lambda x: x["severity"], reverse=True) for scan_summary in summaries_sorted: - scan_results += u"* {}: **{}**\n".format( + scan_results += "* {}: **{}**\n".format( VULNERABILITY_SEVERITY_NAME_MAP[scan_summary["severity"]], scan_summary["count"]) return SCANNING_COMPLETED_TEMPLATE.format( @@ -94,14 +94,14 @@ EVENT_FUNCTION_MAPPER = { def api_harbor_webhook(request: HttpRequest, user_profile: UserProfile, payload: Dict[str, Any] = REQ(argument_type='body')) -> HttpResponse: - operator_username = u"**{}**".format(payload["operator"]) + operator_username = "**{}**".format(payload["operator"]) if operator_username != "auto": operator_profile = guess_zulip_user_from_harbor( operator_username, user_profile.realm) if operator_profile: - operator_username = u"@**{}**".format(operator_profile.full_name) # nocoverage + operator_username = "@**{}**".format(operator_profile.full_name) # nocoverage event = payload["type"] topic = payload["event_data"]["repository"]["repo_full_name"] diff --git a/zerver/webhooks/hellosign/tests.py b/zerver/webhooks/hellosign/tests.py index 71583f74b3..2cadf71664 100644 --- a/zerver/webhooks/hellosign/tests.py +++ b/zerver/webhooks/hellosign/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase from typing import Dict diff --git a/zerver/webhooks/helloworld/tests.py b/zerver/webhooks/helloworld/tests.py index cd156034b6..523e74242a 100644 --- a/zerver/webhooks/helloworld/tests.py +++ b/zerver/webhooks/helloworld/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from zerver.lib.test_classes import WebhookTestCase @@ -13,16 +12,16 @@ class HelloWorldHookTests(WebhookTestCase): # Note: Include a test function per each distinct message condition your integration supports def test_hello_message(self) -> None: - expected_topic = u"Hello World" - expected_message = u"Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**" + expected_topic = "Hello World" + expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**" # use fixture named helloworld_hello self.send_and_test_stream_message('hello', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_goodbye_message(self) -> None: - expected_topic = u"Hello World" - expected_message = u"Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" + expected_topic = "Hello World" + expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" # use fixture named helloworld_goodbye self.send_and_test_stream_message('goodbye', expected_topic, expected_message, @@ -32,7 +31,7 @@ class HelloWorldHookTests(WebhookTestCase): # Note that this is really just a test for check_send_webhook_message self.URL_TEMPLATE = self.PM_URL_TEMPLATE self.url = self.build_webhook_url() - expected_message = u"Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" + expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" self.send_and_test_private_message('goodbye', expected_message=expected_message, content_type="application/x-www-form-urlencoded") @@ -49,9 +48,9 @@ class HelloWorldHookTests(WebhookTestCase): def test_custom_topic(self) -> None: # Note that this is really just a test for check_send_webhook_message - expected_topic = u"Custom Topic" + expected_topic = "Custom Topic" self.url = self.build_webhook_url(topic=expected_topic) - expected_message = u"Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" + expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" self.send_and_test_stream_message('goodbye', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/heroku/tests.py b/zerver/webhooks/heroku/tests.py index f0fd3c7a32..7afd4f8432 100644 --- a/zerver/webhooks/heroku/tests.py +++ b/zerver/webhooks/heroku/tests.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class HerokuHookTests(WebhookTestCase): STREAM_NAME = 'heroku' - URL_TEMPLATE = u"/api/v1/external/heroku?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/heroku?stream={stream}&api_key={api_key}" def test_deployment(self) -> None: expected_topic = "sample-project" @@ -20,7 +19,7 @@ user@example.com deployed version 3eb5f44 of [sample-project](http://sample-proj def test_deployment_multiple_commits(self) -> None: expected_topic = "sample-project" - expected_message = u"""user@example.com deployed version 3eb5f44 of \ + expected_message = """user@example.com deployed version 3eb5f44 of \ [sample-project](http://sample-project.herokuapp.com) ``` quote * Example User: Test commit for Deploy Hook diff --git a/zerver/webhooks/ifttt/tests.py b/zerver/webhooks/ifttt/tests.py index d1ad701d05..195e1d61a8 100644 --- a/zerver/webhooks/ifttt/tests.py +++ b/zerver/webhooks/ifttt/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,13 +7,13 @@ class IFTTTHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'ifttt' def test_ifttt_when_subject_and_body_are_correct(self) -> None: - expected_topic = u"Email sent from email@email.com" - expected_message = u"Email subject: Subject" + expected_topic = "Email sent from email@email.com" + expected_message = "Email subject: Subject" self.send_and_test_stream_message('correct_subject_and_body', expected_topic, expected_message) def test_ifttt_when_topic_and_body_are_correct(self) -> None: - expected_topic = u"Email sent from email@email.com" - expected_message = u"Email subject: Subject" + expected_topic = "Email sent from email@email.com" + expected_message = "Email subject: Subject" self.send_and_test_stream_message('correct_topic_and_body', expected_topic, expected_message) def test_ifttt_when_topic_is_missing(self) -> None: diff --git a/zerver/webhooks/insping/tests.py b/zerver/webhooks/insping/tests.py index ea2cd20a14..8f1555013d 100644 --- a/zerver/webhooks/insping/tests.py +++ b/zerver/webhooks/insping/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,7 +7,7 @@ class InspingHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'insping' def test_website_state_available_message(self) -> None: - expected_topic = u"insping" + expected_topic = "insping" expected_message = """ State changed to **Available**: * **URL**: http://privisus.zulipdev.org:9991 @@ -21,7 +20,7 @@ State changed to **Available**: content_type="application/x-www-form-urlencoded") def test_website_state_not_responding_message(self) -> None: - expected_topic = u"insping" + expected_topic = "insping" expected_message = """ State changed to **Not Responding**: * **URL**: http://privisus.zulipdev.org:9991 diff --git a/zerver/webhooks/jira/tests.py b/zerver/webhooks/jira/tests.py index 0d1803b902..755fe20b39 100644 --- a/zerver/webhooks/jira/tests.py +++ b/zerver/webhooks/jira/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from urllib.parse import quote, unquote from zerver.lib.test_classes import WebhookTestCase @@ -7,7 +6,7 @@ from zerver.lib.users import get_api_key class JiraHookTests(WebhookTestCase): STREAM_NAME = 'jira' - URL_TEMPLATE = u"/api/v1/external/jira?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/jira?api_key={api_key}&stream={stream}" def test_custom_stream(self) -> None: api_key = get_api_key(self.test_user) @@ -91,7 +90,7 @@ Leo Franchi created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/ self.send_and_test_stream_message('created_v1', expected_topic, expected_message) def test_created_with_unicode(self) -> None: - expected_topic = u"BUG-15: New bug with à hook" + expected_topic = "BUG-15: New bug with à hook" expected_message = """ Leo Franchià created [BUG-15: New bug with à hook](http://lfranchi.com:8080/browse/BUG-15): diff --git a/zerver/webhooks/jira/view.py b/zerver/webhooks/jira/view.py index ed1c44cc4a..192d1c3768 100644 --- a/zerver/webhooks/jira/view.py +++ b/zerver/webhooks/jira/view.py @@ -76,14 +76,14 @@ def convert_jira_markup(content: str, realm: Realm) -> str: # Zulip user mention. We don't know the email, just the JIRA username, # so we naively guess at their Zulip account using this if realm: - mention_re = re.compile(u'\\[~(.*?)\\]') + mention_re = re.compile('\\[~(.*?)\\]') for username in mention_re.findall(content): # Try to look up username user_profile = guess_zulip_user_from_jira(username, realm) if user_profile: - replacement = u"**{}**".format(user_profile.full_name) + replacement = "**{}**".format(user_profile.full_name) else: - replacement = u"**{}**".format(username) + replacement = "**{}**".format(username) content = content.replace("[~{}]".format(username,), replacement) @@ -111,7 +111,7 @@ def get_issue_string(payload: Dict[str, Any], issue_id: Optional[str]=None, with base_url = re.match(r"(.*)\/rest\/api/.*", get_in(payload, ['issue', 'self'])) if base_url and len(base_url.groups()): - return u"[{}]({}/browse/{})".format(text, base_url.group(1), issue_id) + return "[{}]({}/browse/{})".format(text, base_url.group(1), issue_id) else: return text @@ -121,7 +121,7 @@ def get_assignee_mention(assignee_email: str, realm: Realm) -> str: assignee_name = get_user_by_delivery_email(assignee_email, realm).full_name except UserProfile.DoesNotExist: assignee_name = assignee_email - return u"**{}**".format(assignee_name) + return "**{}**".format(assignee_name) return '' def get_issue_author(payload: Dict[str, Any]) -> str: @@ -152,7 +152,7 @@ def get_issue_title(payload: Dict[str, Any]) -> str: return get_in(payload, ['issue', 'fields', 'summary']) def get_issue_subject(payload: Dict[str, Any]) -> str: - return u"{}: {}".format(get_issue_id(payload), get_issue_title(payload)) + return "{}: {}".format(get_issue_id(payload), get_issue_title(payload)) def get_sub_event_for_update_issue(payload: Dict[str, Any]) -> str: sub_event = payload.get('issue_event_type_name', '') @@ -170,11 +170,11 @@ def get_event_type(payload: Dict[str, Any]) -> Optional[str]: return event def add_change_info(content: str, field: str, from_field: str, to_field: str) -> str: - content += u"* Changed {}".format(field) + content += "* Changed {}".format(field) if from_field: - content += u" from **{}**".format(from_field) + content += " from **{}**".format(from_field) if to_field: - content += u" to {}\n".format(to_field) + content += " to {}\n".format(to_field) return content def handle_updated_issue_event(payload: Dict[str, Any], user_profile: UserProfile) -> str: @@ -188,7 +188,7 @@ def handle_updated_issue_event(payload: Dict[str, Any], user_profile: UserProfil assignee_mention = get_assignee_mention(assignee_email, user_profile.realm) if assignee_mention != '': - assignee_blurb = u" (assigned to {})".format(assignee_mention) + assignee_blurb = " (assigned to {})".format(assignee_mention) else: assignee_blurb = '' @@ -206,15 +206,15 @@ def handle_updated_issue_event(payload: Dict[str, Any], user_profile: UserProfil else: author = get_issue_author(payload) - content = u"{} {} {}{}".format(author, verb, issue, assignee_blurb) + content = "{} {} {}{}".format(author, verb, issue, assignee_blurb) comment = get_in(payload, ['comment', 'body']) if comment: comment = convert_jira_markup(comment, user_profile.realm) - content = u"{}:\n\n``` quote\n{}\n```".format(content, comment) + content = "{}:\n\n``` quote\n{}\n```".format(content, comment) else: content = "{}.".format(content) else: - content = u"{} updated {}{}:\n\n".format(get_issue_author(payload), issue, assignee_blurb) + content = "{} updated {}{}:\n\n".format(get_issue_author(payload), issue, assignee_blurb) changelog = get_in(payload, ['changelog']) if changelog != '': @@ -227,7 +227,7 @@ def handle_updated_issue_event(payload: Dict[str, Any], user_profile: UserProfil target_field_string = assignee_mention else: # Convert a user's target to a @-mention if possible - target_field_string = u"**{}**".format(item.get('toString')) + target_field_string = "**{}**".format(item.get('toString')) from_field_string = item.get('fromString') if target_field_string or from_field_string: @@ -235,7 +235,7 @@ def handle_updated_issue_event(payload: Dict[str, Any], user_profile: UserProfil elif sub_event == 'issue_transited': from_field_string = get_in(payload, ['transition', 'from_status']) - target_field_string = u'**{}**'.format(get_in(payload, ['transition', 'to_status'])) + target_field_string = '**{}**'.format(get_in(payload, ['transition', 'to_status'])) if target_field_string or from_field_string: content = add_change_info(content, 'status', from_field_string, target_field_string) diff --git a/zerver/webhooks/librato/tests.py b/zerver/webhooks/librato/tests.py index 9ca4dc5aaf..e5e64a7519 100644 --- a/zerver/webhooks/librato/tests.py +++ b/zerver/webhooks/librato/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import urllib from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class LibratoHookTests(WebhookTestCase): STREAM_NAME = 'librato' - URL_TEMPLATE = u"/api/v1/external/librato?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/librato?api_key={api_key}&stream={stream}" FIXTURE_DIR_NAME = 'librato' IS_ATTACHMENT = False diff --git a/zerver/webhooks/librato/view.py b/zerver/webhooks/librato/view.py index 877c65ee4a..4c299e30e9 100644 --- a/zerver/webhooks/librato/view.py +++ b/zerver/webhooks/librato/view.py @@ -98,23 +98,23 @@ class LibratoWebhookHandler(LibratoWebhookParser): return content def handle_snapshots(self) -> str: - content = u'' + content = '' for attachment in self.attachments: content += self.handle_snapshot(attachment) return content def handle_snapshot(self, snapshot: Dict[str, Any]) -> str: - snapshot_template = u"**{author_name}** sent a [snapshot]({image_url}) of [metric]({title})." + snapshot_template = "**{author_name}** sent a [snapshot]({image_url}) of [metric]({title})." author_name, image_url, title = self.parse_snapshot(snapshot) content = snapshot_template.format(author_name=author_name, image_url=image_url, title=title) return content def handle_alert_violation_message(self) -> str: - alert_violation_template = u"Alert [alert_name]({alert_url}) has triggered! " + alert_violation_template = "Alert [alert_name]({alert_url}) has triggered! " alert_id, alert_name, alert_url, alert_runbook_url = self.parse_alert() content = alert_violation_template.format(alert_name=alert_name, alert_url=alert_url) if alert_runbook_url: - alert_runbook_template = u"[Reaction steps]({alert_runbook_url}):" + alert_runbook_template = "[Reaction steps]({alert_runbook_url}):" content += alert_runbook_template.format(alert_runbook_url=alert_runbook_url) content += self.generate_conditions_and_violations() return content @@ -122,7 +122,7 @@ class LibratoWebhookHandler(LibratoWebhookParser): def generate_conditions_and_violations(self) -> str: conditions = self.parse_conditions() violations = self.parse_violations() - content = u"" + content = "" for condition, violation in zip(conditions, violations): content += self.generate_violated_metric_condition(violation, condition) return content @@ -131,14 +131,14 @@ class LibratoWebhookHandler(LibratoWebhookParser): condition: Dict[str, Any]) -> str: summary_function, threshold, condition_type, duration = self.parse_condition(condition) metric_name, recorded_at = self.parse_violation(violation) - metric_condition_template = (u"\n * Metric `{metric_name}`, {summary_function} " + metric_condition_template = ("\n * Metric `{metric_name}`, {summary_function} " "was {condition_type} {threshold}") content = metric_condition_template.format( metric_name=metric_name, summary_function=summary_function, condition_type=condition_type, threshold=threshold) if duration: - content += u" by {duration}s".format(duration=duration) - content += u", recorded at {recorded_at} UTC.".format(recorded_at=recorded_at) + content += " by {duration}s".format(duration=duration) + content += ", recorded at {recorded_at} UTC.".format(recorded_at=recorded_at) return content @api_key_only_webhook_view('Librato') diff --git a/zerver/webhooks/mention/tests.py b/zerver/webhooks/mention/tests.py index b90dbb3364..a83e42bdf8 100644 --- a/zerver/webhooks/mention/tests.py +++ b/zerver/webhooks/mention/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,7 +7,7 @@ class MentionHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'mention' def test_mention_webfeed(self) -> None: - expected_topic = u"news" + expected_topic = "news" expected_message = """ **[Historical Sexual Abuse (Football): 29 Nov 2016: House of Commons debates - TheyWorkForYou](https://www.theyworkforyou.com/debates/?id=2016-11-29b.1398.7&p=24887)**: diff --git a/zerver/webhooks/netlify/tests.py b/zerver/webhooks/netlify/tests.py index 95d4217891..0a0311eb9c 100644 --- a/zerver/webhooks/netlify/tests.py +++ b/zerver/webhooks/netlify/tests.py @@ -1,48 +1,47 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class NetlifyHookTests(WebhookTestCase): STREAM_NAME = 'netlify' - URL_TEMPLATE = u"/api/v1/external/netlify?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/netlify?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = "netlify" def test_building_message(self) -> None: - expected_topic = u"master" - expected_message = u'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now building.' + expected_topic = "master" + expected_message = 'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now building.' self.send_and_test_stream_message('deploy_building', expected_topic, expected_message, content_type="application/json") def test_created_message(self) -> None: - expected_topic = u"master" - expected_message = u'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now ready.' + expected_topic = "master" + expected_message = 'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now ready.' self.send_and_test_stream_message('deploy_created', expected_topic, expected_message, content_type="application/json") def test_failed_message(self) -> None: - expected_topic = u"master" - expected_message = (u"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " - u"on branch master failed during stage 'building site': Build script returned non-zero exit code: 127" + expected_topic = "master" + expected_message = ("The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " + "on branch master failed during stage 'building site': Build script returned non-zero exit code: 127" ) self.send_and_test_stream_message('deploy_failed', expected_topic, expected_message, content_type="application/json") def test_locked_message(self) -> None: - expected_topic = u"master" - expected_message = (u"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " - u"on branch master is now locked." + expected_topic = "master" + expected_message = ("The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " + "on branch master is now locked." ) self.send_and_test_stream_message('deploy_locked', expected_topic, expected_message, content_type="application/json") def test_unlocked_message(self) -> None: - expected_topic = u"master" - expected_message = (u"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " - u"on branch master is now unlocked." + expected_topic = "master" + expected_message = ("The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " + "on branch master is now unlocked." ) self.send_and_test_stream_message('deploy_unlocked', expected_topic, expected_message, diff --git a/zerver/webhooks/netlify/view.py b/zerver/webhooks/netlify/view.py index 607c528d5a..57e2bf55dd 100644 --- a/zerver/webhooks/netlify/view.py +++ b/zerver/webhooks/netlify/view.py @@ -36,7 +36,7 @@ def api_netlify_webhook( def get_template(request: HttpRequest, payload: Dict[str, Any]) -> str: - message_template = u'The build [{build_name}]({build_url}) on branch {branch_name} ' + message_template = 'The build [{build_name}]({build_url}) on branch {branch_name} ' event = validate_extract_webhook_http_header(request, 'X_NETLIFY_EVENT', 'Netlify') if event == 'deploy_failed': diff --git a/zerver/webhooks/newrelic/tests.py b/zerver/webhooks/newrelic/tests.py index 6e7595b11d..887b00268a 100644 --- a/zerver/webhooks/newrelic/tests.py +++ b/zerver/webhooks/newrelic/tests.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class NewRelicHookTests(WebhookTestCase): STREAM_NAME = 'newrelic' - URL_TEMPLATE = u"/api/v1/external/newrelic?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/newrelic?stream={stream}&api_key={api_key}" def test_alert(self) -> None: expected_topic = "Apdex score fell below critical level of 0.90" diff --git a/zerver/webhooks/opbeat/tests.py b/zerver/webhooks/opbeat/tests.py index 2e899aa112..25eb674d63 100644 --- a/zerver/webhooks/opbeat/tests.py +++ b/zerver/webhooks/opbeat/tests.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase from zerver.webhooks.opbeat.view import get_value class OpbeatHookTests(WebhookTestCase): STREAM_NAME = 'opbeat' - URL_TEMPLATE = u"/api/v1/external/opbeat?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/opbeat?api_key={api_key}&stream={stream}" FIXTURE_DIR_NAME = 'opbeat' def test_comment(self) -> None: diff --git a/zerver/webhooks/opsgenie/tests.py b/zerver/webhooks/opsgenie/tests.py index a2da91856a..875f380418 100644 --- a/zerver/webhooks/opsgenie/tests.py +++ b/zerver/webhooks/opsgenie/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,7 +7,7 @@ class OpsGenieHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'opsgenie' def test_acknowledge_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: Acknowledge @@ -20,7 +19,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_addnote_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: AddNote @@ -33,7 +32,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_addrecipient_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: AddRecipient @@ -46,7 +45,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_addtags_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: AddTags @@ -59,7 +58,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_addteam_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: AddTeam @@ -72,7 +71,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_assignownership_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: AssignOwnership @@ -85,7 +84,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_close_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: Close @@ -96,7 +95,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_create_alert(self) -> None: - expected_topic = u"Webhook" + expected_topic = "Webhook" expected_message = """ [OpsGenie Alert for Webhook](https://app.opsgenie.com/alert/V2#/show/ec03dad6-62c8-4c94-b38b-d88f398e900f): * **Type**: Create @@ -108,7 +107,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_customaction_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: TestAction @@ -120,7 +119,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_delete_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: Delete @@ -131,7 +130,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_escalate_alert(self) -> None: - expected_topic = u"Webhook_Test" + expected_topic = "Webhook_Test" expected_message = """ [OpsGenie Alert for Webhook_Test](https://app.opsgenie.com/alert/V2#/show/7ba97e3a-d328-4b5e-8f9a-39e945a3869a): * **Type**: Escalate @@ -142,7 +141,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_removetags_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: RemoveTags @@ -155,7 +154,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_takeownership_alert(self) -> None: - expected_topic = u"Webhook" + expected_topic = "Webhook" expected_message = """ [OpsGenie Alert for Webhook](https://app.opsgenie.com/alert/V2#/show/8a745a79-3ed3-4044-8427-98e067c0623c): * **Type**: TakeOwnership @@ -167,7 +166,7 @@ class OpsGenieHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_unacknowledge_alert(self) -> None: - expected_topic = u"Integration1" + expected_topic = "Integration1" expected_message = """ [OpsGenie Alert for Integration1](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c): * **Type**: UnAcknowledge diff --git a/zerver/webhooks/pagerduty/tests.py b/zerver/webhooks/pagerduty/tests.py index c59517e53d..a1c0a3c19b 100644 --- a/zerver/webhooks/pagerduty/tests.py +++ b/zerver/webhooks/pagerduty/tests.py @@ -1,31 +1,30 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class PagerDutyHookTests(WebhookTestCase): STREAM_NAME = 'pagerduty' - URL_TEMPLATE = u"/api/v1/external/pagerduty?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/pagerduty?api_key={api_key}&stream={stream}" FIXTURE_DIR_NAME = 'pagerduty' def test_trigger(self) -> None: expected_message = 'Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) triggered by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)):\n\n``` quote\nfoo\n```' - self.send_and_test_stream_message('trigger', u"Incident 3", expected_message) + self.send_and_test_stream_message('trigger', "Incident 3", expected_message) def test_trigger_v2(self) -> None: expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)):\n\n``` quote\nMy new incident\n```' - self.send_and_test_stream_message('trigger_v2', u'Incident 33', expected_message) + self.send_and_test_stream_message('trigger_v2', 'Incident 33', expected_message) def test_trigger_without_assignee_v2(self) -> None: expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to nobody):\n\n``` quote\nMy new incident\n```' - self.send_and_test_stream_message('trigger_without_assignee_v2', u'Incident 33', expected_message) + self.send_and_test_stream_message('trigger_without_assignee_v2', 'Incident 33', expected_message) def test_unacknowledge(self) -> None: expected_message = 'Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) unacknowledged by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)):\n\n``` quote\nfoo\n```' - self.send_and_test_stream_message('unacknowledge', u"Incident 3", expected_message) + self.send_and_test_stream_message('unacknowledge', "Incident 3", expected_message) def test_resolved(self) -> None: expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) resolved by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\nIt is on fire\n```' - self.send_and_test_stream_message('resolved', u"Incident 1", expected_message) + self.send_and_test_stream_message('resolved', "Incident 1", expected_message) def test_resolved_v2(self) -> None: expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) resolved by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV):\n\n``` quote\nMy new incident\n```' @@ -33,16 +32,16 @@ class PagerDutyHookTests(WebhookTestCase): def test_auto_resolved(self) -> None: expected_message = 'Incident [2](https://zulip-test.pagerduty.com/incidents/PX7K9J2) resolved:\n\n``` quote\nnew\n```' - self.send_and_test_stream_message('auto_resolved', u"Incident 2", expected_message) + self.send_and_test_stream_message('auto_resolved', "Incident 2", expected_message) def test_acknowledge(self) -> None: expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) acknowledged by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\nIt is on fire\n```' - self.send_and_test_stream_message('acknowledge', u"Incident 1", expected_message) + self.send_and_test_stream_message('acknowledge', "Incident 1", expected_message) def test_acknowledge_without_trigger_summary_data(self) -> None: expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) acknowledged by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\n\n```' self.send_and_test_stream_message('acknowledge_without_trigger_summary_data', - u"Incident 1", expected_message) + "Incident 1", expected_message) def test_acknowledge_v2(self) -> None: expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) acknowledged by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV):\n\n``` quote\nMy new incident\n```' @@ -53,5 +52,5 @@ class PagerDutyHookTests(WebhookTestCase): self.send_and_test_stream_message('assign_v2', 'Incident 33', expected_message) def test_no_subject(self) -> None: - expected_message = u'Incident [48219](https://dropbox.pagerduty.com/incidents/PJKGZF9) resolved:\n\n``` quote\nmp_error_block_down_critical\u2119\u01b4\n```' - self.send_and_test_stream_message('mp_fail', u"Incident 48219", expected_message) + expected_message = 'Incident [48219](https://dropbox.pagerduty.com/incidents/PJKGZF9) resolved:\n\n``` quote\nmp_error_block_down_critical\u2119\u01b4\n```' + self.send_and_test_stream_message('mp_fail', "Incident 48219", expected_message) diff --git a/zerver/webhooks/pagerduty/view.py b/zerver/webhooks/pagerduty/view.py index 5b56603f92..a51b5c7d83 100644 --- a/zerver/webhooks/pagerduty/view.py +++ b/zerver/webhooks/pagerduty/view.py @@ -104,7 +104,7 @@ def build_pagerduty_formatdict(message: Dict[str, Any]) -> Dict[str, Any]: if trigger_description: trigger_message.append(trigger_description) - format_dict['trigger_message'] = u'\n'.join(trigger_message) + format_dict['trigger_message'] = '\n'.join(trigger_message) return format_dict def build_pagerduty_formatdict_v2(message: Dict[str, Any]) -> Dict[str, Any]: @@ -153,7 +153,7 @@ def send_formated_pagerduty(request: HttpRequest, else: template = INCIDENT_WITH_ASSIGNEE - subject = u'Incident {incident_num}'.format(**format_dict) + subject = 'Incident {incident_num}'.format(**format_dict) body = template.format(**format_dict) check_send_webhook_message(request, user_profile, subject, body) diff --git a/zerver/webhooks/papertrail/tests.py b/zerver/webhooks/papertrail/tests.py index 8b383970fb..51806353f3 100644 --- a/zerver/webhooks/papertrail/tests.py +++ b/zerver/webhooks/papertrail/tests.py @@ -9,7 +9,7 @@ class PapertrailHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'papertrail' def test_short_message(self) -> None: - expected_topic = u"logs" + expected_topic = "logs" expected_message = """ [Search for "Important stuff"](https://papertrailapp.com/searches/42) found **2** matches: @@ -27,7 +27,7 @@ A short event content_type="application/x-www-form-urlencoded") def test_long_message(self) -> None: - expected_topic = u"logs" + expected_topic = "logs" expected_message = """ [Search for "Important stuff"](https://papertrailapp.com/searches/42) found **5** matches: diff --git a/zerver/webhooks/pingdom/tests.py b/zerver/webhooks/pingdom/tests.py index 8c70dff690..c9e710d0c9 100644 --- a/zerver/webhooks/pingdom/tests.py +++ b/zerver/webhooks/pingdom/tests.py @@ -1,36 +1,35 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class PingdomHookTests(WebhookTestCase): STREAM_NAME = 'pingdom' - URL_TEMPLATE = u"/api/v1/external/pingdom?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/pingdom?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'pingdom' def test_pingdom_from_up_to_down_http_check_message(self) -> None: """ Tests if pingdom http check from up to down is handled correctly """ - expected_message = u"Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```" - self.send_and_test_stream_message('http_up_to_down', u"Test check status.", expected_message) + expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```" + self.send_and_test_stream_message('http_up_to_down', "Test check status.", expected_message) def test_pingdom_from_up_to_down_smtp_check_message(self) -> None: """ Tests if pingdom smtp check from up to down is handled correctly """ - expected_message = u"Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```" - self.send_and_test_stream_message('smtp_up_to_down', u"SMTP check status.", expected_message) + expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```" + self.send_and_test_stream_message('smtp_up_to_down', "SMTP check status.", expected_message) def test_pingdom_from_up_to_down_imap_check_message(self) -> None: """ Tests if pingdom imap check from up to down is handled correctly """ - expected_message = u"Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```" - self.send_and_test_stream_message('imap_up_to_down', u"IMAP check status.", expected_message) + expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```" + self.send_and_test_stream_message('imap_up_to_down', "IMAP check status.", expected_message) def test_pingdom_from_down_to_up_imap_check_message(self) -> None: """ Tests if pingdom imap check from down to up is handled correctly """ - expected_message = u"Service imap.someurl.com changed its IMAP status from DOWN to UP." - self.send_and_test_stream_message('imap_down_to_up', u"IMAP check status.", expected_message) + expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP." + self.send_and_test_stream_message('imap_down_to_up', "IMAP check status.", expected_message) diff --git a/zerver/webhooks/pivotal/tests.py b/zerver/webhooks/pivotal/tests.py index 79f1cb5327..d0fc806978 100644 --- a/zerver/webhooks/pivotal/tests.py +++ b/zerver/webhooks/pivotal/tests.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class PivotalV3HookTests(WebhookTestCase): STREAM_NAME = 'pivotal' - URL_TEMPLATE = u"/api/v1/external/pivotal?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/pivotal?stream={stream}&api_key={api_key}" def test_accepted(self) -> None: expected_topic = 'My new Feature story' @@ -73,7 +72,7 @@ class PivotalV3HookTests(WebhookTestCase): class PivotalV5HookTests(WebhookTestCase): STREAM_NAME = 'pivotal' - URL_TEMPLATE = u"/api/v1/external/pivotal?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/pivotal?stream={stream}&api_key={api_key}" def test_accepted(self) -> None: expected_topic = '#63486316: Story of the Year' diff --git a/zerver/webhooks/raygun/tests.py b/zerver/webhooks/raygun/tests.py index 154a8e519c..5ca25fea11 100644 --- a/zerver/webhooks/raygun/tests.py +++ b/zerver/webhooks/raygun/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,7 +7,7 @@ class RaygunHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'raygun' def test_status_changed_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ [Error](https://app.raygun.com/error-url) status changed to **Ignored** by Emma Cat: * **Timestamp**: Wed Jan 28 01:49:36 1970 @@ -22,7 +21,7 @@ class RaygunHookTests(WebhookTestCase): "application/x-www-form-urlencoded") def test_comment_added_to_error_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ Anita Peacock commented on [Error](https://app.raygun.com/error-url): @@ -40,7 +39,7 @@ Ignoring these errors "application/x-www-form-urlencoded") def test_error_assigned_to_user_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ Amy Loondon assigned [Error](https://app.raygun.com/error-url) to Kyle Kenny: * **Timestamp**: Wed Jan 28 01:49:36 1970 @@ -54,7 +53,7 @@ Amy Loondon assigned [Error](https://app.raygun.com/error-url) to Kyle Kenny: "application/x-www-form-urlencoded") def test_one_minute_followup_error_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ One minute [follow-up error](http://app.raygun.io/error-url): * **First occurred**: Wed Jan 28 01:49:36 1970 @@ -70,7 +69,7 @@ One minute [follow-up error](http://app.raygun.io/error-url): "application/x-www-form-urlencoded") def test_hourly_followup_error_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ Hourly [follow-up error](http://app.raygun.io/error-url): * **First occurred**: Wed Jan 28 01:49:36 1970 @@ -86,7 +85,7 @@ Hourly [follow-up error](http://app.raygun.io/error-url): "application/x-www-form-urlencoded") def test_new_error_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ New [Error](http://app.raygun.io/error-url) occurred: * **First occurred**: Wed Jan 28 01:49:36 1970 @@ -106,7 +105,7 @@ New [Error](http://app.raygun.io/error-url) occurred: "application/x-www-form-urlencoded") def test_reoccurred_error_message(self) -> None: - expected_topic = u"test" + expected_topic = "test" expected_message = """ [Error](http://app.raygun.io/error-url) reoccurred: * **First occurred**: Wed Jan 28 01:49:36 1970 diff --git a/zerver/webhooks/reviewboard/tests.py b/zerver/webhooks/reviewboard/tests.py index 944de27343..039820c96a 100644 --- a/zerver/webhooks/reviewboard/tests.py +++ b/zerver/webhooks/reviewboard/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase diff --git a/zerver/webhooks/semaphore/tests.py b/zerver/webhooks/semaphore/tests.py index a13da70e86..616441bca6 100644 --- a/zerver/webhooks/semaphore/tests.py +++ b/zerver/webhooks/semaphore/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import ujson from mock import patch from zerver.lib.test_classes import WebhookTestCase @@ -14,7 +13,7 @@ class SemaphoreHookTests(WebhookTestCase): # Tests for Semaphore Classic def test_semaphore_build(self) -> None: - expected_topic = u"knighthood/master" # repo/branch + expected_topic = "knighthood/master" # repo/branch expected_message = """ [Build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314) passed: * **Commit**: [a490b8d: Create user account for Rocinante](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf) @@ -24,7 +23,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_semaphore_deploy(self) -> None: - expected_topic = u"knighthood/master" + expected_topic = "knighthood/master" expected_message = """ [Deploy 17](https://semaphoreci.com/donquixote/knighthood/servers/lamancha-271/deploys/17) of [build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314) passed: * **Commit**: [a490b8d: Create user account for Rocinante](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf) @@ -37,7 +36,7 @@ class SemaphoreHookTests(WebhookTestCase): # Tests For Semaphore 2.0 def test_semaphore2_push(self) -> None: - expected_topic = u"notifications/rw/webhook_impl" # repo/branch + expected_topic = "notifications/rw/webhook_impl" # repo/branch expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/acabe58e-4bcc-4d39-be06-e98d71917703) pipeline **stopped**: * **Commit**: [(2d9f5fc)](https://github.com/renderedtext/notifications/commit/2d9f5fcec1ca7c68fa7bd44dd58ec4ff65814563) Implement webhooks for SemaphoreCI @@ -48,7 +47,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/json") def test_semaphore2_push_non_gh_repo(self) -> None: - expected_topic = u"notifications/rw/webhook_impl" # repo/branch + expected_topic = "notifications/rw/webhook_impl" # repo/branch expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/acabe58e-4bcc-4d39-be06-e98d71917703) pipeline **stopped**: * **Commit**: (2d9f5fc) Implement webhooks for SemaphoreCI @@ -60,7 +59,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/json") def test_semaphore_pull_request(self) -> None: - expected_topic = u"notifications/test-notifications" + expected_topic = "notifications/test-notifications" expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/84383f37-d025-4811-b719-61c6acc92a1e) pipeline **failed**: * **Pull Request**: [Testing PR notifications](https://github.com/renderedtext/notifications/pull/3) @@ -71,7 +70,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/json") def test_semaphore_pull_request_non_gh_repo(self) -> None: - expected_topic = u"notifications/test-notifications" + expected_topic = "notifications/test-notifications" expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/84383f37-d025-4811-b719-61c6acc92a1e) pipeline **failed**: * **Pull Request**: Testing PR notifications (#3) @@ -83,7 +82,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/json") def test_semaphore_tag(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/a8704319-2422-4828-9b11-6b2afa3554e6) pipeline **stopped**: * **Tag**: [v1.0.1](https://github.com/renderedtext/notifications/tree/v1.0.1) @@ -93,7 +92,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/json") def test_semaphore_tag_non_gh_repo(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/a8704319-2422-4828-9b11-6b2afa3554e6) pipeline **stopped**: * **Tag**: v1.0.1 @@ -104,7 +103,7 @@ class SemaphoreHookTests(WebhookTestCase): content_type="application/json") def test_semaphore_unknown_event(self) -> None: - expected_topic = u"notifications" + expected_topic = "notifications" expected_message = """ [Notifications](https://semaphore.semaphoreci.com/workflows/a8704319-2422-4828-9b11-6b2afa3554e6) pipeline **stopped** for unknown event """.strip() diff --git a/zerver/webhooks/sentry/tests.py b/zerver/webhooks/sentry/tests.py index d4cdc2da75..eeee48f80b 100644 --- a/zerver/webhooks/sentry/tests.py +++ b/zerver/webhooks/sentry/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,7 +7,7 @@ class SentryHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'sentry' def test_error_issue_message(self) -> None: - expected_topic = u"zulip" + expected_topic = "zulip" expected_message = """ New [issue](https://sentry.io/zulip/zulip/issues/156699934/) (level: ERROR): diff --git a/zerver/webhooks/slack/tests.py b/zerver/webhooks/slack/tests.py index ef948159c5..26950f45bc 100644 --- a/zerver/webhooks/slack/tests.py +++ b/zerver/webhooks/slack/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -9,8 +8,8 @@ class SlackWebhookTests(WebhookTestCase): def test_slack_channel_to_topic(self) -> None: - expected_topic = u"channel: general" - expected_message = u"**slack_user**: `test\n`" + expected_topic = "channel: general" + expected_message = "**slack_user**: `test\n`" self.send_and_test_stream_message('message_info', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -18,8 +17,8 @@ class SlackWebhookTests(WebhookTestCase): self.STREAM_NAME = 'general' self.url = "{}{}".format(self.url, "&channels_map_to_topics=0") - expected_topic = u"Message from Slack" - expected_message = u"**slack_user**: `test\n`" + expected_topic = "Message from Slack" + expected_message = "**slack_user**: `test\n`" self.send_and_test_stream_message('message_info', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/slack/view.py b/zerver/webhooks/slack/view.py index b0e8636f77..63fd857a8b 100644 --- a/zerver/webhooks/slack/view.py +++ b/zerver/webhooks/slack/view.py @@ -7,7 +7,7 @@ from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_error, json_success from zerver.models import UserProfile -ZULIP_MESSAGE_TEMPLATE = u"**{message_sender}**: `{text}`" +ZULIP_MESSAGE_TEMPLATE = "**{message_sender}**: `{text}`" VALID_OPTIONS = {'SHOULD_NOT_BE_MAPPED': '0', 'SHOULD_BE_MAPPED': '1'} @api_key_only_webhook_view('Slack', notify_bot_owner_on_invalid_json=False) diff --git a/zerver/webhooks/solano/tests.py b/zerver/webhooks/solano/tests.py index 906847c77b..09b6e6b03e 100644 --- a/zerver/webhooks/solano/tests.py +++ b/zerver/webhooks/solano/tests.py @@ -1,17 +1,16 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class SolanoHookTests(WebhookTestCase): STREAM_NAME = 'solano labs' - URL_TEMPLATE = u"/api/v1/external/solano?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/solano?api_key={api_key}&stream={stream}" FIXTURE_DIR_NAME = 'solano' def test_solano_message_001(self) -> None: """ Build notifications are generated by Solano Labs after build completes. """ - expected_topic = u'build update' + expected_topic = 'build update' expected_message = """ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316175)): * **Author**: solano-ci[bot]@users.noreply.github.com @@ -26,7 +25,7 @@ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316175)): """ Build notifications are generated by Solano Labs after build completes. """ - expected_topic = u'build update' + expected_topic = 'build update' expected_message = """ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316723)): * **Author**: Unknown @@ -41,7 +40,7 @@ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316723)): """ Build notifications are generated by Solano Labs after build completes. """ - expected_topic = u'build update' + expected_topic = 'build update' expected_message = """ Build update (see [build log](https://ci.solanolabs.com:443/reports/3317799)): * **Author**: solano-ci[bot]@users.noreply.github.com @@ -53,7 +52,7 @@ Build update (see [build log](https://ci.solanolabs.com:443/reports/3317799)): content_type="application/x-www-form-urlencoded") def test_solano_test_message(self) -> None: - expected_topic = u'build update' + expected_topic = 'build update' expected_message = "Solano webhook set up correctly." self.send_and_test_stream_message('test', expected_topic, expected_message, diff --git a/zerver/webhooks/splunk/tests.py b/zerver/webhooks/splunk/tests.py index b28bbc5d1f..9ca5cd9e0b 100644 --- a/zerver/webhooks/splunk/tests.py +++ b/zerver/webhooks/splunk/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -9,10 +8,10 @@ class SplunkHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'splunk' def test_splunk_search_one_result(self) -> None: - self.url = self.build_webhook_url(topic=u"New Search Alert") + self.url = self.build_webhook_url(topic="New Search Alert") # define the expected message contents - expected_topic = u"New Search Alert" + expected_topic = "New Search Alert" expected_message = """ Splunk alert from saved search: * **Search**: [sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) @@ -30,7 +29,7 @@ Splunk alert from saved search: def test_splunk_short_search_name(self) -> None: # don't provide a topic so the search name is used instead - expected_topic = u"This search's name isn't that long" + expected_topic = "This search's name isn't that long" expected_message = """ Splunk alert from saved search: * **Search**: [This search's name isn't that long](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) @@ -47,7 +46,7 @@ Splunk alert from saved search: def test_splunk_long_search_name(self) -> None: # don't provide a topic so the search name is used instead - expected_topic = u"this-search's-got-47-words-37-sentences-58-words-we-wanna..." + expected_topic = "this-search's-got-47-words-37-sentences-58-words-we-wanna..." expected_message = """ Splunk alert from saved search: * **Search**: [this-search's-got-47-words-37-sentences-58-words-we-wanna-know-details-of-the-search-time-of-the-search-and-any-other-kind-of-thing-you-gotta-say-pertaining-to-and-about-the-search-I-want-to-know-authenticated-user's-name-and-any-other-kind-of-thing-you-gotta-say](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) @@ -63,9 +62,9 @@ Splunk alert from saved search: def test_splunk_missing_results_link(self) -> None: - self.url = self.build_webhook_url(topic=u"New Search Alert") + self.url = self.build_webhook_url(topic="New Search Alert") - expected_topic = u"New Search Alert" + expected_topic = "New Search Alert" expected_message = """ Splunk alert from saved search: * **Search**: [sudo](Missing results_link) @@ -81,9 +80,9 @@ Splunk alert from saved search: def test_splunk_missing_search_name(self) -> None: - self.url = self.build_webhook_url(topic=u"New Search Alert") + self.url = self.build_webhook_url(topic="New Search Alert") - expected_topic = u"New Search Alert" + expected_topic = "New Search Alert" expected_message = """ Splunk alert from saved search: * **Search**: [Missing search_name](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) @@ -99,9 +98,9 @@ Splunk alert from saved search: def test_splunk_missing_host(self) -> None: - self.url = self.build_webhook_url(topic=u"New Search Alert") + self.url = self.build_webhook_url(topic="New Search Alert") - expected_topic = u"New Search Alert" + expected_topic = "New Search Alert" expected_message = """ Splunk alert from saved search: * **Search**: [sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) @@ -117,9 +116,9 @@ Splunk alert from saved search: def test_splunk_missing_source(self) -> None: - self.url = self.build_webhook_url(topic=u"New Search Alert") + self.url = self.build_webhook_url(topic="New Search Alert") - expected_topic = u"New Search Alert" + expected_topic = "New Search Alert" expected_message = """ Splunk alert from saved search: * **Search**: [sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) @@ -135,9 +134,9 @@ Splunk alert from saved search: def test_splunk_missing_raw(self) -> None: - self.url = self.build_webhook_url(topic=u"New Search Alert") + self.url = self.build_webhook_url(topic="New Search Alert") - expected_topic = u"New Search Alert" + expected_topic = "New Search Alert" expected_message = """ Splunk alert from saved search: * **Search**: [sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now) diff --git a/zerver/webhooks/statuspage/tests.py b/zerver/webhooks/statuspage/tests.py index d5ff11c66e..daa53f6064 100644 --- a/zerver/webhooks/statuspage/tests.py +++ b/zerver/webhooks/statuspage/tests.py @@ -1,13 +1,12 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class StatuspageHookTests(WebhookTestCase): STREAM_NAME = 'statuspage-test' - URL_TEMPLATE = u"/api/v1/external/statuspage?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/statuspage?api_key={api_key}&stream={stream}" def test_statuspage_incident(self) -> None: - expected_topic = u"Database query delays: All Systems Operational" + expected_topic = "Database query delays: All Systems Operational" expected_message = """ **Database query delays**: * State: **identified** @@ -19,7 +18,7 @@ class StatuspageHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_statuspage_incident_update(self) -> None: - expected_topic = u"Database query delays: All Systems Operational" + expected_topic = "Database query delays: All Systems Operational" expected_message = """ **Database query delays**: * State: **resolved** @@ -31,8 +30,8 @@ class StatuspageHookTests(WebhookTestCase): content_type="application/x-www-form-urlencoded") def test_statuspage_component(self) -> None: - expected_topic = u"Database component: Service Under Maintenance" - expected_message = u"**Database component** has changed status from **operational** to **under_maintenance**." + expected_topic = "Database component: Service Under Maintenance" + expected_message = "**Database component** has changed status from **operational** to **under_maintenance**." self.send_and_test_stream_message('component_status_update', expected_topic, expected_message, diff --git a/zerver/webhooks/statuspage/view.py b/zerver/webhooks/statuspage/view.py index 30f0a005a1..e5fa6b3f3b 100644 --- a/zerver/webhooks/statuspage/view.py +++ b/zerver/webhooks/statuspage/view.py @@ -17,7 +17,7 @@ INCIDENT_TEMPLATE = """ COMPONENT_TEMPLATE = "**{name}** has changed status from **{old_status}** to **{new_status}**." -TOPIC_TEMPLATE = u'{name}: {description}' +TOPIC_TEMPLATE = '{name}: {description}' def get_incident_events_body(payload: Dict[str, Any]) -> str: return INCIDENT_TEMPLATE.format( diff --git a/zerver/webhooks/stripe/tests.py b/zerver/webhooks/stripe/tests.py index 9e5b80ea6e..50d40fc06c 100644 --- a/zerver/webhooks/stripe/tests.py +++ b/zerver/webhooks/stripe/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import mock from mock import MagicMock, patch @@ -11,58 +10,58 @@ class StripeHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'stripe' def test_charge_dispute_closed(self) -> None: - expected_topic = u"disputes" - expected_message = u"[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) closed. Current status: won." + expected_topic = "disputes" + expected_message = "[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) closed. Current status: won." self.send_and_test_stream_message('charge_dispute_closed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_charge_dispute_created(self) -> None: - expected_topic = u"disputes" - expected_message = u"[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) created. Current status: needs response." + expected_topic = "disputes" + expected_message = "[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) created. Current status: needs response." self.send_and_test_stream_message('charge_dispute_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_charge_failed(self) -> None: - expected_topic = u"charges" - expected_message = u"[Charge](https://dashboard.stripe.com/charges/ch_00000000000000) for 1.00 AUD failed" + expected_topic = "charges" + expected_message = "[Charge](https://dashboard.stripe.com/charges/ch_00000000000000) for 1.00 AUD failed" self.send_and_test_stream_message('charge_failed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") # Credit card charge def test_charge_succeeded__card(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Charge](https://dashboard.stripe.com/charges/ch_000000000000000000000000) for 1.00 AUD succeeded" + expected_topic = "cus_00000000000000" + expected_message = "[Charge](https://dashboard.stripe.com/charges/ch_000000000000000000000000) for 1.00 AUD succeeded" self.send_and_test_stream_message('charge_succeeded__card', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") # ACH payment (really a 'payment', rather than a 'charge') def test_charge_succeeded__invoice(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Payment](https://dashboard.stripe.com/payments/py_000000000000000000000000) for $1.00 succeeded" + expected_topic = "cus_00000000000000" + expected_message = "[Payment](https://dashboard.stripe.com/payments/py_000000000000000000000000) for $1.00 succeeded" self.send_and_test_stream_message('charge_succeeded__invoice', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_created(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created" + expected_topic = "cus_00000000000000" + expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created" self.send_and_test_stream_message('customer_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_created_email(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created\nEmail: example@abc.com" + expected_topic = "cus_00000000000000" + expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created\nEmail: example@abc.com" self.send_and_test_stream_message('customer_created_email', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_deleted(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) deleted" + expected_topic = "cus_00000000000000" + expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) deleted" self.send_and_test_stream_message('customer_deleted', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_subscription_created(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"""\ + expected_topic = "cus_00000000000000" + expected_message = """\ [Subscription](https://dashboard.stripe.com/subscriptions/sub_E6STM5w5EX3K28) created Plan: [flatrate](https://dashboard.stripe.com/plans/plan_E6SQ6RAtmLVtzg) Quantity: 800 @@ -71,13 +70,13 @@ Billing method: send invoice""" content_type="application/x-www-form-urlencoded") def test_customer_subscription_deleted(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Subscription](https://dashboard.stripe.com/subscriptions/sub_00000000000000) deleted" + expected_topic = "cus_00000000000000" + expected_message = "[Subscription](https://dashboard.stripe.com/subscriptions/sub_00000000000000) deleted" self.send_and_test_stream_message('customer_subscription_deleted', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_subscription_updated(self) -> None: - expected_topic = u"cus_00000000000000" + expected_topic = "cus_00000000000000" expected_message = """\ [Subscription](https://dashboard.stripe.com/subscriptions/sub_E6STM5w5EX3K28) updated * Billing cycle anchor is now Nov 01, 2019, 12:00:00 UTC @@ -91,8 +90,8 @@ Billing method: send invoice""" content_type="application/x-www-form-urlencoded") def test_customer_subscription_trial_will_end(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Subscription](https://dashboard.stripe.com/subscriptions/sub_00000000000000) trial will end in 3 days" + expected_topic = "cus_00000000000000" + expected_message = "[Subscription](https://dashboard.stripe.com/subscriptions/sub_00000000000000) trial will end in 3 days" # 3 days before the end of the trial, plus a little bit to make sure the rounding is working with mock.patch('time.time', return_value=1480892861 - 3*3600*24 + 100): # use fixture named stripe_customer_subscription_trial_will_end @@ -108,20 +107,20 @@ Billing method: send invoice""" content_type="application/x-www-form-urlencoded") def test_customer_discount_created(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"Discount created ([25.5% off](https://dashboard.stripe.com/coupons/25_00000000000000))." + expected_topic = "cus_00000000000000" + expected_message = "Discount created ([25.5% off](https://dashboard.stripe.com/coupons/25_00000000000000))." self.send_and_test_stream_message('customer_discount_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_invoice_payment_failed(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Invoice](https://dashboard.stripe.com/invoices/in_00000000000000) payment failed" + expected_topic = "cus_00000000000000" + expected_message = "[Invoice](https://dashboard.stripe.com/invoices/in_00000000000000) payment failed" self.send_and_test_stream_message('invoice_payment_failed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_invoiceitem_created(self) -> None: - expected_topic = u"cus_00000000000000" - expected_message = u"[Invoice item](https://dashboard.stripe.com/invoiceitems/ii_00000000000000) created for 10.00 CAD" + expected_topic = "cus_00000000000000" + expected_message = "[Invoice item](https://dashboard.stripe.com/invoiceitems/ii_00000000000000) created for 10.00 CAD" self.send_and_test_stream_message( 'invoiceitem_created', expected_topic, @@ -130,8 +129,8 @@ Billing method: send invoice""" ) def test_invoice_paid(self) -> None: - expected_topic = u"cus_FDmrSwQt9Fck5M" - expected_message = u"[Invoice](https://dashboard.stripe.com/invoices/in_1EjLINHuGUuNWDDZjDf2WNqd) is now paid" + expected_topic = "cus_FDmrSwQt9Fck5M" + expected_message = "[Invoice](https://dashboard.stripe.com/invoices/in_1EjLINHuGUuNWDDZjDf2WNqd) is now paid" self.send_and_test_stream_message( 'invoice_updated__paid', expected_topic, diff --git a/zerver/webhooks/stripe/view.py b/zerver/webhooks/stripe/view.py index 43192005dc..9d9c5c9546 100644 --- a/zerver/webhooks/stripe/view.py +++ b/zerver/webhooks/stripe/view.py @@ -198,7 +198,7 @@ def amount_string(amount: int, currency: str) -> str: if currency in zero_decimal_currencies: decimal_amount = str(amount) # nocoverage else: - decimal_amount = '{0:.02f}'.format(float(amount) * 0.01) + decimal_amount = '{:.02f}'.format(float(amount) * 0.01) if currency == 'usd': # nocoverage return '$' + decimal_amount diff --git a/zerver/webhooks/taiga/tests.py b/zerver/webhooks/taiga/tests.py index bc10e1405d..f19d01cf4b 100644 --- a/zerver/webhooks/taiga/tests.py +++ b/zerver/webhooks/taiga/tests.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class TaigaHookTests(WebhookTestCase): STREAM_NAME = 'taiga' TOPIC = "subject" - URL_TEMPLATE = u"/api/v1/external/taiga?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/taiga?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'taiga' def setUp(self) -> None: @@ -13,285 +12,285 @@ class TaigaHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=self.TOPIC) def test_taiga_userstory_deleted(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted user story **New userstory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted user story **New userstory**.' self.send_and_test_stream_message("userstory_deleted", self.TOPIC, message) def test_taiga_userstory_created(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created user story **New userstory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created user story **New userstory**.' self.send_and_test_stream_message("userstory_created", self.TOPIC, message) def test_taiga_userstory_changed_unblocked(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_unblocked", self.TOPIC, message) def test_taiga_userstory_changed_subject(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed user story from UserStory to **UserStoryNewSubject**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed user story from UserStory to **UserStoryNewSubject**.' self.send_and_test_stream_message("userstory_changed_subject", self.TOPIC, message) def test_taiga_userstory_changed_status(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Ready to In progress.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Ready to In progress.' self.send_and_test_stream_message("userstory_changed_status", self.TOPIC, message) def test_taiga_userstory_changed_reassigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned user story **UserStory** from TomaszKolek to HanSolo.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned user story **UserStory** from TomaszKolek to HanSolo.' self.send_and_test_stream_message("userstory_changed_reassigned", self.TOPIC, message) def test_taiga_userstory_changed_unassigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unassigned user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unassigned user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_unassigned", self.TOPIC, message) def test_taiga_userstory_changed_points(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimation of user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimation of user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_points", self.TOPIC, message) def test_taiga_userstory_changed_new_sprint(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) added user story **UserStory** to sprint Sprint1.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) added user story **UserStory** to sprint Sprint1.' self.send_and_test_stream_message("userstory_changed_new_sprint", self.TOPIC, message) def test_taiga_userstory_changed_sprint(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed sprint of user story **UserStory** from Sprint1 to Sprint2.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed sprint of user story **UserStory** from Sprint1 to Sprint2.' self.send_and_test_stream_message("userstory_changed_sprint", self.TOPIC, message) def test_taiga_userstory_changed_remove_sprint(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) removed user story **UserStory** from sprint Sprint2.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) removed user story **UserStory** from sprint Sprint2.' self.send_and_test_stream_message("userstory_changed_remove_sprint", self.TOPIC, message) def test_taiga_userstory_changed_description(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_description", self.TOPIC, message) def test_taiga_userstory_changed_closed(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from New to Done.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) closed user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from New to Done.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) closed user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_closed", self.TOPIC, message) def test_taiga_userstory_changed_reopened(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Done to Ready.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reopened user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Done to Ready.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reopened user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_reopened", self.TOPIC, message) def test_taiga_userstory_changed_blocked(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_blocked", self.TOPIC, message) def test_taiga_userstory_changed_assigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned user story **UserStory** to TomaszKolek.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned user story **UserStory** to TomaszKolek.' self.send_and_test_stream_message("userstory_changed_assigned", self.TOPIC, message) def test_taiga_userstory_comment_added(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on user story **UserStory**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on user story **UserStory**.' self.send_and_test_stream_message("userstory_changed_comment_added", self.TOPIC, message) def test_taiga_userstory_changed_due_date(self) -> None: - message = (u'[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of user story ' + + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of user story ' + '[Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) from 2020-02-15 to 2020-02-22.') self.send_and_test_stream_message("userstory_changed_due_date", self.TOPIC, message) def test_taiga_userstory_changed_new_due_date(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of user story [random](https://tree.taiga.io/project/orientor-sd/us/58) to 2020-02-15.' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of user story [random](https://tree.taiga.io/project/orientor-sd/us/58) to 2020-02-15.' self.send_and_test_stream_message("userstory_changed_new_due_date", self.TOPIC, message) def test_taiga_task_created(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created task **New Task**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created task **New Task**.' self.send_and_test_stream_message("task_created", self.TOPIC, message) def test_taiga_task_changed_user_stories(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added task **Get this task done** to sprint Another one.\n[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) moved task **Get this task done** from user story #7 Yaar ne scirra! to #8 A related user story, which is epic.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added task **Get this task done** to sprint Another one.\n[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) moved task **Get this task done** from user story #7 Yaar ne scirra! to #8 A related user story, which is epic.' self.send_and_test_stream_message("task_changed_user_stories", self.TOPIC, message) def test_taiga_task_changed_status(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of task **New Task** from New to In progress.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of task **New Task** from New to In progress.' self.send_and_test_stream_message("task_changed_status", self.TOPIC, message) def test_taiga_task_changed_blocked(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked task **New Task**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked task **New Task**.' self.send_and_test_stream_message("task_changed_blocked", self.TOPIC, message) def test_taiga_task_changed_blocked_link(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked task [nice task](https://tree.taiga.io/project/orientor-sd/task/56).' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked task [nice task](https://tree.taiga.io/project/orientor-sd/task/56).' self.send_and_test_stream_message("task_changed_blocked_link", self.TOPIC, message) def test_taiga_task_changed_unblocked(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked task **New Task**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked task **New Task**.' self.send_and_test_stream_message("task_changed_unblocked", self.TOPIC, message) def test_taiga_task_changed_assigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned task **New Task** to TomaszKolek.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned task **New Task** to TomaszKolek.' self.send_and_test_stream_message("task_changed_assigned", self.TOPIC, message) def test_taiga_task_changed_reassigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned task **New Task** from HanSolo to TomaszKolek.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned task **New Task** from HanSolo to TomaszKolek.' self.send_and_test_stream_message("task_changed_reassigned", self.TOPIC, message) def test_taiga_task_changed_subject(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed task New Task to **New Task Subject**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed task New Task to **New Task Subject**.' self.send_and_test_stream_message("task_changed_subject", self.TOPIC, message) def test_taiga_task_changed_description(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of task **New Task**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of task **New Task**.' self.send_and_test_stream_message("task_changed_description", self.TOPIC, message) def test_taiga_task_deleted(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted task **New Task**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted task **New Task**.' self.send_and_test_stream_message("task_deleted", self.TOPIC, message) def test_taiga_task_changed_comment_added(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on task **New Task**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on task **New Task**.' self.send_and_test_stream_message("task_changed_comment_added", self.TOPIC, message) def test_taiga_task_changed_due_date(self) -> None: - message = (u'[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of task' + + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of task' + ' [nice task](https://tree.taiga.io/project/orientor-sd/task/56) from 2020-02-22 to 2020-02-15.') self.send_and_test_stream_message("task_changed_due_date", self.TOPIC, message) def test_taiga_task_changed_new_due_date(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of task [nice task](https://tree.taiga.io/project/orientor-sd/task/56) to 2020-02-22.' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of task [nice task](https://tree.taiga.io/project/orientor-sd/task/56) to 2020-02-22.' self.send_and_test_stream_message("task_changed_new_due_date", self.TOPIC, message) def test_taiga_sprint_created(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created sprint **New sprint**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created sprint **New sprint**.' self.send_and_test_stream_message("sprint_created", self.TOPIC, message) def test_taiga_sprint_deleted(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted sprint **New name**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted sprint **New name**.' self.send_and_test_stream_message("sprint_deleted", self.TOPIC, message) def test_taiga_sprint_changed_time(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimated finish of sprint **New sprint** from 2017-01-24 to 2017-01-25.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimated finish of sprint **New sprint** from 2017-01-24 to 2017-01-25.' self.send_and_test_stream_message("sprint_changed_time", self.TOPIC, message) def test_taiga_sprint_changed_name(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed sprint from New sprint to **New name**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed sprint from New sprint to **New name**.' self.send_and_test_stream_message("sprint_changed_name", self.TOPIC, message) def test_taiga_issue_created(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created issue **New issue**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created issue **New issue**.' self.send_and_test_stream_message("issue_created", self.TOPIC, message) def test_taiga_issue_created_link(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) created issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) created issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' self.send_and_test_stream_message("issue_created_link", self.TOPIC, message) def test_taiga_issue_deleted(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted issue **New issue**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted issue **New issue**.' self.send_and_test_stream_message("issue_deleted", self.TOPIC, message) def test_taiga_issue_changed_assigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned issue **New issue** to TomaszKolek.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned issue **New issue** to TomaszKolek.' self.send_and_test_stream_message("issue_changed_assigned", self.TOPIC, message) def test_taiga_issue_changed_reassigned(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned issue **New issue** from TomaszKolek to HanSolo.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned issue **New issue** from TomaszKolek to HanSolo.' self.send_and_test_stream_message("issue_changed_reassigned", self.TOPIC, message) def test_taiga_issue_changed_subject(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed issue New issue to **New issueNewSubject**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed issue New issue to **New issueNewSubject**.' self.send_and_test_stream_message("issue_changed_subject", self.TOPIC, message) def test_taiga_issue_changed_description(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of issue **New issue**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of issue **New issue**.' self.send_and_test_stream_message("issue_changed_description", self.TOPIC, message) def test_taiga_issue_changed_type(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed type of issue **New issue** from Bug to Question.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed type of issue **New issue** from Bug to Question.' self.send_and_test_stream_message("issue_changed_type", self.TOPIC, message) def test_taiga_issue_changed_status(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of issue **New issue** from New to In progress.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of issue **New issue** from New to In progress.' self.send_and_test_stream_message("issue_changed_status", self.TOPIC, message) def test_taiga_issue_changed_severity(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed severity of issue **New issue** from Normal to Minor.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed severity of issue **New issue** from Normal to Minor.' self.send_and_test_stream_message("issue_changed_severity", self.TOPIC, message) def test_taiga_issue_changed_priority(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed priority of issue **New issue** from Normal to Low.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed priority of issue **New issue** from Normal to Low.' self.send_and_test_stream_message("issue_changed_priority", self.TOPIC, message) def test_taiga_issue_changed_comment_added(self) -> None: - message = u'[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on issue **New issue**.' + message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on issue **New issue**.' self.send_and_test_stream_message("issue_changed_comment_added", self.TOPIC, message) def test_taiga_issue_changed_blocked(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' self.send_and_test_stream_message("issue_changed_blocked", self.TOPIC, message) def test_taiga_issue_changed_unblocked(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) unblocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) unblocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' self.send_and_test_stream_message("issue_changed_unblocked", self.TOPIC, message) def test_taiga_issue_changed_due_date(self) -> None: - message = (u'[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49) ' + + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49) ' + 'from 2020-03-08 to 2020-02-22.') self.send_and_test_stream_message("issue_changed_due_date", self.TOPIC, message) def test_taiga_issue_changed_new_due_date(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to 2020-02-22.' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to 2020-02-22.' self.send_and_test_stream_message("issue_changed_new_due_date", self.TOPIC, message) def test_taiga_issue_changed_new_sprint(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) added issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to sprint eres.' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) added issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to sprint eres.' self.send_and_test_stream_message("issue_changed_new_sprint", self.TOPIC, message) def test_taiga_issue_changed_remove_sprint(self) -> None: - message = u'[Aditya Verma](https://tree.taiga.io/profile/orientor) detached issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) from sprint eres.' + message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) detached issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) from sprint eres.' self.send_and_test_stream_message("issue_changed_remove_sprint", self.TOPIC, message) def test_taiga_epic_created(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) created epic **Zulip is awesome!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) created epic **Zulip is awesome!**.' self.send_and_test_stream_message("epic_created", self.TOPIC, message) def test_taiga_epic_changed_assigned(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) assigned epic **Zulip is awesome!** to Eeshan Garg.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) assigned epic **Zulip is awesome!** to Eeshan Garg.' self.send_and_test_stream_message("epic_changed_assigned", self.TOPIC, message) def test_taiga_epic_changed_unassigned(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unassigned epic **Zulip is awesome!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unassigned epic **Zulip is awesome!**.' self.send_and_test_stream_message("epic_changed_unassigned", self.TOPIC, message) def test_taiga_epic_changed_reassigned(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) reassigned epic **Zulip is awesome!** from Eeshan Garg to Angela Johnson.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) reassigned epic **Zulip is awesome!** from Eeshan Garg to Angela Johnson.' self.send_and_test_stream_message("epic_changed_reassigned", self.TOPIC, message) def test_taiga_epic_changed_blocked(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) blocked epic **Zulip is awesome!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) blocked epic **Zulip is awesome!**.' self.send_and_test_stream_message("epic_changed_blocked", self.TOPIC, message) def test_taiga_epic_changed_unblocked(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unblocked epic **Zulip is awesome!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unblocked epic **Zulip is awesome!**.' self.send_and_test_stream_message("epic_changed_unblocked", self.TOPIC, message) def test_taiga_epic_changed_status(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) changed status of epic **Zulip is awesome!** from New to In progress.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) changed status of epic **Zulip is awesome!** from New to In progress.' self.send_and_test_stream_message("epic_changed_status", self.TOPIC, message) def test_taiga_epic_changed_renamed(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) renamed epic from **Zulip is awesome!** to **Zulip is great!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) renamed epic from **Zulip is awesome!** to **Zulip is great!**.' self.send_and_test_stream_message("epic_changed_renamed", self.TOPIC, message) def test_taiga_epic_changed_description(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) updated description of epic **Zulip is great!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) updated description of epic **Zulip is great!**.' self.send_and_test_stream_message("epic_changed_description", self.TOPIC, message) def test_taiga_epic_changed_commented(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) commented on epic **Zulip is great!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) commented on epic **Zulip is great!**.' self.send_and_test_stream_message("epic_changed_commented", self.TOPIC, message) def test_taiga_epic_deleted(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) deleted epic **Zulip is great!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) deleted epic **Zulip is great!**.' self.send_and_test_stream_message("epic_deleted", self.TOPIC, message) def test_taiga_relateduserstory_created(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added a related user story **A related user story** to the epic **This is Epic!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added a related user story **A related user story** to the epic **This is Epic!**.' self.send_and_test_stream_message("relateduserstory_created", self.TOPIC, message) def test_taiga_relateduserstory_created_link(self) -> None: - message = (u'[Aditya Verma](https://tree.taiga.io/profile/orientor) added a related user story [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) ' + + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) added a related user story [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) ' + 'to the epic [ASAS](https://tree.taiga.io/project/orientor-sd/epic/42).') self.send_and_test_stream_message("relateduserstory_created_link", self.TOPIC, message) def test_taiga_relateduserstory_deleted(self) -> None: - message = u'[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) removed a related user story **A related user story, which is epic** from the epic **This is Epic!**.' + message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) removed a related user story **A related user story, which is epic** from the epic **This is Epic!**.' self.send_and_test_stream_message("relateduserstory_deleted", self.TOPIC, message) def test_taiga_webhook_test(self) -> None: - message = u'[Jan](https://tree.taiga.io/profile/kostek) triggered a test of the Taiga integration.' + message = '[Jan](https://tree.taiga.io/profile/kostek) triggered a test of the Taiga integration.' self.send_and_test_stream_message("webhook_test", self.TOPIC, message) diff --git a/zerver/webhooks/taiga/view.py b/zerver/webhooks/taiga/view.py index d9730a3273..5e87db2030 100644 --- a/zerver/webhooks/taiga/view.py +++ b/zerver/webhooks/taiga/view.py @@ -36,114 +36,114 @@ def api_taiga_webhook(request: HttpRequest, user_profile: UserProfile, templates = { 'epic': { - 'create': u'[{user}]({user_link}) created epic {subject}.', - 'set_assigned_to': u'[{user}]({user_link}) assigned epic {subject} to {new}.', - 'unset_assigned_to': u'[{user}]({user_link}) unassigned epic {subject}.', - 'changed_assigned_to': u'[{user}]({user_link}) reassigned epic {subject}' + 'create': '[{user}]({user_link}) created epic {subject}.', + 'set_assigned_to': '[{user}]({user_link}) assigned epic {subject} to {new}.', + 'unset_assigned_to': '[{user}]({user_link}) unassigned epic {subject}.', + 'changed_assigned_to': '[{user}]({user_link}) reassigned epic {subject}' ' from {old} to {new}.', - 'blocked': u'[{user}]({user_link}) blocked epic {subject}.', - 'unblocked': u'[{user}]({user_link}) unblocked epic {subject}.', - 'changed_status': u'[{user}]({user_link}) changed status of epic {subject}' + 'blocked': '[{user}]({user_link}) blocked epic {subject}.', + 'unblocked': '[{user}]({user_link}) unblocked epic {subject}.', + 'changed_status': '[{user}]({user_link}) changed status of epic {subject}' ' from {old} to {new}.', - 'renamed': u'[{user}]({user_link}) renamed epic from **{old}** to **{new}**.', - 'description_diff': u'[{user}]({user_link}) updated description of epic {subject}.', - 'commented': u'[{user}]({user_link}) commented on epic {subject}.', - 'delete': u'[{user}]({user_link}) deleted epic {subject}.', + 'renamed': '[{user}]({user_link}) renamed epic from **{old}** to **{new}**.', + 'description_diff': '[{user}]({user_link}) updated description of epic {subject}.', + 'commented': '[{user}]({user_link}) commented on epic {subject}.', + 'delete': '[{user}]({user_link}) deleted epic {subject}.', }, 'relateduserstory': { - 'create': (u'[{user}]({user_link}) added a related user story ' - u'{userstory_subject} to the epic {epic_subject}.'), - 'delete': (u'[{user}]({user_link}) removed a related user story ' + - u'{userstory_subject} from the epic {epic_subject}.'), + 'create': ('[{user}]({user_link}) added a related user story ' + '{userstory_subject} to the epic {epic_subject}.'), + 'delete': ('[{user}]({user_link}) removed a related user story ' + + '{userstory_subject} from the epic {epic_subject}.'), }, 'userstory': { - 'create': u'[{user}]({user_link}) created user story {subject}.', - 'set_assigned_to': u'[{user}]({user_link}) assigned user story {subject} to {new}.', - 'unset_assigned_to': u'[{user}]({user_link}) unassigned user story {subject}.', - 'changed_assigned_to': u'[{user}]({user_link}) reassigned user story {subject}' + 'create': '[{user}]({user_link}) created user story {subject}.', + 'set_assigned_to': '[{user}]({user_link}) assigned user story {subject} to {new}.', + 'unset_assigned_to': '[{user}]({user_link}) unassigned user story {subject}.', + 'changed_assigned_to': '[{user}]({user_link}) reassigned user story {subject}' ' from {old} to {new}.', - 'points': u'[{user}]({user_link}) changed estimation of user story {subject}.', - 'blocked': u'[{user}]({user_link}) blocked user story {subject}.', - 'unblocked': u'[{user}]({user_link}) unblocked user story {subject}.', - 'set_milestone': u'[{user}]({user_link}) added user story {subject} to sprint {new}.', - 'unset_milestone': u'[{user}]({user_link}) removed user story {subject} from sprint {old}.', - 'changed_milestone': u'[{user}]({user_link}) changed sprint of user story {subject} from {old}' + 'points': '[{user}]({user_link}) changed estimation of user story {subject}.', + 'blocked': '[{user}]({user_link}) blocked user story {subject}.', + 'unblocked': '[{user}]({user_link}) unblocked user story {subject}.', + 'set_milestone': '[{user}]({user_link}) added user story {subject} to sprint {new}.', + 'unset_milestone': '[{user}]({user_link}) removed user story {subject} from sprint {old}.', + 'changed_milestone': '[{user}]({user_link}) changed sprint of user story {subject} from {old}' ' to {new}.', - 'changed_status': u'[{user}]({user_link}) changed status of user story {subject}' + 'changed_status': '[{user}]({user_link}) changed status of user story {subject}' ' from {old} to {new}.', - 'closed': u'[{user}]({user_link}) closed user story {subject}.', - 'reopened': u'[{user}]({user_link}) reopened user story {subject}.', - 'renamed': u'[{user}]({user_link}) renamed user story from {old} to **{new}**.', - 'description_diff': u'[{user}]({user_link}) updated description of user story {subject}.', - 'commented': u'[{user}]({user_link}) commented on user story {subject}.', - 'delete': u'[{user}]({user_link}) deleted user story {subject}.', - 'due_date': u'[{user}]({user_link}) changed due date of user story {subject}' + 'closed': '[{user}]({user_link}) closed user story {subject}.', + 'reopened': '[{user}]({user_link}) reopened user story {subject}.', + 'renamed': '[{user}]({user_link}) renamed user story from {old} to **{new}**.', + 'description_diff': '[{user}]({user_link}) updated description of user story {subject}.', + 'commented': '[{user}]({user_link}) commented on user story {subject}.', + 'delete': '[{user}]({user_link}) deleted user story {subject}.', + 'due_date': '[{user}]({user_link}) changed due date of user story {subject}' ' from {old} to {new}.', - 'set_due_date': u'[{user}]({user_link}) set due date of user story {subject}' + 'set_due_date': '[{user}]({user_link}) set due date of user story {subject}' ' to {new}.', }, 'milestone': { - 'create': u'[{user}]({user_link}) created sprint {subject}.', - 'renamed': u'[{user}]({user_link}) renamed sprint from {old} to **{new}**.', - 'estimated_start': u'[{user}]({user_link}) changed estimated start of sprint {subject}' + 'create': '[{user}]({user_link}) created sprint {subject}.', + 'renamed': '[{user}]({user_link}) renamed sprint from {old} to **{new}**.', + 'estimated_start': '[{user}]({user_link}) changed estimated start of sprint {subject}' ' from {old} to {new}.', - 'estimated_finish': u'[{user}]({user_link}) changed estimated finish of sprint {subject}' + 'estimated_finish': '[{user}]({user_link}) changed estimated finish of sprint {subject}' ' from {old} to {new}.', - 'set_estimated_start': u'[{user}]({user_link}) changed estimated start of sprint {subject}' + 'set_estimated_start': '[{user}]({user_link}) changed estimated start of sprint {subject}' ' to {new}.', - 'set_estimated_finish': u'[{user}]({user_link}) set estimated finish of sprint {subject}' + 'set_estimated_finish': '[{user}]({user_link}) set estimated finish of sprint {subject}' ' to {new}.', - 'delete': u'[{user}]({user_link}) deleted sprint {subject}.' + 'delete': '[{user}]({user_link}) deleted sprint {subject}.' }, 'task': { - 'create': u'[{user}]({user_link}) created task {subject}.', - 'set_assigned_to': u'[{user}]({user_link}) assigned task {subject} to {new}.', - 'unset_assigned_to': u'[{user}]({user_link}) unassigned task {subject}.', - 'changed_assigned_to': u'[{user}]({user_link}) reassigned task {subject}' + 'create': '[{user}]({user_link}) created task {subject}.', + 'set_assigned_to': '[{user}]({user_link}) assigned task {subject} to {new}.', + 'unset_assigned_to': '[{user}]({user_link}) unassigned task {subject}.', + 'changed_assigned_to': '[{user}]({user_link}) reassigned task {subject}' ' from {old} to {new}.', - 'blocked': u'[{user}]({user_link}) blocked task {subject}.', - 'unblocked': u'[{user}]({user_link}) unblocked task {subject}.', - 'changed_status': u'[{user}]({user_link}) changed status of task {subject}' + 'blocked': '[{user}]({user_link}) blocked task {subject}.', + 'unblocked': '[{user}]({user_link}) unblocked task {subject}.', + 'changed_status': '[{user}]({user_link}) changed status of task {subject}' ' from {old} to {new}.', - 'renamed': u'[{user}]({user_link}) renamed task {old} to **{new}**.', - 'description_diff': u'[{user}]({user_link}) updated description of task {subject}.', - 'set_milestone': u'[{user}]({user_link}) added task {subject} to sprint {new}.', - 'commented': u'[{user}]({user_link}) commented on task {subject}.', - 'delete': u'[{user}]({user_link}) deleted task {subject}.', - 'changed_us': u'[{user}]({user_link}) moved task {subject} from user story {old} to {new}.', - 'due_date': u'[{user}]({user_link}) changed due date of task {subject}' + 'renamed': '[{user}]({user_link}) renamed task {old} to **{new}**.', + 'description_diff': '[{user}]({user_link}) updated description of task {subject}.', + 'set_milestone': '[{user}]({user_link}) added task {subject} to sprint {new}.', + 'commented': '[{user}]({user_link}) commented on task {subject}.', + 'delete': '[{user}]({user_link}) deleted task {subject}.', + 'changed_us': '[{user}]({user_link}) moved task {subject} from user story {old} to {new}.', + 'due_date': '[{user}]({user_link}) changed due date of task {subject}' ' from {old} to {new}.', - 'set_due_date': u'[{user}]({user_link}) set due date of task {subject}' + 'set_due_date': '[{user}]({user_link}) set due date of task {subject}' ' to {new}.', }, 'issue': { - 'create': u'[{user}]({user_link}) created issue {subject}.', - 'set_assigned_to': u'[{user}]({user_link}) assigned issue {subject} to {new}.', - 'unset_assigned_to': u'[{user}]({user_link}) unassigned issue {subject}.', - 'changed_assigned_to': u'[{user}]({user_link}) reassigned issue {subject}' + 'create': '[{user}]({user_link}) created issue {subject}.', + 'set_assigned_to': '[{user}]({user_link}) assigned issue {subject} to {new}.', + 'unset_assigned_to': '[{user}]({user_link}) unassigned issue {subject}.', + 'changed_assigned_to': '[{user}]({user_link}) reassigned issue {subject}' ' from {old} to {new}.', - 'set_milestone': u'[{user}]({user_link}) added issue {subject} to sprint {new}.', - 'unset_milestone': u'[{user}]({user_link}) detached issue {subject} from sprint {old}.', - 'changed_priority': u'[{user}]({user_link}) changed priority of issue ' + 'set_milestone': '[{user}]({user_link}) added issue {subject} to sprint {new}.', + 'unset_milestone': '[{user}]({user_link}) detached issue {subject} from sprint {old}.', + 'changed_priority': '[{user}]({user_link}) changed priority of issue ' '{subject} from {old} to {new}.', - 'changed_severity': u'[{user}]({user_link}) changed severity of issue ' + 'changed_severity': '[{user}]({user_link}) changed severity of issue ' '{subject} from {old} to {new}.', - 'changed_status': u'[{user}]({user_link}) changed status of issue {subject}' + 'changed_status': '[{user}]({user_link}) changed status of issue {subject}' ' from {old} to {new}.', - 'changed_type': u'[{user}]({user_link}) changed type of issue {subject} from {old} to {new}.', - 'renamed': u'[{user}]({user_link}) renamed issue {old} to **{new}**.', - 'description_diff': u'[{user}]({user_link}) updated description of issue {subject}.', - 'commented': u'[{user}]({user_link}) commented on issue {subject}.', - 'delete': u'[{user}]({user_link}) deleted issue {subject}.', - 'due_date': u'[{user}]({user_link}) changed due date of issue {subject}' + 'changed_type': '[{user}]({user_link}) changed type of issue {subject} from {old} to {new}.', + 'renamed': '[{user}]({user_link}) renamed issue {old} to **{new}**.', + 'description_diff': '[{user}]({user_link}) updated description of issue {subject}.', + 'commented': '[{user}]({user_link}) commented on issue {subject}.', + 'delete': '[{user}]({user_link}) deleted issue {subject}.', + 'due_date': '[{user}]({user_link}) changed due date of issue {subject}' ' from {old} to {new}.', - 'set_due_date': u'[{user}]({user_link}) set due date of issue {subject}' + 'set_due_date': '[{user}]({user_link}) set due date of issue {subject}' ' to {new}.', - 'blocked': u'[{user}]({user_link}) blocked issue {subject}.', - 'unblocked': u'[{user}]({user_link}) unblocked issue {subject}.', + 'blocked': '[{user}]({user_link}) blocked issue {subject}.', + 'unblocked': '[{user}]({user_link}) unblocked issue {subject}.', }, 'webhook_test': { - 'test': u'[{user}]({user_link}) triggered a test of the Taiga integration.' + 'test': '[{user}]({user_link}) triggered a test of the Taiga integration.' }, } diff --git a/zerver/webhooks/teamcity/tests.py b/zerver/webhooks/teamcity/tests.py index 343ce98f4f..5a4d64c22a 100644 --- a/zerver/webhooks/teamcity/tests.py +++ b/zerver/webhooks/teamcity/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import ujson from zerver.lib.send_email import FromAddress @@ -10,33 +9,33 @@ from zerver.webhooks.teamcity.view import \ class TeamcityHookTests(WebhookTestCase): STREAM_NAME = 'teamcity' - URL_TEMPLATE = u"/api/v1/external/teamcity?stream={stream}&api_key={api_key}" - TOPIC = u"Project :: Compile" + URL_TEMPLATE = "/api/v1/external/teamcity?stream={stream}&api_key={api_key}" + TOPIC = "Project :: Compile" FIXTURE_DIR_NAME = 'teamcity' def test_teamcity_success(self) -> None: - expected_message = u"Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." + expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." self.send_and_test_stream_message('success', self.TOPIC, expected_message) def test_teamcity_success_branch(self) -> None: - expected_message = u"Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." - expected_topic = u"Project :: Compile (MyBranch)" + expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." + expected_topic = "Project :: Compile (MyBranch)" self.send_and_test_stream_message('success_branch', expected_topic, expected_message) def test_teamcity_broken(self) -> None: - expected_message = u"Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." + expected_message = "Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." self.send_and_test_stream_message('broken', self.TOPIC, expected_message) def test_teamcity_failure(self) -> None: - expected_message = u"Project :: Compile build 5535 - CL 123456 is still broken with status Exit code 1! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." + expected_message = "Project :: Compile build 5535 - CL 123456 is still broken with status Exit code 1! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." self.send_and_test_stream_message('failure', self.TOPIC, expected_message) def test_teamcity_fixed(self) -> None: - expected_message = u"Project :: Compile build 5535 - CL 123456 has been fixed! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." + expected_message = "Project :: Compile build 5535 - CL 123456 has been fixed! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." self.send_and_test_stream_message('fixed', self.TOPIC, expected_message) def test_teamcity_personal(self) -> None: - expected_message = u"Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." + expected_message = "Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." payload = ujson.dumps(ujson.loads(self.webhook_fixture_data(self.FIXTURE_DIR_NAME, 'personal'))) self.client_post(self.url, payload, content_type="application/json") msg = self.get_last_message() diff --git a/zerver/webhooks/transifex/tests.py b/zerver/webhooks/transifex/tests.py index a439c5d107..67e73e96f8 100644 --- a/zerver/webhooks/transifex/tests.py +++ b/zerver/webhooks/transifex/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Any, Dict from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class TransifexHookTests(WebhookTestCase): STREAM_NAME = 'transifex' - URL_TEMPLATE = u"/api/v1/external/transifex?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/transifex?stream={stream}&api_key={api_key}" URL_REVIEWED_METHOD_TEMPLATE = "reviewed=100" URL_TRANSLATED_METHOD_TEMPLATE = "translated=100" FIXTURE_DIR_NAME = 'transifex' diff --git a/zerver/webhooks/travis/tests.py b/zerver/webhooks/travis/tests.py index fb13a34233..26794dcf40 100644 --- a/zerver/webhooks/travis/tests.py +++ b/zerver/webhooks/travis/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import urllib from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class TravisHookTests(WebhookTestCase): STREAM_NAME = 'travis' - URL_TEMPLATE = u"/api/v1/external/travis?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/travis?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'travis' TOPIC = 'builds' @@ -17,10 +16,10 @@ class TravisHookTests(WebhookTestCase): The subject describes the repo and Stash "project". The content describes the commits pushed. """ - expected_message = (u"Author: josh_mandel\nBuild status: Passed :thumbs_up:\n" - u"Details: [changes](https://github.com/hl7-fhir/fhir-sv" - u"n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht" - u"tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)") + expected_message = ("Author: josh_mandel\nBuild status: Passed :thumbs_up:\n" + "Details: [changes](https://github.com/hl7-fhir/fhir-sv" + "n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht" + "tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)") self.send_and_test_stream_message( 'build', @@ -42,10 +41,10 @@ class TravisHookTests(WebhookTestCase): def test_travis_pull_requests_are_not_ignored_when_applicable(self) -> None: self.url = "{}&ignore_pull_requests=false".format(self.build_webhook_url()) - expected_message = (u"Author: josh_mandel\nBuild status: Passed :thumbs_up:\n" - u"Details: [changes](https://github.com/hl7-fhir/fhir-sv" - u"n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht" - u"tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)") + expected_message = ("Author: josh_mandel\nBuild status: Passed :thumbs_up:\n" + "Details: [changes](https://github.com/hl7-fhir/fhir-sv" + "n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht" + "tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)") self.send_and_test_stream_message( 'pull_request', diff --git a/zerver/webhooks/travis/view.py b/zerver/webhooks/travis/view.py index 75c9a7fcb3..8de660f7a7 100644 --- a/zerver/webhooks/travis/view.py +++ b/zerver/webhooks/travis/view.py @@ -14,9 +14,9 @@ GOOD_STATUSES = ['Passed', 'Fixed'] BAD_STATUSES = ['Failed', 'Broken', 'Still Failing', 'Errored', 'Canceled'] MESSAGE_TEMPLATE = ( - u'Author: {}\n' - u'Build status: {} {}\n' - u'Details: [changes]({}), [build log]({})' + 'Author: {}\n' + 'Build status: {} {}\n' + 'Details: [changes]({}), [build log]({})' ) @api_key_only_webhook_view('Travis') diff --git a/zerver/webhooks/trello/tests.py b/zerver/webhooks/trello/tests.py index 5622aac137..b20336279a 100644 --- a/zerver/webhooks/trello/tests.py +++ b/zerver/webhooks/trello/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from mock import MagicMock, patch from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class TrelloHookTests(WebhookTestCase): STREAM_NAME = 'trello' - URL_TEMPLATE = u"/api/v1/external/trello?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/trello?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'trello' def test_trello_confirmation_request(self) -> None: @@ -14,88 +13,88 @@ class TrelloHookTests(WebhookTestCase): self.assertEqual(response.status_code, 200, response) def test_trello_webhook_when_card_was_moved_to_another_list(self) -> None: - expected_message = u"TomaszKolek moved [This is a card.](https://trello.com/c/r33ylX2Z) from Basics to Intermediate." - self.send_and_test_stream_message('changing_cards_list', u"Welcome Board", expected_message) + expected_message = "TomaszKolek moved [This is a card.](https://trello.com/c/r33ylX2Z) from Basics to Intermediate." + self.send_and_test_stream_message('changing_cards_list', "Welcome Board", expected_message) def test_trello_webhook_when_card_was_renamed(self) -> None: - expected_message = u"TomaszKolek renamed the card from \"Old name\" to [New name](https://trello.com/c/r33ylX2Z)." - self.send_and_test_stream_message('renaming_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek renamed the card from \"Old name\" to [New name](https://trello.com/c/r33ylX2Z)." + self.send_and_test_stream_message('renaming_card', "Welcome Board", expected_message) def test_trello_webhook_when_label_was_added_to_card(self) -> None: - expected_message = u"TomaszKolek added a green label with \"text value\" to [Card name](https://trello.com/c/r33ylX2Z)." - self.send_and_test_stream_message('adding_label_to_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek added a green label with \"text value\" to [Card name](https://trello.com/c/r33ylX2Z)." + self.send_and_test_stream_message('adding_label_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_label_was_removing_from_card(self) -> None: - expected_message = u"TomaszKolek removed a green label with \"text value\" from [New Card](https://trello.com/c/r33ylX2Z)." - self.send_and_test_stream_message('removing_label_from_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek removed a green label with \"text value\" from [New Card](https://trello.com/c/r33ylX2Z)." + self.send_and_test_stream_message('removing_label_from_card', "Welcome Board", expected_message) def test_trello_webhook_when_member_was_added_to_card(self) -> None: - expected_message = u"TomaszKolek added TomaszKolek to [Card name](https://trello.com/c/9BduUcVQ)." - self.send_and_test_stream_message('adding_member_to_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek added TomaszKolek to [Card name](https://trello.com/c/9BduUcVQ)." + self.send_and_test_stream_message('adding_member_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_member_was_removed_from_card(self) -> None: - expected_message = u"TomaszKolek removed Trello from [Card name](https://trello.com/c/9BduUcVQ)." - self.send_and_test_stream_message('removing_member_from_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek removed Trello from [Card name](https://trello.com/c/9BduUcVQ)." + self.send_and_test_stream_message('removing_member_from_card', "Welcome Board", expected_message) def test_trello_webhook_when_due_date_was_set(self) -> None: - expected_message = u"TomaszKolek set due date for [Card name](https://trello.com/c/9BduUcVQ) to 2016-05-11 10:00:00 UTC." - self.send_and_test_stream_message('setting_due_date_to_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek set due date for [Card name](https://trello.com/c/9BduUcVQ) to 2016-05-11 10:00:00 UTC." + self.send_and_test_stream_message('setting_due_date_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_due_date_was_changed(self) -> None: - expected_message = u"TomaszKolek changed due date for [Card name](https://trello.com/c/9BduUcVQ) from 2016-05-11 10:00:00 UTC to 2016-05-24 10:00:00 UTC." - self.send_and_test_stream_message('changing_due_date_on_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek changed due date for [Card name](https://trello.com/c/9BduUcVQ) from 2016-05-11 10:00:00 UTC to 2016-05-24 10:00:00 UTC." + self.send_and_test_stream_message('changing_due_date_on_card', "Welcome Board", expected_message) def test_trello_webhook_when_due_date_was_removed(self) -> None: - expected_message = u"TomaszKolek removed the due date from [Card name](https://trello.com/c/9BduUcVQ)." - self.send_and_test_stream_message('removing_due_date_from_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek removed the due date from [Card name](https://trello.com/c/9BduUcVQ)." + self.send_and_test_stream_message('removing_due_date_from_card', "Welcome Board", expected_message) def test_trello_webhook_when_card_was_archived(self) -> None: - expected_message = u"TomaszKolek archived [Card name](https://trello.com/c/9BduUcVQ)." - self.send_and_test_stream_message('archiving_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek archived [Card name](https://trello.com/c/9BduUcVQ)." + self.send_and_test_stream_message('archiving_card', "Welcome Board", expected_message) def test_trello_webhook_when_card_was_reopened(self) -> None: - expected_message = u"TomaszKolek reopened [Card name](https://trello.com/c/9BduUcVQ)." - self.send_and_test_stream_message('reopening_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek reopened [Card name](https://trello.com/c/9BduUcVQ)." + self.send_and_test_stream_message('reopening_card', "Welcome Board", expected_message) def test_trello_webhook_when_card_was_created(self) -> None: - expected_message = u"TomaszKolek created [New card](https://trello.com/c/5qrgGdD5)." - self.send_and_test_stream_message('creating_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek created [New card](https://trello.com/c/5qrgGdD5)." + self.send_and_test_stream_message('creating_card', "Welcome Board", expected_message) def test_trello_webhook_when_attachment_was_added_to_card(self) -> None: - expected_message = u"TomaszKolek added [attachment_name](http://url.com) to [New card](https://trello.com/c/xPKXoSTQ)." - self.send_and_test_stream_message('adding_attachment_to_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek added [attachment_name](http://url.com) to [New card](https://trello.com/c/xPKXoSTQ)." + self.send_and_test_stream_message('adding_attachment_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_checklist_was_added_to_card(self) -> None: - expected_message = u"TomaszKolek added the Checklist checklist to [New card](https://trello.com/c/xPKXoSTQ)." - self.send_and_test_stream_message('adding_checklist_to_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek added the Checklist checklist to [New card](https://trello.com/c/xPKXoSTQ)." + self.send_and_test_stream_message('adding_checklist_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_check_item_is_checked(self) -> None: - expected_message = u"Eeshan Garg checked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))." - self.send_and_test_stream_message('check_item_on_card_checklist', u"Zulip", expected_message) + expected_message = "Eeshan Garg checked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))." + self.send_and_test_stream_message('check_item_on_card_checklist', "Zulip", expected_message) def test_trello_webhook_when_check_item_is_unchecked(self) -> None: - expected_message = u"Eeshan Garg unchecked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))." - self.send_and_test_stream_message('uncheck_item_on_card_checklist', u"Zulip", expected_message) + expected_message = "Eeshan Garg unchecked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))." + self.send_and_test_stream_message('uncheck_item_on_card_checklist', "Zulip", expected_message) def test_trello_webhook_when_member_was_removed_from_board(self) -> None: - expected_message = u"TomaszKolek removed Trello from [Welcome Board](https://trello.com/b/iqXXzYEj)." - self.send_and_test_stream_message('removing_member_from_board', u"Welcome Board", expected_message) + expected_message = "TomaszKolek removed Trello from [Welcome Board](https://trello.com/b/iqXXzYEj)." + self.send_and_test_stream_message('removing_member_from_board', "Welcome Board", expected_message) def test_trello_webhook_when_member_was_added_to_board(self) -> None: - expected_message = u"TomaszKolek added Trello to [Welcome Board](https://trello.com/b/iqXXzYEj)." - self.send_and_test_stream_message('adding_member_to_board', u"Welcome Board", expected_message) + expected_message = "TomaszKolek added Trello to [Welcome Board](https://trello.com/b/iqXXzYEj)." + self.send_and_test_stream_message('adding_member_to_board', "Welcome Board", expected_message) def test_trello_webhook_when_list_was_added_to_board(self) -> None: - expected_message = u"TomaszKolek added New list list to [Welcome Board](https://trello.com/b/iqXXzYEj)." - self.send_and_test_stream_message('adding_new_list_to_board', u"Welcome Board", expected_message) + expected_message = "TomaszKolek added New list list to [Welcome Board](https://trello.com/b/iqXXzYEj)." + self.send_and_test_stream_message('adding_new_list_to_board', "Welcome Board", expected_message) def test_trello_webhook_when_comment_was_added_to_card(self) -> None: - expected_message = u"TomaszKolek commented on [New card](https://trello.com/c/xPKXoSTQ):\n~~~ quote\nNew comment\n~~~" - self.send_and_test_stream_message('adding_comment_to_card', u"Welcome Board", expected_message) + expected_message = "TomaszKolek commented on [New card](https://trello.com/c/xPKXoSTQ):\n~~~ quote\nNew comment\n~~~" + self.send_and_test_stream_message('adding_comment_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_board_was_renamed(self) -> None: - expected_message = u"TomaszKolek renamed the board from Welcome Board to [New name](https://trello.com/b/iqXXzYEj)." - self.send_and_test_stream_message('renaming_board', u"New name", expected_message) + expected_message = "TomaszKolek renamed the board from Welcome Board to [New name](https://trello.com/b/iqXXzYEj)." + self.send_and_test_stream_message('renaming_board', "New name", expected_message) @patch('zerver.webhooks.trello.view.check_send_webhook_message') def test_trello_webhook_when_card_is_moved_within_single_list_ignore( @@ -122,13 +121,13 @@ class TrelloHookTests(WebhookTestCase): self.assert_json_success(result) def test_trello_webhook_when_description_was_added_to_card(self) -> None: - expected_message = u"Marco Matarazzo set description for [New Card](https://trello.com/c/P2r0z66z) to:\n~~~ quote\nNew Description\n~~~" - self.send_and_test_stream_message('adding_description_to_card', u"Welcome Board", expected_message) + expected_message = "Marco Matarazzo set description for [New Card](https://trello.com/c/P2r0z66z) to:\n~~~ quote\nNew Description\n~~~" + self.send_and_test_stream_message('adding_description_to_card', "Welcome Board", expected_message) def test_trello_webhook_when_description_was_removed_from_card(self) -> None: - expected_message = u"Marco Matarazzo removed description from [New Card](https://trello.com/c/P2r0z66z)." - self.send_and_test_stream_message('removing_description_from_card', u"Welcome Board", expected_message) + expected_message = "Marco Matarazzo removed description from [New Card](https://trello.com/c/P2r0z66z)." + self.send_and_test_stream_message('removing_description_from_card', "Welcome Board", expected_message) def test_trello_webhook_when_description_was_changed_on_card(self) -> None: - expected_message = u"Marco Matarazzo changed description for [New Card](https://trello.com/c/P2r0z66z) from\n~~~ quote\nNew Description\n~~~\nto\n~~~ quote\nChanged Description\n~~~" - self.send_and_test_stream_message('changing_description_on_card', u"Welcome Board", expected_message) + expected_message = "Marco Matarazzo changed description for [New Card](https://trello.com/c/P2r0z66z) from\n~~~ quote\nNew Description\n~~~\nto\n~~~ quote\nChanged Description\n~~~" + self.send_and_test_stream_message('changing_description_on_card', "Welcome Board", expected_message) diff --git a/zerver/webhooks/trello/view/board_actions.py b/zerver/webhooks/trello/view/board_actions.py index f17606127f..a35fc57656 100644 --- a/zerver/webhooks/trello/view/board_actions.py +++ b/zerver/webhooks/trello/view/board_actions.py @@ -3,24 +3,24 @@ from typing import Any, Dict, Mapping, Optional, Tuple from zerver.lib.exceptions import UnexpectedWebhookEventType SUPPORTED_BOARD_ACTIONS = [ - u'removeMemberFromBoard', - u'addMemberToBoard', - u'createList', - u'updateBoard', + 'removeMemberFromBoard', + 'addMemberToBoard', + 'createList', + 'updateBoard', ] -REMOVE_MEMBER = u'removeMemberFromBoard' -ADD_MEMBER = u'addMemberToBoard' -CREATE_LIST = u'createList' -CHANGE_NAME = u'changeName' +REMOVE_MEMBER = 'removeMemberFromBoard' +ADD_MEMBER = 'addMemberToBoard' +CREATE_LIST = 'createList' +CHANGE_NAME = 'changeName' -TRELLO_BOARD_URL_TEMPLATE = u'[{board_name}]({board_url})' +TRELLO_BOARD_URL_TEMPLATE = '[{board_name}]({board_url})' ACTIONS_TO_MESSAGE_MAPPER = { - REMOVE_MEMBER: u'removed {member_name} from {board_url_template}.', - ADD_MEMBER: u'added {member_name} to {board_url_template}.', - CREATE_LIST: u'added {list_name} list to {board_url_template}.', - CHANGE_NAME: u'renamed the board from {old_name} to {board_url_template}.' + REMOVE_MEMBER: 'removed {member_name} from {board_url_template}.', + ADD_MEMBER: 'added {member_name} to {board_url_template}.', + CREATE_LIST: 'added {list_name} list to {board_url_template}.', + CHANGE_NAME: 'renamed the board from {old_name} to {board_url_template}.' } def process_board_action(payload: Mapping[str, Any], @@ -48,7 +48,7 @@ def get_subject(payload: Mapping[str, Any]) -> str: def get_body(payload: Mapping[str, Any], action_type: str) -> str: message_body = ACTIONS_TO_FILL_BODY_MAPPER[action_type](payload, action_type) creator = payload['action']['memberCreator']['fullName'] - return u'{full_name} {rest}'.format(full_name=creator, rest=message_body) + return '{full_name} {rest}'.format(full_name=creator, rest=message_body) def get_managed_member_body(payload: Mapping[str, Any], action_type: str) -> str: data = { @@ -85,7 +85,7 @@ def get_board_name(payload: Mapping[str, Any]) -> str: return get_action_data(payload)['board']['name'] def get_board_url(payload: Mapping[str, Any]) -> str: - return u'https://trello.com/b/{}'.format(get_action_data(payload)['board']['shortLink']) + return 'https://trello.com/b/{}'.format(get_action_data(payload)['board']['shortLink']) def get_message_body(action_type: str) -> str: return ACTIONS_TO_MESSAGE_MAPPER[action_type] diff --git a/zerver/webhooks/trello/view/card_actions.py b/zerver/webhooks/trello/view/card_actions.py index bf1819f528..ad29dbf33b 100644 --- a/zerver/webhooks/trello/view/card_actions.py +++ b/zerver/webhooks/trello/view/card_actions.py @@ -3,65 +3,65 @@ from typing import Any, Dict, Mapping, Optional, Tuple from zerver.lib.exceptions import UnexpectedWebhookEventType SUPPORTED_CARD_ACTIONS = [ - u'updateCard', - u'createCard', - u'addLabelToCard', - u'removeLabelFromCard', - u'addMemberToCard', - u'removeMemberFromCard', - u'addAttachmentToCard', - u'addChecklistToCard', - u'commentCard', - u'updateCheckItemStateOnCard', + 'updateCard', + 'createCard', + 'addLabelToCard', + 'removeLabelFromCard', + 'addMemberToCard', + 'removeMemberFromCard', + 'addAttachmentToCard', + 'addChecklistToCard', + 'commentCard', + 'updateCheckItemStateOnCard', ] IGNORED_CARD_ACTIONS = [ 'createCheckItem', ] -CREATE = u'createCard' -CHANGE_LIST = u'changeList' -CHANGE_NAME = u'changeName' -SET_DESC = u'setDesc' -CHANGE_DESC = u'changeDesc' -REMOVE_DESC = u'removeDesc' -ARCHIVE = u'archiveCard' -REOPEN = u'reopenCard' -SET_DUE_DATE = u'setDueDate' -CHANGE_DUE_DATE = u'changeDueDate' -REMOVE_DUE_DATE = u'removeDueDate' -ADD_LABEL = u'addLabelToCard' -REMOVE_LABEL = u'removeLabelFromCard' -ADD_MEMBER = u'addMemberToCard' -REMOVE_MEMBER = u'removeMemberFromCard' -ADD_ATTACHMENT = u'addAttachmentToCard' -ADD_CHECKLIST = u'addChecklistToCard' -COMMENT = u'commentCard' -UPDATE_CHECK_ITEM_STATE = u'updateCheckItemStateOnCard' +CREATE = 'createCard' +CHANGE_LIST = 'changeList' +CHANGE_NAME = 'changeName' +SET_DESC = 'setDesc' +CHANGE_DESC = 'changeDesc' +REMOVE_DESC = 'removeDesc' +ARCHIVE = 'archiveCard' +REOPEN = 'reopenCard' +SET_DUE_DATE = 'setDueDate' +CHANGE_DUE_DATE = 'changeDueDate' +REMOVE_DUE_DATE = 'removeDueDate' +ADD_LABEL = 'addLabelToCard' +REMOVE_LABEL = 'removeLabelFromCard' +ADD_MEMBER = 'addMemberToCard' +REMOVE_MEMBER = 'removeMemberFromCard' +ADD_ATTACHMENT = 'addAttachmentToCard' +ADD_CHECKLIST = 'addChecklistToCard' +COMMENT = 'commentCard' +UPDATE_CHECK_ITEM_STATE = 'updateCheckItemStateOnCard' -TRELLO_CARD_URL_TEMPLATE = u'[{card_name}]({card_url})' +TRELLO_CARD_URL_TEMPLATE = '[{card_name}]({card_url})' ACTIONS_TO_MESSAGE_MAPPER = { - CREATE: u'created {card_url_template}.', - CHANGE_LIST: u'moved {card_url_template} from {old_list} to {new_list}.', - CHANGE_NAME: u'renamed the card from "{old_name}" to {card_url_template}.', - SET_DESC: u'set description for {card_url_template} to:\n~~~ quote\n{desc}\n~~~\n', - CHANGE_DESC: (u'changed description for {card_url_template} from\n' + + CREATE: 'created {card_url_template}.', + CHANGE_LIST: 'moved {card_url_template} from {old_list} to {new_list}.', + CHANGE_NAME: 'renamed the card from "{old_name}" to {card_url_template}.', + SET_DESC: 'set description for {card_url_template} to:\n~~~ quote\n{desc}\n~~~\n', + CHANGE_DESC: ('changed description for {card_url_template} from\n' + '~~~ quote\n{old_desc}\n~~~\nto\n~~~ quote\n{desc}\n~~~\n'), - REMOVE_DESC: u'removed description from {card_url_template}.', - ARCHIVE: u'archived {card_url_template}.', - REOPEN: u'reopened {card_url_template}.', - SET_DUE_DATE: u'set due date for {card_url_template} to {due_date}.', - CHANGE_DUE_DATE: u'changed due date for {card_url_template} from {old_due_date} to {due_date}.', - REMOVE_DUE_DATE: u'removed the due date from {card_url_template}.', - ADD_LABEL: u'added a {color} label with \"{text}\" to {card_url_template}.', - REMOVE_LABEL: u'removed a {color} label with \"{text}\" from {card_url_template}.', - ADD_MEMBER: u'added {member_name} to {card_url_template}.', - REMOVE_MEMBER: u'removed {member_name} from {card_url_template}.', - ADD_ATTACHMENT: u'added [{attachment_name}]({attachment_url}) to {card_url_template}.', - ADD_CHECKLIST: u'added the {checklist_name} checklist to {card_url_template}.', - COMMENT: u'commented on {card_url_template}:\n~~~ quote\n{text}\n~~~\n', - UPDATE_CHECK_ITEM_STATE: u'{action} **{item_name}** in **{checklist_name}** ({card_url_template}).' + REMOVE_DESC: 'removed description from {card_url_template}.', + ARCHIVE: 'archived {card_url_template}.', + REOPEN: 'reopened {card_url_template}.', + SET_DUE_DATE: 'set due date for {card_url_template} to {due_date}.', + CHANGE_DUE_DATE: 'changed due date for {card_url_template} from {old_due_date} to {due_date}.', + REMOVE_DUE_DATE: 'removed the due date from {card_url_template}.', + ADD_LABEL: 'added a {color} label with \"{text}\" to {card_url_template}.', + REMOVE_LABEL: 'removed a {color} label with \"{text}\" from {card_url_template}.', + ADD_MEMBER: 'added {member_name} to {card_url_template}.', + REMOVE_MEMBER: 'removed {member_name} from {card_url_template}.', + ADD_ATTACHMENT: 'added [{attachment_name}]({attachment_url}) to {card_url_template}.', + ADD_CHECKLIST: 'added the {checklist_name} checklist to {card_url_template}.', + COMMENT: 'commented on {card_url_template}:\n~~~ quote\n{text}\n~~~\n', + UPDATE_CHECK_ITEM_STATE: '{action} **{item_name}** in **{checklist_name}** ({card_url_template}).' } def prettify_date(date_string: str) -> str: @@ -114,7 +114,7 @@ def get_subject(payload: Mapping[str, Any]) -> str: def get_body(payload: Mapping[str, Any], action_type: str) -> str: message_body = ACTIONS_TO_FILL_BODY_MAPPER[action_type](payload, action_type) creator = payload['action']['memberCreator'].get('fullName') - return u'{full_name} {rest}'.format(full_name=creator, rest=message_body) + return '{full_name} {rest}'.format(full_name=creator, rest=message_body) def get_added_checklist_body(payload: Mapping[str, Any], action_type: str) -> str: data = { @@ -215,7 +215,7 @@ def get_filled_card_url_template(payload: Mapping[str, Any]) -> str: return TRELLO_CARD_URL_TEMPLATE.format(card_name=get_card_name(payload), card_url=get_card_url(payload)) def get_card_url(payload: Mapping[str, Any]) -> str: - return u'https://trello.com/c/{}'.format(get_action_data(payload)['card'].get('shortLink')) + return 'https://trello.com/c/{}'.format(get_action_data(payload)['card'].get('shortLink')) def get_message_body(action_type: str) -> str: return ACTIONS_TO_MESSAGE_MAPPER[action_type] diff --git a/zerver/webhooks/updown/tests.py b/zerver/webhooks/updown/tests.py index 868105ebfe..2f0e6b3845 100644 --- a/zerver/webhooks/updown/tests.py +++ b/zerver/webhooks/updown/tests.py @@ -1,33 +1,32 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase class UpdownHookTests(WebhookTestCase): STREAM_NAME = 'updown' - URL_TEMPLATE = u"/api/v1/external/updown?stream={stream}&api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/updown?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'updown' def test_updown_check_down_event(self) -> None: - expected_topic = u"https://updown.io" - expected_message = u"Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC." + expected_topic = "https://updown.io" + expected_message = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC." self.send_and_test_stream_message('check_down_one_event', expected_topic, expected_message) def test_updown_check_up_again_event(self) -> None: - expected_topic = u"https://updown.io" - expected_message = u"Service is `up` again after 4 minutes 25 seconds." + expected_topic = "https://updown.io" + expected_message = "Service is `up` again after 4 minutes 25 seconds." self.send_and_test_stream_message('check_up_again_one_event', expected_topic, expected_message) def test_updown_check_up_event(self) -> None: - expected_topic = u"https://updown.io" - expected_message = u"Service is `up`." + expected_topic = "https://updown.io" + expected_message = "Service is `up`." self.send_and_test_stream_message('check_up_first_time', expected_topic, expected_message) def test_updown_check_up_multiple_events(self) -> None: - first_message_expected_topic = u"https://updown.io" - first_message_expected_message = u"Service is `up` again after 1 second." + first_message_expected_topic = "https://updown.io" + first_message_expected_message = "Service is `up` again after 1 second." - second_message_expected_topic = u"https://updown.io" - second_message_expected_message = u"Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC." + second_message_expected_topic = "https://updown.io" + second_message_expected_message = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC." self.send_and_test_stream_message('check_multiple_events') last_message = self.get_last_message() diff --git a/zerver/webhooks/wordpress/tests.py b/zerver/webhooks/wordpress/tests.py index c49e0c2b1b..60443c84b7 100644 --- a/zerver/webhooks/wordpress/tests.py +++ b/zerver/webhooks/wordpress/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -9,16 +8,16 @@ class WordPressHookTests(WebhookTestCase): def test_publish_post(self) -> None: - expected_topic = u"WordPress Post" - expected_message = u"New post published:\n* [New Blog Post](http://example.com\n)" + expected_topic = "WordPress Post" + expected_message = "New post published:\n* [New Blog Post](http://example.com\n)" self.send_and_test_stream_message('publish_post', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_publish_post_type_not_provided(self) -> None: - expected_topic = u"WordPress Post" - expected_message = u"New post published:\n* [New Blog Post](http://example.com\n)" + expected_topic = "WordPress Post" + expected_message = "New post published:\n* [New Blog Post](http://example.com\n)" self.send_and_test_stream_message('publish_post_type_not_provided', expected_topic, expected_message, @@ -27,8 +26,8 @@ class WordPressHookTests(WebhookTestCase): def test_publish_post_no_data_provided(self) -> None: # Note: the fixture includes 'hook=publish_post' because it's always added by HookPress - expected_topic = u"WordPress Notification" - expected_message = u"New post published:\n* [New WordPress Post](WordPress Post URL)" + expected_topic = "WordPress Notification" + expected_message = "New post published:\n* [New WordPress Post](WordPress Post URL)" self.send_and_test_stream_message('publish_post_no_data_provided', expected_topic, expected_message, @@ -36,24 +35,24 @@ class WordPressHookTests(WebhookTestCase): def test_publish_page(self) -> None: - expected_topic = u"WordPress Page" - expected_message = u"New page published:\n* [New Blog Page](http://example.com\n)" + expected_topic = "WordPress Page" + expected_message = "New page published:\n* [New Blog Page](http://example.com\n)" self.send_and_test_stream_message('publish_page', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_user_register(self) -> None: - expected_topic = u"New Blog Users" - expected_message = u"New blog user registered:\n* **Name**: test_user\n* **Email**: test_user@example.com" + expected_topic = "New Blog Users" + expected_message = "New blog user registered:\n* **Name**: test_user\n* **Email**: test_user@example.com" self.send_and_test_stream_message('user_register', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_wp_login(self) -> None: - expected_topic = u"New Login" - expected_message = u"User testuser logged in." + expected_topic = "New Login" + expected_message = "User testuser logged in." self.send_and_test_stream_message('wp_login', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/yo/tests.py b/zerver/webhooks/yo/tests.py index 411b935f12..aef2caf5df 100644 --- a/zerver/webhooks/yo/tests.py +++ b/zerver/webhooks/yo/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Any, Dict from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class YoHookTests(WebhookTestCase): STREAM_NAME = 'yo' - URL_TEMPLATE = u"/api/v1/external/yo?api_key={api_key}" + URL_TEMPLATE = "/api/v1/external/yo?api_key={api_key}" FIXTURE_DIR_NAME = 'yo' def test_yo_message(self) -> None: @@ -19,7 +18,7 @@ class YoHookTests(WebhookTestCase): username="IAGO", user_ip="127.0.0.1" ) - expected_message = u"Yo from IAGO" + expected_message = "Yo from IAGO" self.send_and_test_private_message('', expected_message=expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/zabbix/tests.py b/zerver/webhooks/zabbix/tests.py index 124244e140..d406390833 100644 --- a/zerver/webhooks/zabbix/tests.py +++ b/zerver/webhooks/zabbix/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.send_email import FromAddress from zerver.lib.test_classes import WebhookTestCase from zerver.models import Recipient @@ -7,15 +6,15 @@ from zerver.webhooks.zabbix.view import MISCONFIGURED_PAYLOAD_ERROR_MESSAGE class ZabbixHookTests(WebhookTestCase): STREAM_NAME = 'zabbix' - URL_TEMPLATE = u"/api/v1/external/zabbix?api_key={api_key}&stream={stream}" + URL_TEMPLATE = "/api/v1/external/zabbix?api_key={api_key}&stream={stream}" FIXTURE_DIR_NAME = 'zabbix' def test_zabbix_alert_message(self) -> None: """ Tests if zabbix alert is handled correctly """ - expected_topic = u"www.example.com" - expected_message = u"PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\n* Zabbix agent on www.example.com is unreachable for 5 minutes\n* Agent ping is Up (1)" + expected_topic = "www.example.com" + expected_message = "PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\n* Zabbix agent on www.example.com is unreachable for 5 minutes\n* Agent ping is Up (1)" self.send_and_test_stream_message('zabbix_alert', expected_topic, expected_message) def test_zabbix_invalid_payload_with_missing_data(self) -> None: diff --git a/zerver/webhooks/zapier/tests.py b/zerver/webhooks/zapier/tests.py index 2ede6fde9e..ed87901a81 100644 --- a/zerver/webhooks/zapier/tests.py +++ b/zerver/webhooks/zapier/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from zerver.lib.test_classes import WebhookTestCase @@ -8,18 +7,18 @@ class ZapierHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'zapier' def test_zapier_when_subject_and_body_are_correct(self) -> None: - expected_topic = u"New email from zulip@zulip.com" - expected_message = u"Your email content is: \nMy Email content." + expected_topic = "New email from zulip@zulip.com" + expected_message = "Your email content is: \nMy Email content." self.send_and_test_stream_message('correct_subject_and_body', expected_topic, expected_message) def test_zapier_when_topic_and_body_are_correct(self) -> None: - expected_topic = u"New email from zulip@zulip.com" - expected_message = u"Your email content is: \nMy Email content." + expected_topic = "New email from zulip@zulip.com" + expected_message = "Your email content is: \nMy Email content." self.send_and_test_stream_message('correct_topic_and_body', expected_topic, expected_message) def test_zapier_weather_update(self) -> None: - expected_topic = u"Here is your weather update for the day:" - expected_message = u"Foggy in the morning.\nMaximum temperature to be 24.\nMinimum temperature to be 12" + expected_topic = "Here is your weather update for the day:" + expected_message = "Foggy in the morning.\nMaximum temperature to be 24.\nMinimum temperature to be 12" self.send_and_test_stream_message('weather_update', expected_topic, expected_message) class ZapierZulipAppTests(WebhookTestCase): diff --git a/zerver/webhooks/zendesk/tests.py b/zerver/webhooks/zendesk/tests.py index d3c25fe029..ece248c8b5 100644 --- a/zerver/webhooks/zendesk/tests.py +++ b/zerver/webhooks/zendesk/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Any, Dict, Optional from zerver.lib.test_classes import WebhookTestCase @@ -6,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase class ZenDeskHookTests(WebhookTestCase): STREAM_NAME = 'zendesk' - URL_TEMPLATE = u"/api/v1/external/zendesk?stream={stream}" + URL_TEMPLATE = "/api/v1/external/zendesk?stream={stream}" DEFAULT_TICKET_TITLE = 'User can\'t login' TICKET_TITLE = DEFAULT_TICKET_TITLE diff --git a/zilencer/management/commands/add_mock_conversation.py b/zilencer/management/commands/add_mock_conversation.py index e63a5813ea..6c12bed1f7 100644 --- a/zilencer/management/commands/add_mock_conversation.py +++ b/zilencer/management/commands/add_mock_conversation.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from typing import Any, Dict, List from django.core.management.base import BaseCommand diff --git a/zilencer/management/commands/compare_messages.py b/zilencer/management/commands/compare_messages.py index bb941fdb89..2a9bcb285b 100644 --- a/zilencer/management/commands/compare_messages.py +++ b/zilencer/management/commands/compare_messages.py @@ -17,7 +17,7 @@ class Command(BaseCommand): def handle(self, *args: Any, **options: Any) -> None: total_count = 0 changed_count = 0 - with open(options['dump1'], 'r') as dump1, open(options['dump2'], 'r') as dump2: + with open(options['dump1']) as dump1, open(options['dump2']) as dump2: for m1, m2 in zip(ijson.items(dump1, 'item'), ijson.items(dump2, 'item')): total_count += 1 if m1['id'] != m2['id']: diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index a11c20f8ce..55e2d4c38f 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -488,7 +488,7 @@ class Command(BaseCommand): # in the config.generate_data.json data set. This makes it # possible for populate_db to run happily without Internet # access. - with open("zerver/tests/fixtures/docs_url_preview_data.json", "r") as f: + with open("zerver/tests/fixtures/docs_url_preview_data.json") as f: urls_with_preview_data = ujson.load(f) for url in urls_with_preview_data: cache_set(url, urls_with_preview_data[url], PREVIEW_CACHE_NAME) @@ -616,7 +616,7 @@ def generate_and_send_messages(data: Tuple[int, Sequence[Sequence[int]], Mapping random.seed(random_seed) with open(os.path.join(get_or_create_dev_uuid_var_path('test-backend'), - "test_messages.json"), "r") as infile: + "test_messages.json")) as infile: dialog = ujson.load(infile) random.shuffle(dialog) texts = itertools.cycle(dialog) diff --git a/zilencer/management/commands/sync_api_key.py b/zilencer/management/commands/sync_api_key.py index 0fa70f2183..6cfade03ac 100644 --- a/zilencer/management/commands/sync_api_key.py +++ b/zilencer/management/commands/sync_api_key.py @@ -15,7 +15,7 @@ class Command(BaseCommand): if not os.path.exists(config_file): raise RuntimeError("No ~/.zuliprc found") config = ConfigParser() - with open(config_file, 'r') as f: + with open(config_file) as f: config.read_file(f, config_file) api_key = config.get("api", "key") email = config.get("api", "email") diff --git a/zilencer/migrations/0001_initial.py b/zilencer/migrations/0001_initial.py index 4927dab49e..82c915365e 100644 --- a/zilencer/migrations/0001_initial.py +++ b/zilencer/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/zilencer/migrations/0002_remote_zulip_server.py b/zilencer/migrations/0002_remote_zulip_server.py index ad0c971274..9d47bbebb6 100644 --- a/zilencer/migrations/0002_remote_zulip_server.py +++ b/zilencer/migrations/0002_remote_zulip_server.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import django.db.models.deletion from django.db import migrations, models diff --git a/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py b/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py index 8d96d6bab8..242abdd7d1 100644 --- a/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py +++ b/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-16 00:03 from django.db import migrations, models diff --git a/zilencer/migrations/0004_remove_deployment_model.py b/zilencer/migrations/0004_remove_deployment_model.py index 90c5bccf89..bd7d4c6ce2 100644 --- a/zilencer/migrations/0004_remove_deployment_model.py +++ b/zilencer/migrations/0004_remove_deployment_model.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-12 06:27 from django.db import migrations diff --git a/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py b/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py index 9a4051ee0d..31febab24c 100644 --- a/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py +++ b/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2017-10-19 04:23 -from __future__ import unicode_literals from django.db import migrations, models @@ -24,6 +22,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='remotepushdevicetoken', - unique_together=set([('server', 'token')]), + unique_together={('server', 'token')}, ), ] diff --git a/zilencer/migrations/0006_customer.py b/zilencer/migrations/0006_customer.py index 366104d349..88ec1d3b6b 100644 --- a/zilencer/migrations/0006_customer.py +++ b/zilencer/migrations/0006_customer.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2018-01-13 11:54 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/zilencer/migrations/0007_remotezulipserver_fix_uniqueness.py b/zilencer/migrations/0007_remotezulipserver_fix_uniqueness.py index 5cd273685b..e112ec49b3 100644 --- a/zilencer/migrations/0007_remotezulipserver_fix_uniqueness.py +++ b/zilencer/migrations/0007_remotezulipserver_fix_uniqueness.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-30 06:55 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zilencer/migrations/0008_customer_billing_user.py b/zilencer/migrations/0008_customer_billing_user.py index e50467d911..40f978e9a9 100644 --- a/zilencer/migrations/0008_customer_billing_user.py +++ b/zilencer/migrations/0008_customer_billing_user.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-12 01:14 -from __future__ import unicode_literals import django.db.models.deletion from django.conf import settings diff --git a/zilencer/migrations/0009_plan.py b/zilencer/migrations/0009_plan.py index eea8955a7d..05c7356745 100644 --- a/zilencer/migrations/0009_plan.py +++ b/zilencer/migrations/0009_plan.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-04-12 01:19 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zilencer/migrations/0010_billingprocessor.py b/zilencer/migrations/0010_billingprocessor.py index 8d03877112..94090640ef 100644 --- a/zilencer/migrations/0010_billingprocessor.py +++ b/zilencer/migrations/0010_billingprocessor.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-13 23:15 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/zilencer/migrations/0011_customer_has_billing_relationship.py b/zilencer/migrations/0011_customer_has_billing_relationship.py index 84f875318d..8466f0a965 100644 --- a/zilencer/migrations/0011_customer_has_billing_relationship.py +++ b/zilencer/migrations/0011_customer_has_billing_relationship.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-14 01:32 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zilencer/migrations/0012_coupon.py b/zilencer/migrations/0012_coupon.py index 5c48547589..ab19661f81 100644 --- a/zilencer/migrations/0012_coupon.py +++ b/zilencer/migrations/0012_coupon.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-23 05:40 -from __future__ import unicode_literals from django.db import migrations, models diff --git a/zilencer/migrations/0013_remove_customer_billing_user.py b/zilencer/migrations/0013_remove_customer_billing_user.py index 546f3502b3..978da320e6 100644 --- a/zilencer/migrations/0013_remove_customer_billing_user.py +++ b/zilencer/migrations/0013_remove_customer_billing_user.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-08-22 06:31 -from __future__ import unicode_literals from django.db import migrations diff --git a/zilencer/migrations/0014_cleanup_pushdevicetoken.py b/zilencer/migrations/0014_cleanup_pushdevicetoken.py index 0ea4a94b3d..32851dcc2b 100644 --- a/zilencer/migrations/0014_cleanup_pushdevicetoken.py +++ b/zilencer/migrations/0014_cleanup_pushdevicetoken.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-10-10 22:52 -from __future__ import unicode_literals from django.db import migrations @@ -14,6 +12,6 @@ class Migration(migrations.Migration): operations = [ migrations.AlterUniqueTogether( name='remotepushdevicetoken', - unique_together=set([('server', 'user_id', 'kind', 'token')]), + unique_together={('server', 'user_id', 'kind', 'token')}, ), ] diff --git a/zilencer/migrations/0015_delete_billing.py b/zilencer/migrations/0015_delete_billing.py index 102245ac9d..b1f16c2fa0 100644 --- a/zilencer/migrations/0015_delete_billing.py +++ b/zilencer/migrations/0015_delete_billing.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.14 on 2018-09-25 12:01 -from __future__ import unicode_literals from django.db import migrations diff --git a/zilencer/migrations/0016_remote_counts.py b/zilencer/migrations/0016_remote_counts.py index 512cb4035c..207ce088c7 100644 --- a/zilencer/migrations/0016_remote_counts.py +++ b/zilencer/migrations/0016_remote_counts.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.18 on 2019-02-02 06:02 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models @@ -40,14 +38,14 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='remoterealmcount', - unique_together=set([('server', 'realm_id', 'property', 'subgroup', 'end_time')]), + unique_together={('server', 'realm_id', 'property', 'subgroup', 'end_time')}, ), migrations.AlterIndexTogether( name='remoterealmcount', - index_together=set([('property', 'end_time')]), + index_together={('property', 'end_time')}, ), migrations.AlterUniqueTogether( name='remoteinstallationcount', - unique_together=set([('server', 'property', 'subgroup', 'end_time')]), + unique_together={('server', 'property', 'subgroup', 'end_time')}, ), ] diff --git a/zilencer/migrations/0017_installationcount_indexes.py b/zilencer/migrations/0017_installationcount_indexes.py index abf7ec1fcb..19c8480765 100644 --- a/zilencer/migrations/0017_installationcount_indexes.py +++ b/zilencer/migrations/0017_installationcount_indexes.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-04-23 20:17 -from __future__ import unicode_literals from django.db import migrations @@ -14,10 +12,10 @@ class Migration(migrations.Migration): operations = [ migrations.AlterIndexTogether( name='remoteinstallationcount', - index_together=set([('server', 'remote_id')]), + index_together={('server', 'remote_id')}, ), migrations.AlterIndexTogether( name='remoterealmcount', - index_together=set([('property', 'end_time'), ('server', 'remote_id')]), + index_together={('property', 'end_time'), ('server', 'remote_id')}, ), ] diff --git a/zilencer/migrations/0018_remoterealmauditlog.py b/zilencer/migrations/0018_remoterealmauditlog.py index 0d8e23cb3d..7e24e25097 100644 --- a/zilencer/migrations/0018_remoterealmauditlog.py +++ b/zilencer/migrations/0018_remoterealmauditlog.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.11.24 on 2019-10-03 00:10 -from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models diff --git a/zproject/backends.py b/zproject/backends.py index 6423e84a8e..c67bfb8865 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -86,7 +86,7 @@ def auth_enabled_helper(backends_to_check: List[str], realm: Optional[Realm]) -> enabled_method_dict = realm.authentication_methods_dict() pad_method_dict(enabled_method_dict) else: - enabled_method_dict = dict((method, True) for method in Realm.AUTHENTICATION_FLAGS) + enabled_method_dict = {method: True for method in Realm.AUTHENTICATION_FLAGS} pad_method_dict(enabled_method_dict) for supported_backend in supported_auth_backends(): for backend_name in backends_to_check: diff --git a/zproject/config.py b/zproject/config.py index 67044a7971..f55c616c1c 100644 --- a/zproject/config.py +++ b/zproject/config.py @@ -41,7 +41,7 @@ def get_config(section: str, key: str, default_value: Optional[str]=None) -> Opt def get_from_file_if_exists(path: str) -> str: if os.path.exists(path): - with open(path, "r") as f: + with open(path) as f: return f.read() else: return '' diff --git a/zproject/email_backends.py b/zproject/email_backends.py index f852f94361..0c5257778e 100644 --- a/zproject/email_backends.py +++ b/zproject/email_backends.py @@ -79,7 +79,7 @@ class EmailLogBackEnd(BaseEmailBackend): # Read in the pre-existing log, so that we can add the new entry # at the top. try: - with open(settings.EMAIL_CONTENT_LOG_PATH, "r") as f: + with open(settings.EMAIL_CONTENT_LOG_PATH) as f: previous_emails = f.read() except FileNotFoundError: previous_emails = ""