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

Commit

Permalink
Get rid of ill-advised conversation helper wrapping silliness.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Dec 19, 2013
1 parent 2224442 commit 245c5d7
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 57 deletions.
20 changes: 11 additions & 9 deletions go/apps/bulk_message/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
conversation = response.context[0].get('conversation')
self.assertEqual(conversation.name, u"myconv")
Expand All @@ -32,7 +33,7 @@ def test_show_running(self):
"""
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
channel = self.app_helper.create_channel(supports_generic_sends=True)
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True, channel=channel, groups=[group])
response = self.client.get(conv_helper.get_view_url('show'))
conversation = response.context[0].get('conversation')
Expand All @@ -44,7 +45,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)
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
started=True, channel=channel, groups=[group])
response = self.client.get(
conv_helper.get_action_view_url('bulk_send'))
Expand All @@ -54,7 +55,7 @@ def test_action_bulk_send_view(self):
self.assertContains(response, '>Send message</button>')

def test_action_bulk_send_no_group(self):
conv_helper = self.app_helper.create_conversation(started=True)
conv_helper = self.app_helper.create_conversation_helper(started=True)
response = self.client.post(
conv_helper.get_action_view_url('bulk_send'),
{'message': 'I am ham, not spam.', 'dedupe': True},
Expand All @@ -67,7 +68,8 @@ def test_action_bulk_send_no_group(self):

def test_action_bulk_send_not_running(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
conv_helper = self.app_helper.create_conversation(groups=[group])
conv_helper = self.app_helper.create_conversation_helper(
groups=[group])
response = self.client.post(
conv_helper.get_action_view_url('bulk_send'),
{'message': 'I am ham, not spam.', 'dedupe': True},
Expand All @@ -81,7 +83,7 @@ def test_action_bulk_send_not_running(self):

def test_action_bulk_send_no_channel(self):
group = self.app_helper.create_group_with_contacts(u'test_group', 0)
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
started=True, groups=[group])
response = self.client.post(
conv_helper.get_action_view_url('bulk_send'),
Expand All @@ -98,7 +100,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)
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
started=True, channel=channel, groups=[group])
response = self.client.post(
conv_helper.get_action_view_url('bulk_send'),
Expand All @@ -118,7 +120,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)
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
started=True, channel=channel, groups=[group])
response = self.client.post(
conv_helper.get_action_view_url('bulk_send'),
Expand Down Expand Up @@ -149,7 +151,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)
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
started=True, channel=channel, groups=[group])

# POST the action with a mock token manager
Expand Down
2 changes: 1 addition & 1 deletion go/apps/dialogue/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup_conversation(self, with_group=True, with_channel=True, **kw):
if with_channel:
channel = self.app_helper.create_channel(
supports_generic_sends=True)
return self.app_helper.create_conversation(
return self.app_helper.create_conversation_helper(
channel=channel, groups=groups, **kw)

def test_action_send_dialogue_get(self):
Expand Down
7 changes: 4 additions & 3 deletions go/apps/http_api/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_show_running(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_edit_view(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
conversation = conv_helper.get_conversation()
self.assertEqual(conversation.config, {})
response = self.client.post(conv_helper.get_view_url('edit'), {
Expand Down
9 changes: 5 additions & 4 deletions go/apps/http_api_nostream/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_show_running(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_edit_view(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
conversation = conv_helper.get_conversation()
self.assertEqual(conversation.config, {})
response = self.client.post(conv_helper.get_view_url('edit'), {
Expand All @@ -50,7 +51,7 @@ def test_edit_view(self):
self.assertEqual(response.status_code, 200)

def test_get_edit_view_no_config(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
conversation = conv_helper.get_conversation()
self.assertEqual(conversation.config, {})
response = self.client.get(conv_helper.get_view_url('edit'))
Expand Down
17 changes: 9 additions & 8 deletions go/apps/jsbox/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ def setUp(self):
self.client = self.app_helper.get_client()

def test_show_stopped(self):
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
conversation = response.context[0].get('conversation')
self.assertEqual(conversation.name, u"myconv")
self.assertContains(response, '<h1>myconv</h1>')

def test_show_running(self):
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
conversation = response.context[0].get('conversation')
self.assertEqual(conversation.name, u"myconv")
self.assertContains(response, '<h1>myconv</h1>')

def setup_and_save_conversation(self, app_config):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
# render the form
response = self.client.get(conv_helper.get_view_url('edit'))
self.assertEqual(response.status_code, 200)
Expand Down Expand Up @@ -84,7 +85,7 @@ def test_edit_conversation_with_extra_endpoints(self):
self.assertEqual(list(conversation.extra_endpoints), ['foo:bar'])

def test_jsbox_logs(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
campaign_key = conv_helper.get_conversation().user_account.key
log_manager = LogManager(
self.app_helper.vumi_helper.get_vumi_api().redis)
Expand All @@ -97,19 +98,19 @@ def test_jsbox_logs(self):
self.assertContains(response, "INFO] test %d" % i)

def test_jsbox_empty_logs(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
response = self.client.get(conv_helper.get_view_url('jsbox_logs'))
self.assertEqual(response.status_code, 200)
self.assertContains(response, "No logs yet.")

def test_jsbox_logs_action(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
response = self.client.get(
conv_helper.get_action_view_url('view_logs'))
self.assertRedirects(response, conv_helper.get_view_url('jsbox_logs'))

def test_jsbox_report_layout_building(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
conversation = conv_helper.get_conversation()
conversation.config['jsbox_app_config'] = {
'reports': {
Expand Down Expand Up @@ -141,7 +142,7 @@ def test_jsbox_report_layout_building(self):
}])

def test_jsbox_report_layout_building_for_no_report_config(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
conversation = conv_helper.get_conversation()

default_reports_view = ConversationReportsView()
Expand Down
6 changes: 4 additions & 2 deletions go/apps/multi_surveys/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ def test_show(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
conversation = response.context[0].get('conversation')
self.assertEqual(conversation.name, 'myconv')

def test_export_messages(self):
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
msgs = conv_helper.add_stored_inbound(
5, start_date=date(2012, 1, 1), time_multiplier=12)
conversation = conv_helper.get_conversation()
Expand Down
5 changes: 3 additions & 2 deletions go/apps/opt_out/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_show_running(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")
7 changes: 4 additions & 3 deletions go/apps/sequential_send/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_show_running(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_edit_conversation_schedule_config(self):
conv_helper = self.app_helper.create_conversation(started=True)
conv_helper = self.app_helper.create_conversation_helper(started=True)
self.assertEqual(conv_helper.get_conversation().config, {})
response = self.client.post(conv_helper.get_view_url('edit'), {
'schedule-recurring': ['daily'],
Expand Down
11 changes: 6 additions & 5 deletions go/apps/static_reply/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,34 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_show_running(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_get_edit_empty_config(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
response = self.client.get(conv_helper.get_view_url('edit'))
self.assertEqual(response.status_code, 200)

def test_get_edit_small_config(self):
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
{'reply_text': 'hello'})
response = self.client.get(conv_helper.get_view_url('edit'))
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'hello')

def test_edit_config(self):
conv_helper = self.app_helper.create_conversation()
conv_helper = self.app_helper.create_conversation_helper()
conv = conv_helper.get_conversation()
self.assertEqual(conv.config, {})
response = self.client.post(conv_helper.get_view_url('edit'), {
Expand Down
5 changes: 3 additions & 2 deletions go/apps/subscription/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ def test_show_stopped(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(name=u"myconv")
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv")
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")

def test_show_running(self):
"""
Test showing the conversation
"""
conv_helper = self.app_helper.create_conversation(
conv_helper = self.app_helper.create_conversation_helper(
name=u"myconv", started=True)
response = self.client.get(conv_helper.get_view_url('show'))
self.assertContains(response, u"<h1>myconv</h1>")
Expand Down
Loading

0 comments on commit 245c5d7

Please sign in to comment.