Skip to content

Commit

Permalink
[bug 964568] Pass question tags to zendesk.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Mar 18, 2014
1 parent 0b5ea06 commit 9be0e09
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion kitsune/questions/forms.py
Expand Up @@ -354,7 +354,8 @@ def submit_ticket(self):
email,
self.cleaned_data['category'],
self.cleaned_data['subject'],
self.ticket_body)
self.ticket_body,
[])


class MarketplaceAaqForm(BaseZendeskForm):
Expand Down
3 changes: 2 additions & 1 deletion kitsune/questions/marketplace.py
Expand Up @@ -38,7 +38,7 @@ def get_zendesk():
zendesk_url, zendesk_email, zendesk_password, api_version=2)


def submit_ticket(email, category, subject, body):
def submit_ticket(email, category, subject, body, tags):
"""Submit a marketplace ticket to Zendesk.
:arg email: user's email address
Expand All @@ -56,6 +56,7 @@ def submit_ticket(email, category, subject, body):
'subject': settings.ZENDESK_SUBJECT_PREFIX + subject,
'description': body,
'set_tags': category,
'tags': tags,
}
}
try:
Expand Down
3 changes: 2 additions & 1 deletion kitsune/questions/tasks.py
Expand Up @@ -183,7 +183,8 @@ def escalate_question(question_id):
category='Escalated',
subject=u'[Escalated] {title}'.format(title=question.title),
body=u'{url}\n\n{content}'.format(url=url,
content=question.content))
content=question.content),
tags=[t.slug for t in question.tags.all()])
except ZendeskError:
# This is unpickleable, so we need to unwrap it a bit
raise PickleableZendeskError()
11 changes: 6 additions & 5 deletions kitsune/questions/tests/test_marketplace.py
Expand Up @@ -74,7 +74,7 @@ def test_submit_ticket(self, submit_ticket):
{'subject': subject, 'body': body, 'category': cat},
args=['account'])
eq_(200, response.status_code)
submit_ticket.assert_called_with(self.user.email, cat, subject, body)
submit_ticket.assert_called_with(self.user.email, cat, subject, body, [])

@mock.patch.object(kitsune.questions.forms, 'submit_ticket')
def test_submit_ticket_anon(self, submit_ticket):
Expand All @@ -91,7 +91,7 @@ def test_submit_ticket_anon(self, submit_ticket):
'email': email},
args=['account'])
eq_(200, response.status_code)
submit_ticket.assert_called_with(email, cat, subject, body)
submit_ticket.assert_called_with(email, cat, subject, body, [])

@mock.patch.object(kitsune.questions.forms, 'submit_ticket')
def test_submit_refund_request(self, submit_ticket):
Expand All @@ -107,7 +107,7 @@ def test_submit_refund_request(self, submit_ticket):
'transaction_id': transaction_id})
eq_(200, response.status_code)
body = 'Transaction ID: qwerty12345\nCategory: Defective\nNOW!!'
submit_ticket.assert_called_with(self.user.email, cat, subject, body)
submit_ticket.assert_called_with(self.user.email, cat, subject, body, [])

@mock.patch.object(kitsune.questions.forms, 'submit_ticket')
def test_submit_developer_request(self, submit_ticket):
Expand All @@ -121,7 +121,7 @@ def test_submit_developer_request(self, submit_ticket):
{'subject': subject, 'body': body, 'category': cat})
eq_(200, response.status_code)
body = 'Category: Review Process\nPLEASE!!'
submit_ticket.assert_called_with(self.user.email, cat, subject, body)
submit_ticket.assert_called_with(self.user.email, cat, subject, body, [])


class FauxZendesk(Zendesk):
Expand All @@ -142,11 +142,12 @@ def test_submit_ticket(self, get_zendesk):
zd = FauxZendesk('https://appsmarket.zendesk.com', 'x@y.z', 'pwd')
get_zendesk.return_value = zd

submit_ticket('a@b.c', 'cat', 'subject', 'description')
submit_ticket('a@b.c', 'cat', 'subject', 'description', ['tag1', 'tag2'])
zd.client.request.assert_called_with(
'https://appsmarket.zendesk.com/tickets.json?',
'POST',
body='{"ticket": {"requester_email": "a@b.c", "set_tags": "cat", '
'"tags": ["tag1", "tag2"], '
'"description": "description", '
'"subject": "[TEST] subject"}}',
headers={
Expand Down
3 changes: 2 additions & 1 deletion kitsune/questions/tests/test_templates.py
Expand Up @@ -972,7 +972,8 @@ def test_escalate_tag(self, get_current, submit_ticket):
category='Escalated',
subject=u'[Escalated] {title}'.format(title=self.question.title),
body=u'{url}\n\n{content}'.format(
url=question_url, content=self.question.content))
url=question_url, content=self.question.content),
tags=['escalate'])


class TaggingViewTestsAsAdmin(TestCaseBase):
Expand Down

0 comments on commit 9be0e09

Please sign in to comment.