コード例 #1
0
def post_to_add_batch(ref, sku, qty, eta):
    url = config.get_api_url()
    r = requests.post(f'{url}/add_batch',
                      json={
                          'ref': ref,
                          'sku': sku,
                          'qty': qty,
                          'eta': eta
                      })
    assert r.status_code == 201
コード例 #2
0
def post_to_allocate(order_id, sku, qty, expect_success=True):
    url = config.get_api_url()

    data = {'orderid': order_id, 'sku': sku, 'qty': qty}
    r = requests.post(f'{url}/allocations', json=data)

    if expect_success:
        assert r.status_code == 202

    return r
コード例 #3
0
ファイル: conftest.py プロジェクト: LiGuoV/Allocate
def wait_for_webapp_to_come_up():
    # deadline = time.time() + 5
    # url = config.get_api_url()
    # while time.time() < deadline:
    #     try:
    #         return requests.get(url)
    #     except ConnectionError:
    #         time.sleep(0.5)
    # pytest.fail('API never came up')
    return requests.get(config.get_api_url())
コード例 #4
0
def post_to_add_batch(ref, sku, qty, eta):
    url = config.get_api_url()
    r = requests.post(f"{url}/add_batch",
                      json={
                          "ref": ref,
                          "sku": sku,
                          "qty": qty,
                          "eta": eta
                      })
    assert r.status_code == 201
コード例 #5
0
ファイル: api_client.py プロジェクト: glestaris/code
def post_to_allocate(orderid, sku, qty, expect_success=True):
    url = config.get_api_url()
    r = requests.post(f"{url}/allocate",
                      json={
                          "orderid": orderid,
                          "sku": sku,
                          "qty": qty,
                      })
    if expect_success:
        assert r.status_code == 202
    return r
コード例 #6
0
def post_to_add_batch(ref, sku, qty, eta):
    url = config.get_api_url()
    r = requests.post(
<<<<<<< HEAD
        f'{url}/add_batch',
        json={'ref': ref, 'sku': sku, 'qty': qty, 'eta': eta}
=======
        f"{url}/add_batch", json={"ref": ref, "sku": sku, "qty": qty, "eta": eta}
>>>>>>> upstream/master
    )
    assert r.status_code == 201
コード例 #7
0
def test_happy_path_returns_201_and_allocated_batch():
    sku, othersku = random_sku(), random_sku('other')
    earlybatch = random_batchref("1")
    laterbatch = random_batchref("2")
    otherbatch = random_batchref("3")
    post_to_add_batch(laterbatch, sku, 100, '2011-01-02')
    post_to_add_batch(earlybatch, sku, 100, '2011-01-01')
    post_to_add_batch(otherbatch, othersku, 100, None)
    data = {'orderid': random_orderid(), 'sku': sku, 'qty': 3}
    url = config.get_api_url()
    r = requests.post(f'{url}/allocate', json=data)
    assert r.status_code == 201
    assert r.json()['batchref'] == earlybatch
コード例 #8
0
def test_happy_path_returns_201_and_allocated_batch():
    sku, othersku = random_sku(), random_sku("other")
    earlybatch = random_batchref(1)
    laterbatch = random_batchref(2)
    otherbatch = random_batchref(3)
    post_to_add_batch(laterbatch, sku, 100, "2011-01-02")
    post_to_add_batch(earlybatch, sku, 100, "2011-01-01")
    post_to_add_batch(otherbatch, othersku, 100, None)
    data = {"orderid": random_orderid(), "sku": sku, "qty": 3}

    url = config.get_api_url()
    r = requests.post(f"{url}/allocate", json=data)

    assert r.status_code == 201
    assert r.json()["batchref"] == earlybatch
コード例 #9
0
ファイル: test_api.py プロジェクト: hbeemster/code
def test_happy_path_returns_202_and_batch_is_allocated():
    orderid = random_orderid()
    sku, othersku = random_sku(), random_sku('other')
    batch1, batch2, batch3 = random_batchref(1), random_batchref(
        2), random_batchref(3)
    post_to_add_batch(batch1, sku, 100, '2011-01-02')
    post_to_add_batch(batch2, sku, 100, '2011-01-01')
    post_to_add_batch(batch3, othersku, 100, None)
    data = {'orderid': orderid, 'sku': sku, 'qty': 3}
    url = config.get_api_url()
    r = requests.post(f'{url}/allocate', json=data)
    assert r.status_code == 202
    r = get_allocation(orderid)
    assert r.ok
    assert r.json() == [
        {
            'sku': sku,
            'batchref': batch2
        },
    ]
コード例 #10
0
def wait_for_webapp_to_come_up():
    return requests.get(config.get_api_url())
コード例 #11
0
ファイル: api_client.py プロジェクト: glestaris/code
def get_allocation(orderid):
    url = config.get_api_url()
    return requests.get(f"{url}/allocations/{orderid}")
コード例 #12
0
def post_to_allocate(orderid, sku, qty, expect_success=True):
    url = config.get_api_url()