示例#1
0
                ok(x) == [b'redirect to /api/v1/orders/']
                ok(sr.status) == "301 Moved Permanently"
                ok(sr.headers) == [("Content-Type",
                                    "text/plain;charset=utf-8"),
                                   ("Content-Length", "27"),
                                   ("Location", "/api/v1/orders/")]
            #
            for meth in ("GET", "HEAD"):
                sr = StartResponse()
                x = app(new_env(meth, "/api/v1/orders/123/"), sr)
                ok(x) == [b'redirect to /api/v1/orders/123']
                ok(sr.status) == "301 Moved Permanently"
                ok(sr.headers) == [("Content-Type",
                                    "text/plain;charset=utf-8"),
                                   ("Content-Length", "30"),
                                   ("Location", "/api/v1/orders/123")]

        @test("redirect is available only when GET or HEAD method.")
        def _(self):
            sr = StartResponse()
            x = app(new_env("POST", "/api/v1/orders"), sr)
            ok(x) == [b'<h2>404 Not Found</h2>']
            ok(sr.status) == "404 Not Found"
            ok(sr.headers) == [("Content-Type", "text/html;charset=utf-8"),
                               ("Content-Length", "22")]


if __name__ == '__main__':
    import oktest
    oktest.main()
        expected = sorted(os.listdir('/'))
        ok(sorted(utils.run_locally('ls /').split())) == expected

    @test("test_local_executor_sleep1")
    def test_sleep1(self):
        t = time.time()
        with self.assertRaises(RuntimeError):
            utils.run_locally(['sleep', '20'], timeout=1)
        ok(time.time() - t) < 1.2

    @test("test_local_executor_sleep2")
    def test_sleep2(self):
        t = time.time()
        with self.assertRaises(RuntimeError):
            utils.run_locally('sleep 20', timeout=1)
        ok(time.time() - t) < 1.2

    @test("test_ssh_executor1")
    def test_ssh_executor1(self):
        id_rsa_path = os.path.expanduser('~/.ssh/id_rsa')
        ssh_url = "ssh://localhost::" + id_rsa_path
        expected = sorted(os.listdir('/'))

        conn = ssh_utils.connect(ssh_url)
        out = ssh_utils.run_over_ssh(conn, "ls /")
        ok(sorted(out.split())) == expected


if __name__ == '__main__':
    main()
示例#3
0
		ok(data['links'][0]['url']) == "http://www.wikipedia.com/AlbertEinstein"
		ok(data['links'][0]['comment']) == "Wikipedia"

	@test("can edit person's name")
	def _(self):
		self.p.person(self.id).put({"name": "Albert Einstein"})
		result = self.p.person(self.id).get()
		ok(result['result']['name']) == "Albert Einstein"

	@test("can delete person")
	def _(self):
		result = self.p.person(self.id).delete()
		ok(result) == True
		def f():
			result = self.p.person(self.id).get()
		ok (f).raises(HttpClientError)

	@test("cannot delete person twice")
	def _(self):
		result = self.p.person(self.id).delete()
		ok(result) == True
		
		def f():
			self.p.person(self.id).delete()
		ok (f).raises(HttpClientError)

## invoke tests
if __name__ == '__main__':
	import oktest
	oktest.main()
        tasks_dir = os.path.dirname(agent.__file__)
        fname = os.path.join(tasks_dir, 'io_scenario_ceph.cfg')
        fc = open(fname).read()

        sections = P(fc, {'FILENAME': '/dev/null'})
        sections = list(sections)

        ok(len(sections)) == 7 * 9 * 4 + 7

        etime = agent.calculate_execution_time(sections)
        # ramptime optimization
        expected_time = (60 * 7 + 30) * 9 * 4 + (60 * 7 + 30)
        ok(etime) == expected_time

if __name__ == '__main__':
    main()

# def do_run_fio_fake(bconf):
#     def estimate_iops(sz, bw, lat):
#         return 1 / (lat + float(sz) / bw)
#     global count
#     count += 1
#     parsed_out = []

#     BW = 120.0 * (1024 ** 2)
#     LAT = 0.003

#     for name, cfg in bconf:
#         sz = to_bytes(cfg['blocksize'])
#         curr_lat = LAT * ((random.random() - 0.5) * 0.1 + 1)
#         curr_ulat = curr_lat * 1000000