예제 #1
0
    def test_env_and_source_non_ascii(self):
        c = Context()
        c.url = 'http://localhost:8000/api'
        c.headers.update({
            'Accept': 'text/csv',
            'Authorization': 'ApiKey 1234'
        })
        c.querystring_params.update({'page': ['1'], 'limit': ['50']})
        c.body_params.update({'name': '許 功蓋'})
        c.options.update({'--verify': 'no', '--form': None})

        c2 = c.copy()

        filename = self.make_tempfile()
        execute('env > %s' % filename, c)
        execute('rm *', c)

        self.assertFalse(c.headers)
        self.assertFalse(c.querystring_params)
        self.assertFalse(c.body_params)
        self.assertFalse(c.options)

        execute('source %s' % filename, c)

        self.assertEqual(c, c2)
예제 #2
0
def test_json_serializing():
    c = Context('http://example.com/api')
    c.headers.update({
        'Authorization': 'ApiKey 1234',
        'Accept': 'text/html'
    })
    c.options['--form'] = None
    c.body_params.update({
        'name': 'Jane Doe',
        'email': '*****@*****.**'
    })

    json_obj = c.json_obj()

    c2 = c.copy()
    c2.headers['Accept'] = 'application/json'
    c2.body_params['name'] = 'Jane Doe'
    assert c2 != c

    c2.load_from_json_obj(json_obj)
    assert c2 == c
예제 #3
0
def test_copy():
    c1 = Context('http://localhost')
    c2 = c1.copy()
    assert c1 == c2
    assert c1 is not c2
예제 #4
0
def test_copy():
    c1 = Context('http://localhost')
    c2 = c1.copy()
    assert c1 == c2
    assert c1 is not c2