Beispiel #1
0
def test_slack_locale(monkeypatch):
    patch_locale(monkeypatch, 'ru')
    responses.add(responses.POST, 'http://slack.hook/')

    post2slack([Review(
        id=u'34e56344☃',
        platform='ios',
        title=u'Great app! ♡',
        rating=5,
        summary=u'NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨ',
        url=u'http://www',
        author=u'Here comes more BS',
        date=datetime.datetime(2015, 1, 1, 6),
        language=None,
        version='2.1.3'
    )], 'http://slack.hook/', channel=None)

    assert len(responses.calls) == 1
    request = responses.calls[0].request
    assert request.url == 'http://slack.hook/'
    assert json.loads(parse_qs(request.body)['payload'][0]) == {
        u'username': u'Критик',
        u'text': u'В AppStore 1 новый отзыв',
        u'attachments': [{
            u'color': u'#30E80C',
            u'text': u'★★★★★\nNOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨ\n\n_Here comes more BS_, 1 января 2015 06:00 [2.1.3]',  # noqa
            u'title_link': u'http://www',
            u'mrkdwn_in': [u'text'],
            u'title': u'Great app! \u2661'}
        ],
        u'icon_emoji': u':godmode:'}
Beispiel #2
0
def test_slack(monkeypatch):
    patch_locale(monkeypatch, 'en')
    responses.add(responses.POST, 'http://slack.hook/')

    post2slack([Review(
        id=u'gp:AOqpTOGVTpUWQyZJhCbF6dpGfgWnmaj992am2upoCj8Iur1YoNKubAlN_W_BzRYHGh7pdxAe-HDIdOUEvaRfpw',
        platform='android',
        title=u'',
        rating=1,
        summary=u'dffdf\nfgf4tt',
        url=u'http://www',
        author=u'Someauthor',
        date=datetime.datetime(2015, 1, 1, 6),
        language='ru',
        version=None
    )], 'http://slack.hook/', channel=None)

    assert json.loads(parse_qs(responses.calls[0].request.body)['payload'][0]) == {
        u'username': u'Critic',
        u'text': u'There is 1 new review in Google Play',
        u'attachments': [{
            u'color': u'#CC2525',
            u'text': u'★☆☆☆☆\ndffdf\nfgf4tt\n\n_Someauthor_, 1 January 2015 06:00 ',
            u'title_link': u'http://www',
            u'mrkdwn_in': [u'text'],
            u'title': u'-'}
        ],
        u'icon_emoji': u':feelsgood:'}
Beispiel #3
0
def test_slack_locale(monkeypatch):
    patch_locale(monkeypatch, 'ru')
    responses.add(responses.POST, 'http://slack.hook/')

    post2slack([
        Review(
            id=u'34e56344☃',
            platform='ios',
            title=u'Great app! ♡',
            rating=5,
            summary=u'NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨ',
            url=u'http://www',
            author=u'Here comes more BS',
            date=datetime.datetime(2015, 1, 1, 6),
            language=None,
            version='2.1.3')
    ],
               'http://slack.hook/',
               channel=None)

    assert len(responses.calls) == 1
    request = responses.calls[0].request
    assert request.url == 'http://slack.hook/'
    assert json.loads(parse_qs(request.body)['payload'][0]) == {
        u'username':
        u'Критик',
        u'text':
        u'В AppStore 1 новый отзыв',
        u'attachments': [{
            u'color': u'#30E80C',
            u'text':
            u'★★★★★\nNOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨ\n\n_Here comes more BS_, 1 января 2015 06:00 [2.1.3]',  # noqa
            u'title_link': u'http://www',
            u'mrkdwn_in': [u'text'],
            u'title': u'Great app! \u2661'
        }],
        u'icon_emoji':
        u':godmode:'
    }
Beispiel #4
0
def test_slack(monkeypatch):
    patch_locale(monkeypatch, 'en')
    responses.add(responses.POST, 'http://slack.hook/')

    post2slack([
        Review(
            id=
            u'gp:AOqpTOGVTpUWQyZJhCbF6dpGfgWnmaj992am2upoCj8Iur1YoNKubAlN_W_BzRYHGh7pdxAe-HDIdOUEvaRfpw',
            platform='android',
            title=u'',
            rating=1,
            summary=u'dffdf\nfgf4tt',
            url=u'http://www',
            author=u'Someauthor',
            date=datetime.datetime(2015, 1, 1, 6),
            language='ru',
            version=None)
    ],
               'http://slack.hook/',
               channel=None)

    assert json.loads(parse_qs(
        responses.calls[0].request.body)['payload'][0]) == {
            u'username':
            u'Critic',
            u'text':
            u'There is 1 new review in Google Play',
            u'attachments': [{
                u'color': u'#CC2525',
                u'text':
                u'★☆☆☆☆\ndffdf\nfgf4tt\n\n_Someauthor_, 1 January 2015 06:00 ',
                u'title_link': u'http://www',
                u'mrkdwn_in': [u'text'],
                u'title': u'-'
            }],
            u'icon_emoji':
            u':feelsgood:'
        }