示例#1
0
    def test_execute_data_json(self):
        actor = misc.GenericHTTP('Unit Test Action',
                                 {'url': 'http://example.com',
                                  'data-json': {'foo': 'bar'}})
        actor._fetch = mock_tornado({'success': {'code': 200}})

        yield actor.execute()
示例#2
0
    def test_execute_fail(self):
        actor = misc.GenericHTTP('Unit Test Action',
                                 {'url': 'http://example.com'})
        error = httpclient.HTTPError(code=401, response={})
        actor._fetch = mock_tornado(exc=error)

        with self.assertRaises(exceptions.InvalidCredentials):
            yield actor.execute()
示例#3
0
    def integration_auth(self):
        actor = misc.GenericHTTP(
            'Test', {
                'url': 'http://httpbin.org/basic-auth/unit/test',
                'username': '******',
                'password': '******'
            })

        yield actor.execute()
示例#4
0
    def integration_post(self):
        actor = misc.GenericHTTP('Test', {
            'url': 'http://httpbin.org/post',
            'data': {
                'foo': 'bar'
            }
        })

        yield actor.execute()
示例#5
0
    def test_execute_dry(self):
        actor = misc.GenericHTTP('Unit Test Action',
                                 {'url': 'http://example.com'},
                                 dry=True)

        actor._fetch = mock_tornado()

        yield actor.execute()

        self.assertEqual(actor._fetch._call_count, 0)
示例#6
0
    def integration_auth_fail(self):
        actor = misc.GenericHTTP(
            'Test', {
                'url': 'http://httpbin.org/basic-auth/unit/test',
                'username': '******',
                'password': '******'
            })

        with self.assertRaises(exceptions.InvalidCredentials):
            yield actor.execute()
示例#7
0
    def integration_get(self):
        actor = misc.GenericHTTP('Test', {'url': 'http://httpbin.org/get'})

        yield actor.execute()