Exemple #1
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
Exemple #2
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
Exemple #3
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"]]
Exemple #4
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
Exemple #5
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
Exemple #6
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
Exemple #7
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"]
            ]
Exemple #8
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
Exemple #9
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
Exemple #10
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
Exemple #11
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
Exemple #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.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
Exemple #13
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
Exemple #14
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
Exemple #15
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
Exemple #16
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
Exemple #17
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
Exemple #18
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
Exemple #19
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