Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
More convenient channel creation in app tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Dec 19, 2013
1 parent 6a7b8d6 commit 46eefc5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 37 deletions.
20 changes: 5 additions & 15 deletions go/apps/bulk_message/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def test_show_running(self):
Test showing the conversation
"""
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
name=u"myconv", started=True, channel=channel, groups=[group])
response = self.client.get(conv_helper.get_view_url('show'))
Expand All @@ -45,9 +43,7 @@ def test_show_running(self):

def test_action_bulk_send_view(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=True, channel=channel, groups=[group])
response = self.client.get(
Expand Down Expand Up @@ -101,9 +97,7 @@ def test_action_bulk_send_no_channel(self):

def test_action_bulk_send_dedupe(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=True, channel=channel, groups=[group])
response = self.client.post(
Expand All @@ -123,9 +117,7 @@ def test_action_bulk_send_dedupe(self):

def test_action_bulk_send_no_dedupe(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=True, channel=channel, groups=[group])
response = self.client.post(
Expand Down Expand Up @@ -156,9 +148,7 @@ def test_action_bulk_send_confirm(self):

# Start the conversation
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=True, channel=channel, groups=[group])

Expand Down
5 changes: 2 additions & 3 deletions go/apps/dialogue/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ def setup_conversation(self, with_group=True, with_channel=True, **kw):
self.app_helper.create_group_with_contacts(u'test_group', 0))
channel = None
if with_channel:
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(
supports_generic_sends=True)
return self.app_helper.create_conversation(
channel=channel, groups=groups, **kw)

Expand Down
24 changes: 6 additions & 18 deletions go/apps/surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ def create_poll(self, conversation, **kwargs):

def test_action_send_survey_get(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
name=u"myconv", started=True, channel=channel, groups=[group])
response = self.client.get(
Expand All @@ -38,9 +36,7 @@ def test_action_send_survey_get(self):

def test_action_send_survey_post(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=True, channel=channel, groups=[group])
response = self.client.post(
Expand All @@ -57,9 +53,7 @@ def test_action_send_survey_post(self):
delivery_class=conversation.delivery_class))

def test_action_send_survey_no_group(self):
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=True, channel=channel)
response = self.client.post(
Expand All @@ -72,9 +66,7 @@ def test_action_send_survey_no_group(self):

def test_action_send_survey_not_running(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
started=False, channel=channel, groups=[group])
response = self.client.post(
Expand Down Expand Up @@ -116,9 +108,7 @@ def test_show_running(self):
Test showing the conversation
"""
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
name=u"myconv", started=True, channel=channel, groups=[group])
response = self.client.get(conv_helper.get_view_url('show'))
Expand Down Expand Up @@ -174,9 +164,7 @@ def test_edit_continue_editing(self):

def test_action_export_user_data_get(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel({
"supports": {"generic_sends": True},
})
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
name=u"myconv", started=True, channel=channel, groups=[group])
response = self.client.get(
Expand Down
7 changes: 6 additions & 1 deletion go/apps/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ def create_conversation(self, started=False, channel=None, **conv_kw):

@proxyable
@maybe_async
def create_channel(self, metadata=None):
def create_channel(self, metadata=None, supports_generic_sends=None):
if supports_generic_sends is not None:
if metadata is None:
metadata = {}
supports = metadata.setdefault('supports', {})
supports['generic_sends'] = supports_generic_sends
yield self.vumi_helper.setup_tagpool(u"pool", [u"tag"], metadata)
user_helper = yield self.vumi_helper.get_or_create_user()
yield user_helper.add_tagpool_permission(u"pool")
Expand Down

0 comments on commit 46eefc5

Please sign in to comment.