Beispiel #1
0
def _(step, wc, department):
    with app.test_request_context():
        with app.test_client() as c:
            login('s', 's', c)
            rv = c.post('/manufacture/schedule/[%d]' % wc.id,
                        data=dict(department_id=department.id, procedure_id=1))
            assert rv.status_code == 302
Beispiel #2
0
def _(step, node_id):
    with app.test_client() as c:
        login('cc', 'cc', c)
        node = models.Node.query.get(node_id)
        node.approve()
        assert node.approved
        assert node.work_flow.status == yawf.constants.WORK_FLOW_EXECUTED
Beispiel #3
0
def _(step, wc):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('qi', 'qi', c)
            url = url_for('manufacture_ws.work_command',
                          work_command_id=wc.id,
                          action=wc_const.ACT_QI,
                          auth_token=auth_token)
            rv = c.put(url,
                       data={
                           '0.jpeg': (StringIO('foo jpg 0'), '0.jpeg'),
                           '1.jpeg': (StringIO('foo jpg 1'), '1.jpeg'),
                           'qirList':
                           json.dumps([{
                               'result': qi_const.FINISHED,
                               'weight': wc.processed_weight
                           }])
                       })
            assert rv.status_code == 200
            url = url_for('manufacture_ws.work_command',
                          work_command_id=wc.id,
                          auth_token=auth_token)
            rv = c.get(url)
            assert rv.status_code == 200
            d = json.loads(rv.data)
            assert len(d['qirList']) == 1
            qir_dict = d['qirList'][0]
            assert qir_dict['result'] == qi_const.FINISHED
            assert qir_dict['weight'] == wc.processed_weight
            assert qir_dict['quantity'] == wc.processed_weight
            assert qir_dict['actorId'] == current_user.id
            return qir_dict
Beispiel #4
0
def _(step, plate_name, us):
    plate_ = do_commit(models.Plate(name=plate_name))
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(u"/cargo/unload-session/%d" % us.id,
                        data={"plate_": plate_name})
            assert 302 == rv.status_code
Beispiel #5
0
def _(step, wc):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('qi', 'qi', c)
            url = url_for('manufacture_ws.work_command',
                          work_command_id=wc.id,
                          action=wc_const.ACT_QI,
                          auth_token=auth_token)
            rv = c.put(url,
                       data={
                           '0.jpeg': (StringIO('foo jpg 0'), '0.jpeg'),
                           '1.jpeg': (StringIO('foo jpg 1'), '1.jpeg'),
                           'qirList':
                           json.dumps([{'result': qi_const.FINISHED,
                                        'weight': wc.processed_weight}])
                       })
            assert rv.status_code == 200
            url = url_for('manufacture_ws.work_command', work_command_id=wc.id,
                          auth_token=auth_token)
            rv = c.get(url)
            assert rv.status_code == 200
            d = json.loads(rv.data)
            assert len(d['qirList']) == 1
            qir_dict = d['qirList'][0]
            assert qir_dict['result'] == qi_const.FINISHED
            assert qir_dict['weight'] == wc.processed_weight
            assert qir_dict['quantity'] == wc.processed_weight
            assert qir_dict['actorId'] == current_user.id
            return qir_dict
Beispiel #6
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-session/%d" % us.id,
                        data={"__action__": u"生成收货单"})
            assert 302 == rv.status_code
            return db.session.query(models.GoodsReceipt).filter(
                models.GoodsReceipt.unload_session_id == us.id).all()
Beispiel #7
0
def _(step, weight, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-session/%d" % us.id, data={"__action__": u"生成收货单"})
            assert 302 == rv.status_code
            gr = models.GoodsReceipt.query.order_by(models.GoodsReceipt.id.desc()).first()
            assert int(weight) == sum(i.weight for i in gr.goods_receipt_entries)
            return gr
Beispiel #8
0
def _(step):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.get("/cargo/unload-session")
            from bs4 import BeautifulSoup

            soup = BeautifulSoup(rv.data)
            return [i["value"] for i in soup.find_all("option")]
Beispiel #9
0
def _(step):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.get("/cargo/unload-session")
            from bs4 import BeautifulSoup

            soup = BeautifulSoup(rv.data)
            return [i["value"] for i in soup.find_all("option")]
Beispiel #10
0
def _(step, weight, sub_order):
    with app.test_request_context():
        with app.test_client() as c:
            login('s', 's', c)
            rv = c.post('/order/work-command',
                        data=dict(sub_order_id=sub_order.id,
                                  schedule_weight=weight))
            assert rv.status_code == 302
Beispiel #11
0
def _(step, weight, sub_order):
    with app.test_request_context():
        with app.test_client() as c:
            login('s', 's', c)
            rv = c.post('/order/work-command',
                        data=dict(sub_order_id=sub_order.id,
                                  schedule_weight=weight))
            assert rv.status_code == 302
Beispiel #12
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('l', 'l', c)
            rv = c.get("/cargo_ws/unload-session-list?auth_token=" + auth_token)
            from flask import json

            assert not [i for i in json.loads(rv.data)["data"] if not i["isLocked"]]
Beispiel #13
0
def _(step, delivery_session, store_bill1, store_bill2):
    with app.test_client() as c:
        rv = c.post('/auth_ws/login?username=l&password=l')
        assert rv.status_code == 200
        auth_token = json.loads(rv.data)['token']
        rv = c.post("/delivery_ws/delivery-task?sid=%s&is_finished=1&auth_token=%s&remain=%d" % (delivery_session.id, auth_token, store_bill2.weight+1),
                    data=json.dumps([{"store_bill_id": store_bill1.id, "is_finished": 1}, 
                                     {'store_bill_id': store_bill2.id, 'is_finished': 0}]))
        assert rv.status_code == 201 
Beispiel #14
0
def _(step, order):
    for count, sub_order in enumerate(order.sub_order_list):
        with app.test_request_context():
            with app.test_client() as c:
                rv = c.post("/order/sub-order/%d" % sub_order.id, data={"due_time": "2013-08-09"})
                assert 302 == rv.status_code
                if count == len(order.sub_order_list) - 1:
                    rv = c.post("/order/order/%d" % order.id, data={"__action__": u"标记为完善"})
                    assert 302 == rv.status_code
Beispiel #15
0
def _(step, weight, wc):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('tl', 'tl', c)
            rv = c.put(
                '/manufacture_ws/work-command/%d?action=%d&weight=%d&auth_token=%s'
                % (wc.id, lite_mms.constants.work_command.ACT_ADD_WEIGHT,
                   int(weight), auth_token))
            assert rv.status_code == 200
Beispiel #16
0
def _(step, goods_receipt, order_type):
    if order_type == constants.STANDARD_ORDER_TYPE:
        action = u"生成计重类型订单"
    else:
        action = u"生成计件类型订单"
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/goods_receipt/goods-receipt/%d" % goods_receipt.id, data={"__action__": action})
            assert 302 == rv.status_code
            return models.Order.query.order_by(models.Order.id.desc()).first()
Beispiel #17
0
def after_login_then_redirect_to(step, username, password, content):
    from lite_mms.basemain import app
    from lite_mms.permissions import permissions
    import flask.ext.principal as principal
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(url_for("auth.login"),
                        data=dict(username=username, password=password),
                        follow_redirects=True)
            assert_equals(rv.status_code, 200)
            assert_equals(rv.data.decode("utf-8"), content)
Beispiel #18
0
def _(step, wc, department, team):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('dl', 'dl', c)
            url = '/manufacture_ws/work-command/%d?action=%d&team_id=%s\
&auth_token=%s'

            rv = c.put(url %
                       (wc.id, lite_mms.constants.work_command.ACT_ASSIGN,
                        team.id, auth_token))
            assert rv.status_code == 200
Beispiel #19
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('l', 'l', c)
            rv = c.get("/cargo_ws/unload-session-list?auth_token=" +
                       auth_token)
            from flask import json

            assert not [
                i for i in json.loads(rv.data)["data"] if not i["isLocked"]
            ]
Beispiel #20
0
def _(step, weight, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-session/%d" % us.id,
                        data={"__action__": u"生成收货单"})
            assert 302 == rv.status_code
            gr = models.GoodsReceipt.query.order_by(
                models.GoodsReceipt.id.desc()).first()
            assert int(weight) == sum(i.weight
                                      for i in gr.goods_receipt_entries)
            return gr
Beispiel #21
0
def _(step, weight, unload_task):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/weigh-unload-task/%d" % unload_task.id,
                        data={
                            "weight": weight,
                            "product_type": 1,
                            "product": 1,
                            "customer": unload_task.customer.id
                        })
            assert 302 == rv.status_code
Beispiel #22
0
def after_login_then_redirect_to(step, username, password, content):
    from lite_mms.basemain import app
    from lite_mms.permissions import permissions
    import flask.ext.principal as principal
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(url_for("auth.login"), 
                        data=dict(username=username, password=password), 
                        follow_redirects=True) 
            assert_equals(rv.status_code, 200)
            assert_equals(rv.data.decode("utf-8"), content)
Beispiel #23
0
def _(step, wc, department, team):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('dl', 'dl', c)
            url = '/manufacture_ws/work-command/%d?action=%d&team_id=%s\
&auth_token=%s'
            rv = c.put(url % (wc.id,
                              lite_mms.constants.work_command.ACT_ASSIGN,
                              team.id,
                              auth_token))
            assert rv.status_code == 200
Beispiel #24
0
def _(step, delivery_session, store_bill):
    with app.test_request_context():
        with app.test_client() as c:
            login('cc', 'cc', c)
            rv = c.post("/delivery/store-bill-list/%d" % delivery_session.id, data={"store_bill_list": store_bill.id})
            assert 302 == rv.status_code
            rv = c.post('/auth_ws/login?username=l&password=l')
            assert rv.status_code == 200
            auth_token = json.loads(rv.data)['token']
            rv = c.post("/delivery_ws/delivery-task?sid=%s&is_finished=1&remain=0&auth_token=%s" % (delivery_session.id, auth_token),
                        data=json.dumps([{"store_bill_id": store_bill.id, "is_finished": 1}]))
            assert 200 == rv.status_code
Beispiel #25
0
def _(step, delivery_session):
    with app.test_request_context():
        with app.test_client() as c:
            login('cc', 'cc', c)
            rv = c.post("/delivery/create-consignment-list/%s" % delivery_session.id,
                        data={"customer-pay_mod": json.dumps({customer.id: 0 for customer in
                                                              DeliverySessionWrapper(
                                                                  delivery_session).customer_list})})

            assert 302 == rv.status_code

    return models.Consignment.query.order_by(models.Consignment.id.desc()).first()
Beispiel #26
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('l', 'l', c)
            rv = c.post(
                u"/cargo_ws/unload-task?actor_id=1&customer_id=1&harbour=foo车间&is_finished=1&session_id=%d"
                u"&auth_token=%s" % (
                us.id, auth_token))
            assert 200 == rv.status_code
            rv = c.post("/cargo/weigh-unload-task/%s" % rv.data,
                        data={"weight": 2213, "product_type": 1, "product": 1, "customer": 1})
            assert 302 == rv.status_code
Beispiel #27
0
def after_login_then_could(step, username, password):
    from lite_mms.basemain import app
    from lite_mms.permissions import permissions
    import flask.ext.principal as principal
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(url_for("auth.login"), data=dict(username=username, password=password)) 
            assert rv.status_code == 302
            from flask.ext.login import current_user
            for perm_dict in step.hashes:
                need = permissions[perm_dict["permission"]]["needs"][0]
                perm = principal.Permission(need)
                assert perm.can()
Beispiel #28
0
def _(step, delivery_session, store_bill):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('l', 'l', c)
            rv = c.post("/delivery_ws/delivery-task?sid=%s&is_finished=1&remain=0&auth_token=%s" % (delivery_session.id, auth_token),
                        data=json.dumps([{"store_bill_id": store_bill.id, "is_finished": 1}]))
            assert 200 == rv.status_code
            delivery_task = models.DeliveryTask.query.filter(
                models.DeliveryTask.delivery_session == delivery_session).order_by(
                models.DeliveryTask.id.desc()).first()
            login('cc', 'cc', c)
            rv = c.post("/delivery/weigh-delivery-task/%d" % delivery_task.id, data={"weight": 6500})
            assert rv.status_code == 302
Beispiel #29
0
def after_login_then_could(step, username, password):
    from lite_mms.basemain import app
    from lite_mms.permissions import permissions
    import flask.ext.principal as principal
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(url_for("auth.login"),
                        data=dict(username=username, password=password))
            assert rv.status_code == 302
            from flask.ext.login import current_user
            for perm_dict in step.hashes:
                need = permissions[perm_dict["permission"]]["needs"][0]
                perm = principal.Permission(need)
                assert perm.can()
Beispiel #30
0
def _(step, wc, team):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('tl', 'tl', c)
            rv = c.get('/manufacture_ws/work-command-list?team_id=%s&status=%d&auth_token=%s' % (team.id, lite_mms.constants.work_command.STATUS_ENDING, auth_token))
            assert rv.status_code == 200
            d = json.loads(rv.data)['data'][0]
            assert d['customerName'] == wc.sub_order.order.goods_receipt.customer.name
            assert d['team']['id'] == team.id
            assert d['team']['name'] == team.name
            assert d['id'] == wc.id
            assert d['orderID'] == wc.sub_order.order.id
            assert d['subOrderId'] == wc.sub_order.id
            assert d['orgWeight'] == wc.org_weight
Beispiel #31
0
def _(step, wc):
    with app.test_client() as c:
        auth_token = client_login('qi', 'qi', c)
        url = url_for('manufacture_ws.quality_inspection_report_list',
                      work_command_id=wc.id,
                      auth_token=auth_token)
        qir_list = [{'result': qi_const.FINISHED,
                     'weight': wc.processed_weight}]
        rv = c.put(url,
                   data={
                       '0.jpeg': (StringIO('foo jpg 0'), '0.jpg'),
                       '1.jpeg': (StringIO('foo jpg 1'), '1.jpg'),
                       'qirList': json.dumps(qir_list)
                   })
        assert rv.status_code == 200
        return qir_list
Beispiel #32
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('l', 'l', c)
            rv = c.post(
                u"/cargo_ws/unload-task?actor_id=1&customer_id=1&harbour=foo车间&is_finished=1&session_id=%d"
                u"&auth_token=%s" % (us.id, auth_token))
            assert 200 == rv.status_code
            rv = c.post("/cargo/weigh-unload-task/%s" % rv.data,
                        data={
                            "weight": 2213,
                            "product_type": 1,
                            "product": 1,
                            "customer": 1
                        })
            assert 302 == rv.status_code
Beispiel #33
0
def _(step, wc, qir_list):
    with app.test_client() as c:
        auth_token = client_login('qi', 'qi', c)
        url = url_for('manufacture_ws.work_command', work_command_id=wc.id,
                      auth_token=auth_token)
        rv = c.get(url)
        assert rv.status_code == 200
        wc_dict = json.loads(rv.data)
        assert len(wc_dict['qirList']) == 1
        qir_dict1 = wc_dict['qirList'][0]
        qir_dict2 = qir_list[0]

        assert qir_dict1['result'] == qi_const.FINISHED
        assert qir_dict1['weight'] == qir_dict2['weight']
        # 标准类型的质检单,重量与数量相同
        assert qir_dict1['quantity'] == qir_dict2['weight']
        assert qir_dict1['actorId'] == current_user.id
Beispiel #34
0
def _(step, wc, team):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('tl', 'tl', c)
            rv = c.get(
                '/manufacture_ws/work-command-list?team_id=%s&status=%d&auth_token=%s'
                % (team.id, lite_mms.constants.work_command.STATUS_ENDING,
                   auth_token))
            assert rv.status_code == 200
            d = json.loads(rv.data)['data'][0]
            assert d[
                'customerName'] == wc.sub_order.order.goods_receipt.customer.name
            assert d['team']['id'] == team.id
            assert d['team']['name'] == team.name
            assert d['id'] == wc.id
            assert d['orderID'] == wc.sub_order.order.id
            assert d['subOrderId'] == wc.sub_order.id
            assert d['orgWeight'] == wc.org_weight
Beispiel #35
0
def _(step, wc, qir_list):
    with app.test_client() as c:
        auth_token = client_login('qi', 'qi', c)
        url = url_for('manufacture_ws.work_command',
                      work_command_id=wc.id,
                      auth_token=auth_token)
        rv = c.get(url)
        assert rv.status_code == 200
        wc_dict = json.loads(rv.data)
        assert len(wc_dict['qirList']) == 1
        qir_dict1 = wc_dict['qirList'][0]
        qir_dict2 = qir_list[0]

        assert qir_dict1['result'] == qi_const.FINISHED
        assert qir_dict1['weight'] == qir_dict2['weight']
        # 标准类型的质检单,重量与数量相同
        assert qir_dict1['quantity'] == qir_dict2['weight']
        assert qir_dict1['actorId'] == current_user.id
Beispiel #36
0
def _(step, wc):
    with app.test_client() as c:
        auth_token = client_login('qi', 'qi', c)
        url = url_for('manufacture_ws.quality_inspection_report_list',
                      work_command_id=wc.id,
                      auth_token=auth_token)
        qir_list = [{
            'result': qi_const.FINISHED,
            'weight': wc.processed_weight
        }]
        rv = c.put(url,
                   data={
                       '0.jpeg': (StringIO('foo jpg 0'), '0.jpg'),
                       '1.jpeg': (StringIO('foo jpg 1'), '1.jpg'),
                       'qirList': json.dumps(qir_list)
                   })
        assert rv.status_code == 200
        return qir_list
Beispiel #37
0
def _(step, wc, department):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('dl', 'dl', c)
            url = '/manufacture_ws/work-command-list?department_id=%s&\
status=%d&auth_token=%s'
            rv = c.get(url % (department.id,
                              lite_mms.constants.work_command.STATUS_ASSIGNING,
                              auth_token))
            assert rv.status_code == 200
            d = json.loads(rv.data)['data'][0]
            assert d['customerName'] == \
                wc.sub_order.order.goods_receipt.customer.name
            assert d['department']['id'] == department.id
            assert d['department']['name'] == department.name
            assert d['id'] == wc.id
            assert d['orderID'] == wc.sub_order.order.id
            assert d['subOrderId'] == wc.sub_order.id
            assert d['orgWeight'] == wc.org_weight
Beispiel #38
0
def _(step, wc, department):
    with app.test_request_context():
        with app.test_client() as c:
            auth_token = client_login('dl', 'dl', c)
            url = '/manufacture_ws/work-command-list?department_id=%s&\
status=%d&auth_token=%s'

            rv = c.get(
                url %
                (department.id,
                 lite_mms.constants.work_command.STATUS_ASSIGNING, auth_token))
            assert rv.status_code == 200
            d = json.loads(rv.data)['data'][0]
            assert d['customerName'] == \
                wc.sub_order.order.goods_receipt.customer.name
            assert d['department']['id'] == department.id
            assert d['department']['name'] == department.name
            assert d['id'] == wc.id
            assert d['orderID'] == wc.sub_order.order.id
            assert d['subOrderId'] == wc.sub_order.id
            assert d['orgWeight'] == wc.org_weight
Beispiel #39
0
def _(step, weight, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-task/%d" % us.task_list[0].id, data={"weight": weight})
            assert 302 == rv.status_code
Beispiel #40
0
def _(step, weight, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-task/%d" % us.task_list[0].id,
                        data={"weight": weight})
            assert 302 == rv.status_code
Beispiel #41
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-session/%d" % us.id,
                        data={"__action__": u"打开"})
            assert 302 == rv.status_code
Beispiel #42
0
def _(step, weight, unload_task):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/weigh-unload-task/%d" % unload_task.id,
                        data={"weight": weight, "product_type": 1, "product": 1, "customer": unload_task.customer.id})
            assert 302 == rv.status_code
Beispiel #43
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-session/%d" % us.id, data={"__action__": u"打开"})
            assert 302 == rv.status_code
Beispiel #44
0
def _(step, order):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/order/order/%s" % order.id, data={"__action__": u"下发"})
            return rv.status_code
Beispiel #45
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(u"/cargo/unload-session/%d" % us.id, data={"gross_weight": 123123})
            assert 403 == rv.status_code
Beispiel #46
0
def _(step, gr):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/goods_receipt/goods-receipt/%d" % gr.id)
            assert 403 == rv.status_code
Beispiel #47
0
def _(step, gr):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/goods_receipt/goods-receipt/%d" % gr.id, data={"__action__": u"生成计重类型订单"})
            assert 302 == rv.status_code
Beispiel #48
0
def _(step, gr):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/goods_receipt/goods-receipt/%d" % gr.id)
            assert 403 == rv.status_code
Beispiel #49
0
def _(step, ut):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post(u"/cargo/unload-task/%d" % ut.id, data={"weight": 12312})
            assert 403 == rv.status_code
Beispiel #50
0
def _(step, gr):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/goods_receipt/goods-receipt/%d" % gr.id,
                        data={"__action__": u"生成计重类型订单"})
            assert 302 == rv.status_code
Beispiel #51
0
def _(step, ut):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/ajax/unload-task/%d" % ut.id,
                        data={"action": u"delete"})
            return rv.status_code
Beispiel #52
0
def _(step, ut):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/ajax/unload-task/%d" % ut.id, data={"action": u"delete"})
            return rv.status_code
Beispiel #53
0
def _(step, us):
    with app.test_request_context():
        with app.test_client() as c:
            rv = c.post("/cargo/unload-session/%d" % us.id, data={"__action__": u"生成收货单"})
            assert 302 == rv.status_code
            return db.session.query(models.GoodsReceipt).filter(models.GoodsReceipt.unload_session_id == us.id).all()