Example #1
0
 def test_body(self):
     data = json.dumps({'key': 'value'})
     post = RequestFactory().post('/',
                                  data,
                                  content_type='application/json')
     post.META[settings.HEADER_DESTINATION] = '/some/url/'
     eq_(utils.prepare(post)['data'], data)
Example #2
0
 def test_header_ignored(self):
     assert 'Foo' not in settings.HEADERS_ALLOWED
     self.req.META['HTTP_FOO'] = 'bar'
     res = utils.prepare(self.req)
     ok_('Foo' not in res['headers'])
Example #3
0
 def test_header_added(self):
     self.req.META['HTTP_X_SOLITUDE_SOAPACTION'] = 'something'
     res = utils.prepare(self.req)
     eq_(res['headers']['SOAPAction'], 'something')
Example #4
0
 def test_url_ok(self):
     res = utils.prepare(self.req)
     eq_(res['url'], '/some/url/')
Example #5
0
 def test_body(self):
     data = json.dumps({'key': 'value'})
     post = RequestFactory().post('/', data,
                                  content_type='application/json')
     post.META[settings.HEADER_DESTINATION] = '/some/url/'
     eq_(utils.prepare(post)['data'], data)
Example #6
0
 def test_no_header(self):
     utils.prepare(RequestFactory().get('/'))
Example #7
0
def test_url():
    req = RequestFactory().get(
        '/v1/reference/reference/bar?q=1',
        **{settings.HEADER_DESTINATION: 'http://foo.com'})
    eq_(utils.reference_url(req, utils.prepare(req), 'reference'),
        'http://foo.com/bar?q=1')
Example #8
0
def test_url():
    req = RequestFactory().get(
        '/v1/reference/reference/bar?q=1',
        **{settings.HEADER_DESTINATION: 'http://foo.com'})
    eq_(utils.reference_url(req, utils.prepare(req), 'reference'),
        'http://foo.com/bar?q=1')
Example #9
0
 def test_header_ignored(self):
     assert 'Foo' not in settings.HEADERS_ALLOWED
     self.req.META['HTTP_FOO'] = 'bar'
     res = utils.prepare(self.req)
     ok_('Foo' not in res['headers'])
Example #10
0
 def test_header_added(self):
     self.req.META['HTTP_X_SOLITUDE_SOAPACTION'] = 'something'
     res = utils.prepare(self.req)
     eq_(res['headers']['SOAPAction'], 'something')
Example #11
0
 def test_url_ok(self):
     res = utils.prepare(self.req)
     eq_(res['url'], '/some/url/')
Example #12
0
 def test_no_header(self):
     utils.prepare(RequestFactory().get('/'))