streams: refactor stream creation code path.

Refactor list_to_streams and create_streams_if_needed to take a list
of dictionaries, instead of a list of stream names.  This is
preparation for being able to pass additional arguments into the
stream creation process.

An important note: This removes a set of validation code from the
start of add_subscriptions_backend; doing so is correct because
list_to_streams has that same validation code already.

[with some tweaks by tabbott for clarity]
This commit is contained in:
Calvin Lee
2016-11-20 15:55:50 -05:00
committed by Tim Abbott
parent 308069d828
commit 8461cc411e
3 changed files with 41 additions and 26 deletions

View File

@@ -63,7 +63,7 @@ class TestCreateStreams(ZulipTestCase):
new_streams, existing_streams = create_streams_if_needed(
realm,
stream_names,
[{"name": stream_name} for stream_name in stream_names],
invite_only=True)
self.assertEqual(len(new_streams), 3)
self.assertEqual(len(existing_streams), 0)
@@ -73,7 +73,7 @@ class TestCreateStreams(ZulipTestCase):
new_streams, existing_streams = create_streams_if_needed(
realm,
stream_names,
[{"name": stream_name} for stream_name in stream_names],
invite_only=True)
self.assertEqual(len(new_streams), 0)
self.assertEqual(len(existing_streams), 3)