예제 #1
0
def req_url(tid=None):
    from ..config import config as c
    from dxpy.web.urls import req_url
    if tid is None:
        return req_url(c['names'], c['ip'], c['port'], None, c['version'],
                       c['base'])
    else:
        return req_url(c['name'], c['ip'], c['port'], tid, c['version'],
                       c['base'])
예제 #2
0
파일: test_urls.py 프로젝트: Hong-Xiang/dxl
 def test_req_url_empty_base_1(self):
     result = urls.req_url('task', '127.0.0.1', 23300, 10, 0.1, '/')
     expect = 'http://127.0.0.1:23300/api/v0.1/task/10'
예제 #3
0
파일: test_urls.py 프로젝트: Hong-Xiang/dxl
 def test_req_url_non_suffix(self):
     result = urls.req_url('tasks', '127.0.0.1', 23300, None, 0.1, '/')
     expect = 'http://127.0.0.1:23300/api/v0.1/tasks/'
예제 #4
0
파일: test_urls.py 프로젝트: Hong-Xiang/dxl
 def test_req_url_non_empty_base_2(self):
     result = urls.req_url('task', '127.0.0.1', 23300, 10, 0.1, 'parent')
     expect = 'http://127.0.0.1:23300/api/v0.1/parent/task/10'
     self.assertEqual(result, expect)
예제 #5
0
def delete(tid):
    r = requests.delete(req_url(tid))
    if r.status_code == 404:
        raise TaskNotFoundError(tid)
예제 #6
0
def update(task_json):
    task_json_dct = json.loads(task_json)
    r = requests.put(req_url(task_json_dct['id']), data={'task': task_json})
    if r.status_code == 404:
        raise TaskNotFoundError(task_json_dct['id'])
예제 #7
0
def read_all():
    return rx.Observable.from_(json.loads(requests.get(req_url()).text))
예제 #8
0
def read(tid):
    r = requests.get(req_url(tid))
    if r.status_code == 200:
        return r.text
    else:
        raise TaskNotFoundError(tid)
예제 #9
0
def create(task_json):
    r = requests.post(req_url(), {'task': task_json})
    return r.json()['id']