File: 007-test-util.py

package info (click to toggle)
python-restkit 4.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,908 kB
  • ctags: 841
  • sloc: python: 5,964; makefile: 84; xml: 8; sh: 5
file content (38 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -
#
# This file is part of restkit released under the MIT license. 
# See the NOTICE for more information.


import t
from restkit import util

def test_001():
    qs = {'a': "a"}
    t.eq(util.url_encode(qs), "a=a")
    qs = {'a': 'a', 'b': 'b'}
    t.eq(util.url_encode(qs), "a=a&b=b")
    qs = {'a': 1}
    t.eq(util.url_encode(qs), "a=1")
    qs = {'a': [1, 2]}
    t.eq(util.url_encode(qs), "a=1&a=2")
    qs = {'a': [1, 2], 'b': [3, 4]}
    t.eq(util.url_encode(qs), "a=1&a=2&b=3&b=4")
    qs = {'a': lambda : 1}
    t.eq(util.url_encode(qs), "a=1")
    
def test_002():
    t.eq(util.make_uri("http://localhost", "/"), "http://localhost/")
    t.eq(util.make_uri("http://localhost/"), "http://localhost/")
    t.eq(util.make_uri("http://localhost/", "/test/echo"), 
        "http://localhost/test/echo")
    t.eq(util.make_uri("http://localhost/", "/test/echo/"), 
        "http://localhost/test/echo/")
    t.eq(util.make_uri("http://localhost", "/test/echo/"),
        "http://localhost/test/echo/")
    t.eq(util.make_uri("http://localhost", "test/echo"), 
        "http://localhost/test/echo")
    t.eq(util.make_uri("http://localhost", "test/echo/"),
        "http://localhost/test/echo/")