sprintly/sprint.ly-services — pull request #17 by chrisforrette (2014-04-17 01:54:11+00:00)
Title: Slack post as attachment

#### What's this PR do?

It updates our Slack integration to use the [Attachments API](https://api.slack.com/docs/attachments) and leverages some more Slack-specific sugar in our posts.

#### Where should the reviewer start?

The meat of the changes in this PR are in the Slack service class (mostly with activity-type-specific formatting methods) here: `lookout/services/slack.py`

#### How should this be manually tested?

Each type of post can be relatively easily tested using a Python shell and the fixtures used for testing. Slack Webhook Integrations live here: `https://(your-company-name).slack.com/services`, where you can create an "Incoming Webhook" integration or use an existing one. With your Incoming Webhook integration you'll get a URL that looks something like this: `https://(your-company-here).slack.com/services/hooks/incoming-webhook?token=abcdefg...`.

From this project's directory, make sure you have the requirements in `requirements.txt` installed, open a Python shell and do the following to test:

```python
from lookout.services.slack import Service
from tests.fixtures import fake_comment_payload, fake_item_payload, fake_block_payload, fake_favorite_payload, fake_deploy_payload

url = '(the URL you got from your Incoming Webhook integration above)'
srv = Service({'url': url})

srv.send(fake_comment_payload)
srv.send(fake_item_payload)
srv.send(fake_block_payload)
srv.send(fake_favorite_payload)
srv.send(fake_deploy_payload)
```

This will create posts for each test payload to whatever channel you specify in your Incoming Webhook integration configuration.

#### Any background context you want to provide?

Slack recommended this update.

#### What are the relevant tickets?

[#6867](https://sprint.ly/product/1/#!/item/6867)

Fixes #6867

#### Screenshots (if appropriate)

What the posts look like in chat—note that I used item type colors for the color bar on the left where applicable.

Item creation:

![screen shot 2014-04-16 at 6 31 35 pm](https://cloud.githubusercontent.com/assets/126919/2727346/18d7453e-c5d2-11e3-85bb-40001a6978c7.png)

Comment:

![screen shot 2014-04-16 at 6 32 26 pm](https://cloud.githubusercontent.com/assets/126919/2727344/18d708d0-c5d2-11e3-96d4-a9a34939d18b.png)

Favorite:

![screen shot 2014-04-16 at 6 32 44 pm](https://cloud.githubusercontent.com/assets/126919/2727345/18d71fa0-c5d2-11e3-8e9b-a8eba95be5a9.png)

Block:

![screen shot 2014-04-16 at 6 33 01 pm](https://cloud.githubusercontent.com/assets/126919/2727343/18d695f8-c5d2-11e3-8398-08bbd9b944f5.png)

Deploy:

![screen shot 2014-04-16 at 6 33 10 pm](https://cloud.githubusercontent.com/assets/126919/2727347/18d7d698-c5d2-11e3-8009-b55ce846fa22.png)

#### Questions:
- Is there a blog post? No, but I will write a blog post about our Slack integration once this is up and live.
- Does the knowledge base need an update? I'm not sure how specific it is, but we might want to add some updated screenshots cc/ @ppalmares @jasonrehmus
- Does this add new (Python) dependencies which need to be added to chef? No
- Does this add migrations and (if so) have you validated they are backwards compatible? N/A