Mateusz Mandera
d5b450c1e0
import: Fix the import of authentication_methods BitField.
...
The ordering of bits that fix_realm_authentication_bitfield was making
was incorrect, it needs to be reversed.
2022-08-29 11:10:18 -07:00
Mateusz Mandera
3ff0b64281
test_import_export: Use get_output_dir() helper.
...
That's much briefer and cleaner than repeating the os.path.join
expression and the helper already exists.
2022-08-29 10:39:14 -07:00
Mateusz Mandera
ac9e927989
import_realm: Validate emails of users being imported.
...
Having users with malformed email addresses in our database can lead to
hard to debug issues and we really should try to prevent that.
2022-08-29 10:39:14 -07:00
Zixuan James Li
97fd662d48
test_import_export: Enhance typing of getters.
...
This fixes the type annotations of `Set` derived from `QuerySet` objects,
and add necessary assertions.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-26 18:00:24 -07:00
Zixuan James Li
7c62af0d73
typing: Add assertions before accessing settings.
...
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-15 14:00:56 -07:00
Mateusz Mandera
e6264cd85b
test_import_export: Test exclusion of private uploads from realm export.
2022-07-12 06:08:07 +00:00
Zixuan James Li
5a934ef39f
test_import_export: Tighten function signatures with generic QuerySet.
...
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-07 11:28:13 -07:00
Zixuan James Li
ab1bbdda65
typing: Broaden type annotations for QuerySet compatibility.
...
To explain the rationale of this change, for example, there is
`get_user_activity_summary` which accepts either a `Collection[UserActivity]`,
where `QuerySet[T]` is not strictly `Sequence[T]` because its slicing behavior
is different from the `Protocol`, making `Collection` necessary.
Similarily, we should have `Iterable[T]` instead of `List[T]` so that
`QuerySet[T]` will also be an acceptable subtype, or `Sequence[T]` when we
also expect it to be indexed.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2022-07-07 11:27:42 -07:00
Anders Kaseorg
df69e1d979
mypy: Enable truthy-bool errors.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-06-23 19:22:12 -07:00
Zixuan James Li
c572d9be5a
typing: Add none-checks for db queries.
...
Signed-off-by: Zixuan James Li <359101898@qq.com>
2022-05-31 09:43:55 -07:00
Zixuan James Li
bb6a934c8d
typing: Add appropriate none-checks for LOCAL_UPLOADS_DIR.
...
This is a part of django-stubs refactorings.
Signed-off-by: Zixuan James Li <359101898@qq.com>
2022-05-31 09:43:55 -07:00
Zixuan James Li
63e9ae8389
typing: Apply trivial fixes to adjust edge cases in typing.
...
Add none-checks, rename variables (to avoid redefinition of
the same variable with different types error), add necessary
type annotations.
This is a part of #18777 .
Signed-off-by: Zixuan James Li <359101898@qq.com>
2022-05-30 12:03:51 -07:00
Anders Kaseorg
59f6b090c7
actions: Split out zerver.actions.realm_settings.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:37 -07:00
Anders Kaseorg
5d1a5a3877
actions: Split out zerver.actions.muted_users.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:36 -07:00
Anders Kaseorg
e5500a2226
actions: Split out zerver.actions.reactions.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:35 -07:00
Anders Kaseorg
cbad5739ab
actions: Split out zerver.actions.create_user.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:35 -07:00
Anders Kaseorg
d7981dad62
actions: Split out zerver.actions.users.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:34 -07:00
Anders Kaseorg
bbce879c81
actions: Split out zerver.actions.custom_profile_fields.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:33 -07:00
Anders Kaseorg
b7adfb02f6
actions: Split out zerver.actions.presence.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:32 -07:00
Anders Kaseorg
6168c0110a
actions: Split out zerver.actions.user_activity.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:32 -07:00
Anders Kaseorg
df4849bb15
actions: Split out zerver.actions.user_topics.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:32 -07:00
Anders Kaseorg
385616f27f
actions: Split out zerver.actions.realm_emoji.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:31 -07:00
Anders Kaseorg
3d7aa98c45
actions: Split out zerver.actions.realm_icon.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:31 -07:00
Anders Kaseorg
7f088f3403
actions: Split out zerver.actions.realm_logo.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:31 -07:00
Anders Kaseorg
241463e215
actions: Split out zerver.actions.alert_words.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:31 -07:00
Kartik Srivastava
eefaa9120f
user_topic: Rename topic_mutes.py to user_topics.py.
2022-03-11 14:26:55 -08:00
Mateusz Mandera
c6be15908c
import: Ensure that .author gets set when importing RealmEmoji.
...
Sometimes we may get data to import, due to export bugs, malformed data
etc., which doesn't have the invariant of RealmEmoji.author always being
set. The import code should fix that, by choosing a reasonable default
and setting it.
2022-02-11 18:21:38 +01:00
Steve Howell
3138f7a73c
mypy: Fix content types.
...
This got by mypy due to Message being an Any type.
2021-12-16 20:35:56 -05:00
Steve Howell
0b0faa46b4
mypy: Use object type for checker return values.
2021-12-16 19:52:35 -05:00
Steve Howell
16db496871
export tests: Verify files for single-user exports.
2021-12-13 12:29:19 -08:00
Steve Howell
3c63ebde15
export tests: Extract ExportFile class.
...
This is just moving code around.
2021-12-13 12:29:19 -08:00
Steve Howell
eb0114cdee
export tests: Add verify_attachment_json.
...
This allows verify_uploads to use the database
as the authoritative source for what attachments
we need to look for when we're verifying the
images got exported properly, while still
also verifying attachment.json is correct.
2021-12-13 12:29:19 -08:00
Steve Howell
24009cb7d3
export tests: Clean up emoji setup.
...
We can't use the normal RealmEmoji from the
test database.
Also, we now use an actual action function to
set up emojis for our own purposes.
2021-12-13 12:29:17 -08:00
Steve Howell
c6cdf98b66
export tests: Rename method to export_realm.
2021-12-13 12:25:19 -08:00
Steve Howell
c79c95d55e
export tests: Split function for uploading files.
...
This will give us flexibility for the single-user
tests.
2021-12-13 12:25:19 -08:00
Steve Howell
a215a14c00
export tests: Use verify_uploads() for s3, too.
2021-12-13 12:25:19 -08:00
Steve Howell
3f5c15320b
export tests: Extract verify_uploads.
2021-12-13 12:25:19 -08:00
Steve Howell
6b5a90bbd1
tests: Extract verify_emojis.
2021-12-13 12:25:19 -08:00
Steve Howell
302ef32c5b
export tests: Extract verify_realm_logo_and_icon.
2021-12-13 12:25:19 -08:00
Steve Howell
b4c089d3b8
export tests: Improve how we check avatars.
...
We avoid code duplication, and we iterate
over all records to see if files exist.
2021-12-13 12:25:19 -08:00
Steve Howell
0c02d89bf3
export tests: Avoid passing back path_id from setup.
2021-12-13 12:25:19 -08:00
Steve Howell
d3ea369057
export tests: Clean up emoji checks.
2021-12-13 12:25:19 -08:00
Steve Howell
fd94ba1579
tests: Avoid returning original_avatar_path_id.
...
The way we check for avatars is kind of clumsy for
realms. Ideally we would just check all users
in the realm.
2021-12-13 12:25:19 -08:00
Steve Howell
dbf1ae989d
tests: Avoid relying on setup data (test_image).
...
It is better for the verifying code to just explicitly
ensure that the exported file bytes match the bytes
in the test image. This introduces a tiny bit more
of I/O.
2021-12-13 12:25:19 -08:00
Steve Howell
53ffb8152f
tests: Use read_test_image_file helper.
2021-12-13 12:25:19 -08:00
Steve Howell
186c446458
tests: Create export files for specific user.
...
We no longer hackily look for the first message ever
sent within the realm.
2021-12-13 12:25:19 -08:00
Steve Howell
2debb5e5e6
tests: Add assertions for upload path_ids.
2021-12-13 12:25:19 -08:00
Steve Howell
035c90df68
export tests: Avoid full_data concept.
...
It's easier to read the code without the intermediate
full_data dictionary that obscures where the files live.
We also avoid some unnecessary file i/o in the tests.
2021-12-13 12:25:19 -08:00
Steve Howell
275653ad2a
tests: Move helpers to module level.
...
(This is a pure code move apart from removing "self"
in a few places.)
2021-12-13 12:25:19 -08:00
Steve Howell
6e3e3a7bff
export tests: Remove unnecessary setUp method.
...
I cargo-culted this in a recent commit.
2021-12-13 12:25:11 -08:00