コード例 #1
0
def test_get_orders(call_and_unpack):
    psc1 = decl.ProcStateCodes(1, 'psc1')
    psc2 = decl.ProcStateCodes(2, 'psc2')

    ec1 = decl.ErrorCodes(11, 'ec1')
    ec2 = decl.ErrorCodes(12, 'ec2')

    d.session.add(decl.InterfaceEvent(1, psc1, ec1))
    d.session.add(decl.InterfaceEvent(2, psc2, ec2))

    assert call_and_unpack('/orders') == [
            {
                'id': 2,
                'eventTime': None,
                'partner': None,
                'msgType': None,
                'procEnv': None,
                'procStateDesc': 'psc2',
                'procMsg': None,
                'procResDesc': 'ec2',
            },
            {
                'id': 1,
                'eventTime': None,
                'partner': None,
                'msgType': None,
                'procEnv': None,
                'procStateDesc': 'psc1',
                'procMsg': None,
                'procResDesc': 'ec1',
            },
        ]
コード例 #2
0
    def test_xml(self, client):
        psc1 = decl.ProcStateCodes(1, 'psc1')

        d.session.add(decl.InterfaceEvent(1, psc1, xml='<foo></foo>'))

        resp = client.post(
            '/orders/1',
            data=json.dumps(
                {'xml': '<bar></bar>'},
                indent=2,
                sort_keys=True
                ),
            content_type='application/json',
            )

        assert json.loads(resp.get_data().decode()) == {
                'id': 1,
                'eventTime': None,
                'partner': None,
                'msgType': None,
                'xml': '<bar></bar>',
                'procEnv': None,
                'procStateDesc': 'psc1',
                'procMsg': None,
                'procResDesc': None,
            }
コード例 #3
0
    def test_cancel(self, client):
        d.session.add(decl.ProcStateCodes(9, 'psc9'))

        d.session.add(decl.InterfaceEvent(1))

        resp = client.post(
            '/orders/1',
            data=json.dumps(
                {'cancel': True},
                indent=2,
                sort_keys=True
                ),
            content_type='application/json',
            )

        assert json.loads(resp.get_data().decode()) == {
                'id': 1,
                'eventTime': None,
                'partner': None,
                'msgType': None,
                'xml': None,
                'procEnv': None,
                'procStateDesc': 'psc9',
                'procMsg': None,
                'procResDesc': None,
            }
コード例 #4
0
    def test_ok(self):
        psc1 = decl.ProcStateCodes(1, 'psc1')
        psc2 = decl.ProcStateCodes(2, 'psc2')

        ec1 = decl.ErrorCodes(11, 'ec1')
        ec2 = decl.ErrorCodes(12, 'ec2')

        d.session.add(decl.InterfaceEvent(1, psc1, ec1))
        d.session.add(decl.InterfaceEvent(2, psc2, ec2))
        d.session.add(decl.InterfaceEvent(3, psc1))
        d.session.add(decl.InterfaceEvent(4))

        assert interface.get_orders() == [
                {
                    'id': 3,
                    'eventTime': None,
                    'partner': None,
                    'msgType': None,
                    'procEnv': None,
                    'procStateDesc': 'psc1',
                    'procMsg': None,
                    'procResDesc': None,
                },
                {
                    'id': 2,
                    'eventTime': None,
                    'partner': None,
                    'msgType': None,
                    'procEnv': None,
                    'procStateDesc': 'psc2',
                    'procMsg': None,
                    'procResDesc': 'ec2',
                },
                {
                    'id': 1,
                    'eventTime': None,
                    'partner': None,
                    'msgType': None,
                    'procEnv': None,
                    'procStateDesc': 'psc1',
                    'procMsg': None,
                    'procResDesc': 'ec1',
                },
            ]
コード例 #5
0
    def test_cancel(self):
        psc1 = decl.ProcStateCodes(1, 'psc1')
        d.session.add(decl.ProcStateCodes(9, 'psc9'))

        ec1 = decl.ErrorCodes(1, 'ec1')

        d.session.add(decl.InterfaceEvent(1, psc1, ec1))

        assert interface.update_order(1, cancel=True) == {
            'id': 1,
            'eventTime': None,
            'partner': None,
            'msgType': None,
            'procEnv': None,
            'procStateDesc': 'psc9',
            'procMsg': None,
            'procResDesc': 'ec1',
            'xml': None,
            }
コード例 #6
0
    def test_resubmit(self):
        d.session.add(decl.ProcStateCodes(1, 'psc1'))
        psc9 = decl.ProcStateCodes(9, 'psc9')

        d.session.add(decl.ErrorCodes(0, 'ec0'))
        ec9 = decl.ErrorCodes(9, 'ec9')

        d.session.add(decl.InterfaceEvent(1, psc9, ec9))

        assert interface.update_order(1, resubmit=True) == {
            'id': 1,
            'eventTime': None,
            'partner': None,
            'msgType': None,
            'procEnv': None,
            'procStateDesc': 'psc1',
            'procMsg': None,
            'procResDesc': 'ec0',
            'xml': None,
            }
コード例 #7
0
    def test_xml(self):
        psc1 = decl.ProcStateCodes(1, 'psc1')

        d.session.add(decl.InterfaceEvent(1, psc1, xml='<foo></foo>'))

        assert interface.update_order(1, xml='<bar></bar>') == {
            'id': 1,
            'eventTime': None,
            'partner': None,
            'msgType': None,
            'procEnv': None,
            'procStateDesc': 'psc1',
            'procMsg': None,
            'procResDesc': None,
            'xml': '<bar></bar>',
            }
コード例 #8
0
def test_get_order(call_and_unpack):
    psc1 = decl.ProcStateCodes(1, 'psc1')

    ec1 = decl.ErrorCodes(11, 'ec1')

    d.session.add(decl.InterfaceEvent(
        1, psc1, ec1, datetime(2017, 1, 1), 'partner1',
        'msgtype1', '<foo></foo>', 'PROD', 'errmsg1'))

    assert call_and_unpack('/orders/1') == {
            'id': 1,
            'eventTime': '2017-01-01T00:00:00',
            'partner': 'partner1',
            'msgType': 'msgtype1',
            'xml': '<foo></foo>',
            'procEnv': 'PROD',
            'procStateDesc': 'psc1',
            'procMsg': 'errmsg1',
            'procResDesc': 'ec1',
        }