コード例 #1
0
ファイル: 001-test-users.py プロジェクト: akissa/BaruwaAPI
def test_update_user(api):
    data = {
        "username": "******",
        "firstname": "Blossom",
        "lastname": "Utonium",
        "password1": "ng5qhhbiwozcANc3",
        "password2": "ng5qhhbiwozcANc3",
        "email": "*****@*****.**",
        "timezone": "Africa/Johannesburg",
        "account_type": "3",
        "domains": "9",
        "active": "y",
        "send_report": "y",
        "spam_checks": "y",
        "low_score": "5.0",
        "high_score": "10.0",
    }
    req = api.update_user(data)
    path = ENDPOINTS["users"]["update"]["name"]
    t.eq(api.response.final_url, "%s%s%s" % (BASE_URL, API_PATH, path))
    t.eq(api.response.request.method, ENDPOINTS["users"]["update"]["method"])
    t.eq(api.response.status_int, 201)
    t.eq(req["low_score"], "5.0")
    t.eq(req["high_score"], "10.0")
    t.isnotin("password1", req)
コード例 #2
0
def test_from_func():
    @t.task
    def foo():
        "Hi"
        pass
    t.desc(foo, "yay")
    t.eq(t.app.mgr.lookup("foo").descr, "yay")
コード例 #3
0
ファイル: n11_test.py プロジェクト: benoitc/pywebmachine
 def test_post_is_create_no_redirect(self):
     self.TestResource.create = True
     self.TestResource.location = None
     self.req.method = 'POST'
     self.go()
     t.eq(self.rsp.status, '200 OK')
     t.eq(self.rsp.body, 'created')
コード例 #4
0
def test_override_docstring():
    @t.task
    def foo():
        "Not the description"
        pass
    t.desc("foo", "wheeee")
    t.eq(t.app.mgr.lookup("foo").descr, "wheeee")
コード例 #5
0
def test_add_description_first():
    t.desc("foo", "bazinga")
    @t.task
    def foo():
        "Not used as a description"
        pass
    t.eq(t.app.mgr.lookup("foo").descr, "bazinga")
コード例 #6
0
ファイル: 008-test-request.py プロジェクト: andrewjw/restkit
def test_003():
     u = "http://*****:*****@%s:%s/auth" % (HOST, PORT)
     r = request(u)
     t.eq(r.status_int, 200)
     u = "http://*****:*****@%s:%s/auth" % (HOST, PORT)
     r = request(u)
     t.eq(r.status_int, 403)
コード例 #7
0
ファイル: 006-connect-test.py プロジェクト: pombredanne/sheba
def test_raw_yaml():
    yaml = dedent("""\
        name: test
        sql: SELECT 'x' as "foo"
        """)
    conn = t.sheba.connect(yaml, driver='sqlite3', args=(":memory:",))
    t.eq(isinstance(conn, t.Connection), True)
コード例 #8
0
def test_invalid_native_case(conn, cursor):
    try:
        t.dbwrapper.DB_INFO['sqlite'].native_case = "foo"
        cursor.execute("select 1 as a")
    except t.dbwrapper.InvalidNativeCase, inst:
        t.eq(inst.name, "foo")
        str(inst) # Doesn't raise
コード例 #9
0
ファイル: test-translate.py プロジェクト: pombredanne/nebseq
def test_partial():
    seq = "AAACTGCTTTAA"
    t.eq(t.translate(seq), "XLL")
    t.eq(t.translate(seq, partial=True), "KLL*")
    t.eq(t.translate(seq, partial=(True, False)), "KLL")
    t.eq(t.translate(seq, partial=(False, True)), "XLL*")
    t.eq(t.translate(seq, partial=(False, False)), "XLL")
コード例 #10
0
def test_del_item():
    fl = t.FileList("a.c", "b.c")
    del fl[0]
    t.eq(fl[0], "b.c")
    def rem():
        del fl[2]
    t.raises(IndexError, rem)
コード例 #11
0
ファイル: test-both.py プロジェクト: alepharchives/gloom
def test_single_job(master, slave):
    master.submit(id="hi", type="foo", body="Here")
    slave.join("foo")
    job = slave.job(timeout=1)
    t.eq(job, {"action": "job", "id": "hi", "type": "foo", "body": "Here"})
    slave.respond(body="ohai!")
    t.eq(master.receive(timeout=1), {"id": "hi", "body": "ohai!"})
コード例 #12
0
ファイル: test_003-config.py プロジェクト: 1stvamp/gunicorn
def test_nworkers_changed():
    c = config.Config()
    def nworkers_changed_3(server, new_value, old_value):
        return 3

    c.set("nworkers_changed", nworkers_changed_3)
    t.eq(3, c.nworkers_changed(1, 2, 3))
コード例 #13
0
def test_set_slice():
    fl1 = t.FileList("a.c", "b.c", "exist*")
    fl2 = t.FileList("d.c")
    fl1[1:2] = fl2
    t.eq(fl1, ["a.c", "d.c", "existing"])
    fl1[2:] = ["d.e"]
    t.eq(fl1, ["a.c", "d.c", "d.e"])
コード例 #14
0
def test_add_arrays():
    t.eq(t.FileList("a.c", "b.c") + ["foo.py"], ["a.c", "b.c", "foo.py"])
    t.eq(["foo.py"] + t.FileList("a.c", "b.c"), ["foo.py", "a.c", "b.c"])
    t.raises(TypeError, lambda: t.FileList("a.c", "b.c") + 1)
    t.raises(TypeError, lambda: t.FileList("a.c", "b.c") + [1])
    t.raises(TypeError, lambda: 1 + t.FileList("a.c", "b.c"))
    t.raises(TypeError, lambda: [1] + t.FileList("a.c", "b.c"))
コード例 #15
0
def test_compiled_contexts(rt):
    "Check to be sure multiple contexts can be used for compiled execution."
    ctx1 = rt.new_context({"a": 111})
    ctx2 = rt.new_context({"a": 222})
    expr1 = ctx1.compile("a * 3;")
    t.eq(expr1.execute(), 333)
    t.eq(expr1.execute(ctx2), 666)
コード例 #16
0
def test_add_matching():
    fl = t.FileList()
    fl.append("a.java")
    fl.include("*.c")
    t.eq(fl[0], "a.java")
    t.eq(len(fl), 4)
    t.isin("abc.c", fl)
コード例 #17
0
ファイル: treq.py プロジェクト: Leits/restkit
    def check(self, sender, sizer, matcher):
        cases = self.expect[:]

        unreader = IterUnreader(sender())
        resp = Request(unreader)
        self.same(resp, sizer, matcher, cases.pop(0))
        t.eq(len(cases), 0)
コード例 #18
0
def test_sub_with_backref():
    fl = t.FileList("src/org/onestepback/a.java", "src/org/onestepback/b.java")
    fl.sub(r"^src/(.*).java$", r"classes/\1.class")
    t.eq(sorted(fl), [
        "classes/org/onestepback/a.class",
        "classes/org/onestepback/b.class"
    ])
コード例 #19
0
ファイル: p03_test.py プロジェクト: msabramo/rapidmachine
 def test_ok(self):
     self.TestResource.conflict = False
     self.env.method = 'PUT'
     self.env.content_type = 'text/html'
     self.go()
     t.eq(self.rsp.status_code, 200)
     t.eq(self.rsp.response, ['bar'])
コード例 #20
0
def test_set_item():
    fl = t.FileList("a.c", "b.c")
    fl[0] = "foo.py"
    t.eq(fl, ["foo.py", "b.c"])
    def assign():
        fl[1] = 2
    t.raises(TypeError, assign)
コード例 #21
0
def test_syntax_error(cx):
    try:
        cx.execute("function(asdf;")
        t.eq(1, 0)
    except:
        line = traceback.format_exc().split("\n")[-3].strip()
        t.eq(line, ERROR)
コード例 #22
0
def test_statement_error():
    obj = {"name": "test"}
    try:
        t.Statement(obj)
    except t.IncompleteStatementError, e:
        t.eq(e.name, "sql")
        str(e)  # Doesn't raise
コード例 #23
0
def test_plumbing(inq, outq, proc):
    data = get_simple_data(100)
    i = 0
    for sample in send_get_data(data, inq, outq):
        t.eq(sample, data[i])
        i += 1
    t.eq(i, 100)
コード例 #24
0
ファイル: 003-test-client.py プロジェクト: mwhooker/restkit
def test_016(u, c):
    fn = os.path.join(os.path.dirname(__file__), "1M")
    with open(fn, "rb") as f:
        l = int(os.fstat(f.fileno())[6])
        r = c.request(u, 'POST', body=f)
        t.eq(r.status_int, 200)
        t.eq(int(r.body), l)
コード例 #25
0
def test_filter(inq, outq, proc):
    data = get_simple_data(100)
    i = 0
    for sample in send_get_data(data, inq, outq):
        t.eq(sample[2] % 2, 1)
        i += 1
    t.eq(i, 50)
コード例 #26
0
def test_py_no_del_item(rt):
    glbl = ActiveGlobal()
    cx = rt.new_context(glbl)
    cx.execute('foo = 4;')
    t.eq(glbl.data["foo"], 8)
    cx.execute("delete foo;")
    t.isin("foo", glbl.data)
コード例 #27
0
def test_py_del_global(rt):
    glbl = ActiveGlobalWithDel()
    cx = rt.new_context(glbl)
    cx.execute("foo = 4;")
    t.eq(glbl.data["foo"], 8)
    cx.execute("delete foo;")
    t.isnotin("foo", glbl.data)
コード例 #28
0
ファイル: test-multi-def.py プロジェクト: alepharchives/nebfa
def second(rec):
    t.eq(rec.meta, {
        'ids': [
            ('gi', '66816243'),
            ('ref', 'XP_642131.1'),
            ('gi', '1705556'),
            ('sp', 'P54670.1|CAF1_DICDI'),
            ('gi', '793761'),
            ('dbj', 'BAA06266.1'),
            ('gi', '60470106'),
            ('gb', 'EAL68086.1')
        ],
        'desc': [
            'calfumirin-1 [Dictyostelium discoideum AX4]',
            'RecName: Full=Calfumirin-1; Short=CAF-1',
            'calfumirin-1 [Dictyostelium discoideum]'
        ]
    })
    t.eq(rec.id, ('gi', '66816243'))
    t.eq(rec.desc, 'calfumirin-1 [Dictyostelium discoideum AX4]')
    t.eq(rec.sequence, ''.join("""
        MASTQNIVEEVQKMLDTYDTNKDGEITKAEAVEYFKGKKAFNPERSAIYLFQVYDKDNDGKITIKELA
        GDIDFDKALKEYKEKQAKSKQQEAEVEEDIEAFILRHNKDDNTDITKDELIQGFKETGAKDPEKSANF
        ILTEMDTNKDGTITVKELRVYYQKVQKLLNPDQ
    """.split()))
    t.eq(rec.hash, "7D6B32F721E2E8BF34A37015C11E3FBAA0C791B8")
コード例 #29
0
ファイル: p03_test.py プロジェクト: benoitc/pywebmachine
 def test_ok(self):
     self.TestResource.conflict = False
     self.req.method = 'PUT'
     self.req.content_type = 'text/html'
     self.go()
     t.eq(self.rsp.status, '200 OK')
     t.eq(self.rsp.body, 'bar')
コード例 #30
0
ファイル: p03_test.py プロジェクト: msabramo/rapidmachine
 def test_unsupported_media_type(self):
     prev = self.TestResource.accepted
     self.TestResource.accepted = []
     self.TestResource.conflict = False
     self.env.method = 'PUT'
     self.go()
     self.TestResource.accepted = prev
     t.eq(self.rsp.status_code, 415)
コード例 #31
0
def test_017(u, c):
    r = c.request(u, 'POST', body=LONG_BODY_PART)
    t.eq(r.status_int, 200)
    t.eq(int(r['content-length']), len(LONG_BODY_PART))
    t.eq(r.body_string(), LONG_BODY_PART)
コード例 #32
0
def test_021(u, c):
    lines = ["line 1\n", " line2\n"]
    r = c.request(u, 'POST', body=lines, 
            headers=[("Content-Length", "14")])
    t.eq(r.status_int, 200)
    t.eq(r.body_string(), 'line 1\n line2\n')
コード例 #33
0
def test_019(u, c):
    r = c.request(u, 'PUT', body="test")
    t.eq(r.body_string(), "test")
コード例 #34
0
def test_001(u, c):
    r = c.request(u)
    t.eq(r.body_string(), "welcome")
コード例 #35
0
def test_022(u, c):
    lines = ["line 1\n", " line2\n"]
    r = c.request(u, 'POST', body=lines, 
            headers=[("Transfer-Encoding", "chunked")])
    t.eq(r.status_int, 200)
    t.eq(r.body_string(), '7\r\nline 1\n\r\n7\r\n line2\n\r\n0\r\n\r\n')
コード例 #36
0
ファイル: 003-test-config.py プロジェクト: tanish2k/gunicorn
def test_cfg_over_paster():
    with AltArgs(["prog_name", "-c", cfg_file(), paster_ini()]):
        app = PasterApp()
        t.eq(app.cfg.bind, "unix:/tmp/bar/baz")
        t.eq(app.cfg.proc_name, "fooey")
        t.eq(app.cfg.default_proc_name, "blurgh")
コード例 #37
0
def test_paster_config():
    with AltArgs(["prog_name", paster_ini()]):
        app = PasterApp()
        t.eq(app.cfg.bind, "192.168.0.1:80")
        t.eq(app.cfg.proc_name, "brim")
        t.eq("ignore_me" in app.cfg.settings, False)
コード例 #38
0
def test_app_config():
    with AltArgs():
        app = NoConfigApp()
    for s in config.KNOWN_SETTINGS:
        t.eq(s.default, app.cfg.settings[s.name].get())
コード例 #39
0
def test_load_config():
    with AltArgs(["prog_name", "-c", cfg_file()]):
        app = NoConfigApp()
    t.eq(app.cfg.bind, "unix:/tmp/bar/baz")
    t.eq(app.cfg.workers, 3)
    t.eq(app.cfg.proc_name, "fooey")
コード例 #40
0
def test_not_rebuilt():
    src = t.tmpfname()
    tgt = t.tmpfname()

    @t.build(src, recreate=False)
    def mksrc(task):
        open(task.name, "wb").write(t.uuid.uuid4().hex)

    @t.build(tgt, [src])
    def mktgt(task):
        print task.sources
        print task.source
        open(task.name, "wb").write(open(task.source).read())

    print t.app.mgr.tasks
    t.app.run(None, [tgt])
    t.eq(t.app._dbg, [(src, None), (tgt, None)])
    t.eq(os.path.exists(src), True)
    t.eq(os.path.exists(tgt), True)
    first_run = open(src).read()
    t.eq(open(tgt).read(), first_run)
    t.app.clear()
    t.app.run(None, [tgt])
    t.eq(t.app._dbg, [])
    t.eq(open(src).read(), first_run)
    t.eq(open(tgt).read(), first_run)
コード例 #41
0
def test_str_validation():
    c = config.Config()
    t.eq(c.proc_name, "gunicorn")
    c.set("proc_name", " foo ")
    t.eq(c.proc_name, "foo")
    t.raises(TypeError, c.set, "proc_name", 2)
コード例 #42
0
def test_012(u, c):
    r = c.request(u, 'POST', body=u"éàù@")
    t.eq(r.body_string(), "éàù@")
コード例 #43
0
def test_002(u, c):
    r = c.request(u)
    t.eq(r.body_string(charset="utf-8"), u"éàù@")
コード例 #44
0
def test_003(u, c):
    r = c.request(u)
    t.eq(r.body_string(), "ok")
    t.eq(r.status_int, 200)
コード例 #45
0
def test_015(u, c):
    r = c.request(u, 'POST', body="", 
            headers={'Content-Type': 'application/json'})
    t.eq(r.status_int, 200)
コード例 #46
0
def test_cli_overrides_config():
    with AltArgs(["prog_name", "-c", cfg_file(), "-b", "blarney"]):
        app = NoConfigApp()
        t.eq(app.cfg.bind, "blarney")
        t.eq(app.cfg.proc_name, "fooey")
コード例 #47
0
ファイル: b09_test.py プロジェクト: plucury/pywebmachine
 def test_not_ok(self):
     self.req.query_string = 'value=false'
     self.go()
     t.eq(self.rsp.status, '400 Bad Request')
     t.eq(self.rsp.body, '')
コード例 #48
0
def test_004(u, c):
    r = c.request(u, headers={'Content-Type': 'application/json'})
    t.eq(r.status_int, 200)
    r = c.request(u, headers={'Content-Type': 'text/plain'})
    t.eq(r.status_int, 400)
コード例 #49
0
ファイル: b12_test.py プロジェクト: plucury/pywebmachine
 def test_not_ok(self):
     self.req.method = 'PUT'
     self.go()
     t.eq(self.rsp.status, '501 Not Implemented')
     t.eq(self.rsp.body, '')
コード例 #50
0
def test_005(u, c):
    r = c.request(u, headers={'Content-Type': 'application/json'})
    t.eq(r.status_int, 404)
コード例 #51
0
ファイル: 001-task-tests.py プロジェクト: joelimome/smithy
def test_lambda_action():
    print t.task(lambda: 4.5)
    print t.app.mgr.tasks
    t.app.run(None, ["<lambda>.1"])
    t.eq(t.app._dbg, [("<lambda>.1", 4.5)])
コード例 #52
0
ファイル: b09_test.py プロジェクト: plucury/pywebmachine
 def test_ok(self):
     self.req.query_string = 'value=1&foo=true'
     self.go()
     t.eq(self.rsp.status, '200 OK')
     t.eq(self.rsp.body, 'nom nom')
コード例 #53
0
ファイル: treq.py プロジェクト: rclmenezes/djangotogo
 def same(self, req, sizer, matcher, exp):
     t.eq(req.method, exp["method"])
     t.eq(req.uri, exp["uri"]["raw"])
     t.eq(req.path, exp["uri"]["path"])
     t.eq(req.query, exp["uri"]["query"])
     t.eq(req.fragment, exp["uri"]["fragment"])
     t.eq(req.version, exp["version"])
     t.eq(req.headers, exp["headers"])
     matcher(req, exp["body"], sizer)
     t.eq(req.trailers, exp.get("trailers", []))
コード例 #54
0
ファイル: b12_test.py プロジェクト: plucury/pywebmachine
 def test_ok(self):
     self.go()
     t.eq(self.rsp.status, '200 OK')
     t.eq(self.rsp.body, 'nom nom')
コード例 #55
0
ファイル: 003-test-config.py プロジェクト: tanish2k/gunicorn
def test_cli_cfg_paster():
    with AltArgs(["prog_name", "-c", cfg_file(), "-b", "whee", paster_ini()]):
        app = PasterApp()
        t.eq(app.cfg.bind, "whee")
        t.eq(app.cfg.proc_name, "fooey")
        t.eq(app.cfg.default_proc_name, "blurgh")
コード例 #56
0
ファイル: 001-task-tests.py プロジェクト: joelimome/smithy
 def bizzle(task):
     from smithy.task import Task
     t.eq(isinstance(task, Task), True)
     return task.name
コード例 #57
0
ファイル: 003-test-config.py プロジェクト: tanish2k/gunicorn
def test_defaults():
    c = config.Config()
    for s in config.KNOWN_SETTINGS:
        t.eq(c.settings[s.name].validator(s.default),
             c.settings[s.name].get())
コード例 #58
0
ファイル: 003-test-config.py プロジェクト: tanish2k/gunicorn
def test_property_access():
    c = config.Config()
    for s in config.KNOWN_SETTINGS:
        getattr(c, s.name)
    
    # Class was loaded
    t.eq(c.worker_class, SyncWorker)
    
    # Debug affects workers
    t.eq(c.workers, 1)
    c.set("workers", 3)
    t.eq(c.workers, 3)
    
    # Address is parsed
    t.eq(c.address, ("127.0.0.1", 8000))
    
    # User and group defaults
    t.eq(os.geteuid(), c.uid)
    t.eq(os.getegid(), c.gid)
    
    # Proc name
    t.eq("gunicorn", c.proc_name)
    
    # Not a config property
    t.raises(AttributeError, getattr, c, "foo")
    # Force to be not an error
    class Baz(object):
        def get(self):
            return 3.14
    c.settings["foo"] = Baz()
    t.eq(c.foo, 3.14)

    # Attempt to set a cfg not via c.set
    t.raises(AttributeError, setattr, c, "proc_name", "baz")
    
    # No setting for name
    t.raises(AttributeError, c.set, "baz", "bar")
コード例 #59
0
 def mktgt(task):
     return sorted(task.sources)
     t.eq(sorted(task.sources), )
     out.write_bytes(data.bytes())
コード例 #60
0
ファイル: treq.py プロジェクト: rclmenezes/djangotogo
 def check(self, cfg, sender, sizer, matcher):
     cases = self.expect[:]
     p = RequestParser(cfg, sender())
     for req in p:
         self.same(req, sizer, matcher, cases.pop(0))
     t.eq(len(cases), 0)