Exemplo n.º 1
0
def test_facebook_button():
    fb = Facebook()
    s = stack(ButtonTemplate('foo', [UrlButton('foo', 'https://example.com')]))

    with patch.object(fb, '_send', return_value=instant_run()) as mock_send:
        run(fb.send(None, s))
        mock_send.assert_called_once_with(
            None, {
                'attachment': {
                    'type': 'template',
                    'payload': {
                        'template_type':
                        'button',
                        'text':
                        'foo',
                        'buttons': [
                            {
                                'type': 'web_url',
                                'title': 'foo',
                                'url': 'https://example.com'
                            },
                        ],
                    },
                },
            }, s)
Exemplo n.º 2
0
def test_telegram_sleep():
    duration = 0.001
    tg = Telegram()
    s = stack(Sleep(duration))

    start = time()
    # noinspection PyTypeChecker
    run(tg.send(None, s))
    stop = time()

    assert (stop - start) >= duration
Exemplo n.º 3
0
def test_facebook_sleep():
    duration = 0.001
    fb = Facebook()
    s = stack(Sleep(duration))

    start = time()
    # noinspection PyTypeChecker
    run(fb.send(None, s))
    stop = time()

    assert (stop - start) >= duration
Exemplo n.º 4
0
def test_facebook_share():
    fb = Facebook()
    s = stack(
        ButtonTemplate('foo', [
            ShareButton(
                GenericTemplate([
                    Card(
                        title='foo',
                        subtitle='bar',
                        buttons=[
                            UrlButton('baz', 'https://example.com'),
                        ],
                    ),
                ]))
        ]))

    with patch.object(fb, '_send', return_value=instant_run()) as mock_send:
        run(fb.send(None, s))
        mock_send.assert_called_once_with(
            None, {
                'attachment': {
                    'type': 'template',
                    'payload': {
                        'template_type':
                        'button',
                        'text':
                        'foo',
                        'buttons': [
                            {
                                'type': 'element_share',
                                'share_contents': {
                                    'attachment': {
                                        'type': 'template',
                                        'payload': {
                                            'template_type':
                                            'generic',
                                            'sharable':
                                            False,
                                            'elements': [
                                                {
                                                    'title':
                                                    'foo',
                                                    'subtitle':
                                                    'bar',
                                                    'buttons': [
                                                        {
                                                            'type':
                                                            'web_url',
                                                            'title':
                                                            'baz',
                                                            'url':
                                                            'https://'
                                                            'example.com',
                                                        },
                                                    ],
                                                },
                                            ],
                                        },
                                    },
                                },
                            },
                        ],
                    },
                },
            }, s)
Exemplo n.º 5
0
def test_typify():
    at = AutoType(None)
    assert at.typify(lyr.stack(lyr.Typing())) == [lyr.stack(lyr.Typing())]