def test_003(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)    
    t.eq(p.status_int, 404)
    body, tr = p.filter_body(buf2)
    t.eq(body,"")
    t.eq(p.body_eof(), True)
def test_006(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)    
    t.eq(p.status_int, 200)
    body, tr = p.filter_body(buf2)
    t.eq(body,"these headers are from http://news.ycombinator.com/")
    t.eq(p.body_eof(), True)
def test_007(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)    
    t.eq(p.status_int, 200)
    body, tr = p.filter_body(buf2)
    t.eq(body,"hello world")
    t.eq(len(body), int(p.content_len))
    t.eq(p.body_eof(), True)
    def test_002(self):
        """test key eviction"""
        cache = self.CacheEngine(1)
        key = "lru_key"
        value = "lru_value"

        cache[key] = value
        cache['trash'] = 'junk'

        t.ne(cache.get(key), value)
Example #5
0
def test_006(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/get_no_headers_no_body/world")
    t.eq(p.query_string, "")
    t.eq(p.fragment, "")
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "")
def test_004(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/dumbfuck")
    t.eq(p.query_string, "")
    t.eq(p.headers, [("Aaaaaaaaaaaaa", "++++++++++")])
    body, tr = p.filter_body(buf2)
    t.eq(body, "")
def test_006(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/get_no_headers_no_body/world")
    t.eq(p.query_string, "")
    t.eq(p.fragment, "")
    body, tr = p.filter_body(buf2)
    t.eq(body, "")
Example #8
0
def test_004(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/dumbfuck")
    t.eq(p.query_string, "")
    t.eq(p.headers, [("Aaaaaaaaaaaaa", "++++++++++")])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "")
Example #9
0
def test_007(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/get_one_header_no_body")
    t.eq(p.query_string, "")
    t.eq(p.fragment, "")
    t.eq(p.headers, [('Accept', '*/*')])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "")
Example #10
0
def test_008(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 0))
    t.eq(p.path, "/get_funky_content_length_body_hello")
    t.eq(p.query_string, "")
    t.eq(p.fragment, "")
    t.eq(p.headers, [('Content-Length', '5')])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "HELLO")
def test_008(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 0))
    t.eq(p.path, "/get_funky_content_length_body_hello")
    t.eq(p.query_string, "")
    t.eq(p.fragment, "")
    t.eq(p.headers, [('Content-Length', '5')])
    body, tr = p.filter_body(buf2)
    t.eq(body, "HELLO")
def test_007(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/get_one_header_no_body")
    t.eq(p.query_string, "")
    t.eq(p.fragment, "")
    t.eq(p.headers, [('Accept', '*/*')])
    body, tr = p.filter_body(buf2)
    t.eq(body, "")
Example #13
0
def test_dberror(conn, cursor):
    obj = {"name": "test", "sql": "select a${name}"}
    s = t.Statement(obj)
    try:
        s.execute(cursor, {"name": "foo"})
    except t.DBError, e:
        t.eq(e.method, "query")
        t.eq(e.name, "test")
        t.eq(e.sql, "select a?")
        t.eq(e.bound, [("foo", "str")])
        t.ne(e.trace, None)
        str(e)  # Doesn't raise
Example #14
0
def test_005(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/forums/1/topics/2375")
    t.eq(p.query_string, "page=1")

    t.eq(p.fragment, "posts-17408")
    body, tr = p.filter_body(buf2)
    t.eq(body, "")
Example #15
0
def test_009(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/post_identity_body_world")
    t.eq(p.query_string, "q=search")
    t.eq(p.fragment, "hey")
    t.eq(sorted(p.headers), [("Accept", "*/*"), ("Content-Length", "5"), ("Transfer-Encoding", "identity")])
    body, tr = p.filter_body(buf2)
    t.eq(body, "World")
def test_012(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 0))
    t.eq(p.path, "/stuff/here")
    t.eq(p.query_string, "foo=bar")
    t.eq(p.is_chunked, False)
    t.eq(p._chunk_eof, False)
    t.eq(p.body_eof(), True)
    t.eq(p.headers, [("If-Match", "bazinga!, large-sound")])
Example #17
0
def test_005(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/forums/1/topics/2375")
    t.eq(p.query_string, "page=1")

    t.eq(p.fragment, "posts-17408")
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "")
Example #18
0
def test_009(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/post_identity_body_world")
    t.eq(p.query_string, "q=search")
    t.eq(p.fragment, "hey")
    t.eq(sorted(p.headers), [('Accept', '*/*'), ('Content-Length', '5'),
                             ('Transfer-Encoding', 'identity')])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "World")
Example #19
0
def add_feature(pack):
    f = {
        "location": {"type": "span", "from": 1, "to": 100},
        "type": "CDS",
        "note": "Hiya"
    }
    with pack.writer('message') as w:
        fid = w.add_feature(f)
    t.ne(pack.repo.tree()/"obj"/fid, None)

    desc_id = pack.descid(f)
    t.eq(pack.active_ids[desc_id], fid)
    t.eq(pack.known_ids[desc_id], fid)
Example #20
0
def test_001(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)

    t.eq(p.method, "PUT")
    t.eq(p.version, (1, 0))
    t.eq(p.path, "/stuff/here")
    t.eq(p.query_string, "foo=bar")
    t.eq(sorted(p.headers), [('Content-Length', '14'),
                             ('Content-Type', 'application/json'),
                             ('Server', 'http://127.0.0.1:5984')])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, '{"nom": "nom"}')
    t.eq(p.body_eof(), True)
Example #21
0
def test_001(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)

    t.eq(p.method, "PUT")
    t.eq(p.version, (1, 0))
    t.eq(p.path, "/stuff/here")
    t.eq(p.query_string, "foo=bar")
    t.eq(
        sorted(p.headers),
        [("Content-Length", "14"), ("Content-Type", "application/json"), ("Server", "http://127.0.0.1:5984")],
    )
    body, tr = p.filter_body(buf2)
    t.eq(body, '{"nom": "nom"}')
    t.eq(p.body_eof(), True)
def test_002(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
       
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/test")
    t.eq(p.query_string, "")
    t.eq(sorted(p.headers), [
        ("Accept", "*/*"),
        ("Host", "0.0.0.0=5000"),
        ("User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1")
    ])
    body, tr = p.filter_body(buf2)
    t.eq(body, "")
Example #23
0
def test_009(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/post_identity_body_world")
    t.eq(p.query_string, "q=search")
    t.eq(p.fragment, "hey")
    t.eq(sorted(p.headers), [
        ('Accept', '*/*'),
        ('Content-Length', '5'),
        ('Transfer-Encoding', 'identity')
    ])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "World")
Example #24
0
def test_merge_desc():
    obj1 = {"name": "test", "sql": "select * from scenes;"}
    obj2 = {"name": "test", "desc": "I am a desc.", "dbs": "sqlite", "sql": "select * from scenes2;"}
    obj3 = {"name": "test", "desc": "Another desc", "sql": "select * from scenes3;"}
    s1 = t.Statement(obj1)
    s2 = t.Statement(obj2)
    s3 = t.Statement(obj3)
    t.eq(s1.desc, None)
    t.eq(s2.desc, "I am a desc.")
    t.eq(s3.desc, "Another desc")

    s1.merge(s2)
    t.eq(s1.desc, s2.desc)

    s3.merge(s2)
    t.ne(s3.desc, s2.desc)
def test_011(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/two_chunks_mult_zero_end")
    t.eq(p.headers, [('Transfer-Encoding', 'chunked')])
    t.eq(p.is_chunked, True)
    t.eq(p._chunk_eof, False)
    t.ne(p.body_eof(), True)
    body = ""
    while not p.body_eof():
        chunk, buf2 = p.filter_body(buf2)
        if chunk:
            body += chunk
    t.eq(body, "hello world")
def test_002(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.status_int, 200)
    t.eq(p.reason, 'OK')
    t.eq(sorted(p.headers), [
        ('Connection', 'close'),
        ('Content-Type', 'text/xml; charset=utf-8'),
        ('Date', 'Tue, 04 Aug 2009 07:59:32 GMT'),
        ('Server', 'Apache'),
        ('X-Powered-By', 'Servlet/2.5 JSP/2.1'),
        
    ])
    
    body, tr = p.filter_body(buf2)
    t.eq(p.body_eof(), True)
Example #27
0
def test_002(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)

    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/test")
    t.eq(p.query_string, "")
    t.eq(sorted(p.headers), [
        ("Accept", "*/*"), ("Host", "0.0.0.0=5000"),
        ("User-Agent",
         "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1"
         )
    ])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "")
Example #28
0
def test_001(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    
    t.eq(p.method, "PUT")
    t.eq(p.version, (1,0))
    t.eq(p.path, "/stuff/here")
    t.eq(p.query_string, "foo=bar")
    t.eq(sorted(p.headers), [
        ('Content-Length', '14'),
        ('Content-Type', 'application/json'),
        ('Server', 'http://127.0.0.1:5984')
    ])
    body, tr = p.filter_body(buf[i:])    
    t.eq(body, '{"nom": "nom"}')
    t.eq(p.body_eof(), True)
Example #29
0
def test_011(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/two_chunks_mult_zero_end")
    t.eq(p.headers, [('Transfer-Encoding', 'chunked')])
    t.eq(p.is_chunked, True)
    t.eq(p._chunk_eof, False)
    t.ne(p.body_eof(), True)
    body = ""
    buf = buf[i:]
    while not p.body_eof():
        chunk, buf = p.filter_body(buf)
        if chunk:
            body += chunk
    t.eq(body, "hello world")
def test_010(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/post_chunked_all_your_base")
    t.eq(p.headers, [('Transfer-Encoding', 'chunked')])
    t.eq(p.is_chunked, True)
    t.eq(p._chunk_eof, False)
    t.ne(p.body_eof(), True)
    body = ""
    while not p.body_eof():
        chunk, buf2 = p.filter_body(buf2)
        print chunk
        if chunk:
            body += chunk
    t.eq(body, "all your base are belong to us")
Example #31
0
def test_010(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "POST")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/post_chunked_all_your_base")
    t.eq(p.headers, [('Transfer-Encoding', 'chunked')])
    t.eq(p.is_chunked, True)
    t.eq(p._chunk_eof, False)
    t.ne(p.body_eof(), True)
    body = ""
    buf = buf[i:]
    while not p.body_eof():
        chunk, buf = p.filter_body(buf)
        print chunk
        if chunk:
            body += chunk
    t.eq(body, "all your base are belong to us")
def test_001(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.version, (1,1))
    t.eq(p.status, "301 Moved Permanently")
    t.eq(p.status_int, 301)
    t.eq(p.reason, "Moved Permanently")
    t.eq(sorted(p.headers), [
        ('Cache-Control', 'public, max-age=2592000'),
        ('Content-Length', '211'),
        ('Content-Type', 'text/html; charset=UTF-8'),
        ('Date', 'Sun, 26 Apr 2009 11:11:49 GMT'),
        ('Expires', 'Tue, 26 May 2009 11:11:49 GMT'),
        ('Location', 'http://www.google.com/'),
        ('Server', 'gws'),
    ])
    body, tr = p.filter_body(buf2)
    t.eq(p.content_len,len(body))
    t.eq(p.body_eof(), True)
def test_003(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/favicon.ico")
    t.eq(p.query_string, "")
    t.eq(sorted(p.headers), [
        ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
        ("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"),
        ("Accept-Encoding", "gzip,deflate"),
        ("Accept-Language", "en-us,en;q=0.5"),
        ("Connection", "keep-alive"),
        ("Host", "0.0.0.0=5000"),
        ("Keep-Alive", "300"),
        ("User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0"),
    ])
    body, tr = p.filter_body(buf2)
    t.eq(body, "")
def test_005(buf, p):
    headers = []
    buf2 = p.filter_headers(headers, buf)
    t.ne(buf2, False)    
    t.eq(p.status_int, 200)
    t.eq(sorted(p.headers), [
        ('Content-Type', 'text/plain'),
        ('Transfer-Encoding', 'chunked')
    ])
    t.eq(p.is_chunked, True)
    t.eq(p._chunk_eof, False)
    t.ne(p.body_eof(), True)
    body = ""
    while not p.body_eof():
        chunk, buf2 = p.filter_body(buf2)
        print chunk
        if chunk:
            body += chunk
    t.eq(body, 
    "  This is the data in the first chunk  and this is the second one")
    t.eq(p.body_eof(), True)
Example #35
0
def test_003(buf, p):
    headers = []
    i = p.filter_headers(headers, buf)
    t.ne(i, -1)
    t.eq(p.method, "GET")
    t.eq(p.version, (1, 1))
    t.eq(p.path, "/favicon.ico")
    t.eq(p.query_string, "")
    t.eq(sorted(p.headers), [
        ("Accept",
         "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
        ("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"),
        ("Accept-Encoding", "gzip,deflate"),
        ("Accept-Language", "en-us,en;q=0.5"),
        ("Connection", "keep-alive"),
        ("Host", "0.0.0.0=5000"),
        ("Keep-Alive", "300"),
        ("User-Agent",
         "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0"
         ),
    ])
    body, tr = p.filter_body(buf[i:])
    t.eq(body, "")
Example #36
0
def test_creating_runtime(rt):
    t.ne(rt, None)
Example #37
0
def test_info(conn, cursor):
    t.ne(t.dbwrapper.DB_INFO['sqlite'], t.dbwrapper.DB_INFO['pgsql'])
    t.eq(conn.info(), t.dbwrapper.DBInfo('"', False, None))
def test_NaN_to_py_nan(cx):
    nan = cx.execute("NaN;")
    t.eq(type(nan), float)
    t.ne(nan, nan)
def test_creating_runtime(rt):
    t.ne(rt, None)
def test_multiple_record_streaming(src):
    for idx, rec in enumerate(src):
        t.eq(rec.info.accession, ACCESSIONS[idx])
        for s in rec:
            t.ne(s, "")
Example #41
0
def test_pkt_reader():
    for pkt in pkts():
        t.ne(len(pkt), 0)
Example #42
0
def test_pkt_reader():
    for pkt in pkts("collectd.pkts"):
        t.ne(len(pkt), 0)
def test_pkt_reader():
    for pkt in pkts():
        t.ne(len(pkt), 0)
def test_roundtrip_nan(echo):
    t.eq(type(echo(1E500 / 1E500)), float)
    t.ne(echo(1E500 / 1E500), 1E500 / 1E500)
Example #45
0
def test_submit(master):
    id = master.submit(id=None, type="foo", body={"something": "here"})
    t.ne(id, None)
Example #46
0
def test_submit(master):
    id = master.submit(id=None, type="foo", body={"something": "here"})
    t.ne(id, None)
def test_NaN_to_py_nan(cx):
    nan = cx.execute("NaN;")
    t.eq(type(nan), float)
    t.ne(nan, nan)