예제 #1
0
    def test_post(self):
        stork.Api('path1').resource('path2').post()

        stork.Resource.client.request.assert_called_with('post',
                                                         url='path1/path2',
                                                         params=None,
                                                         data=None,
                                                         headers={},
                                                         cookies=None,
                                                         timeout=None,
                                                         auth=None,
                                                         verify=None,
                                                         allow_redirects=None)
예제 #2
0
    def test_default_header_overriden(self):
        api = stork.Api('http://myapi/v1', headers={'accept-language': 'es'})
        api.resource('path').get(headers={'accept-language': 'en'})

        stork.Resource.client.request.assert_called_with(
            'get',
            url='http://myapi/v1/path',
            params=None,
            data=None,
            headers={'accept-language': 'en'},
            cookies=None,
            timeout=None,
            auth=None,
            verify=None,
            allow_redirects=None)
예제 #3
0
    def test_resource(self):
        api = stork.Api('http://myapi/v1')
        resource = api.resource('path')

        assert 'http://myapi/v1/path' == resource.path
예제 #4
0
 def test_nested_resource_slash_end(self):
     r = stork.Api('path1/').resource('path2')
     assert r.path == 'path1/path2'
예제 #5
0
 def test_nested_resource_slash_beginning(self):
     r = stork.Api('path1').resource('/path2')
     assert r.path == 'path1/path2'