Ejemplo n.º 1
0
def fx_method_args(fx_dog):
    return (
        collections.OrderedDict([
            ('a', fx_dog[0]),
            ('b', Product(name=u'Product.name', sale=False)),
            ('c', Gender.female),
            ('d', Way(u'way/path/text')),
            ('e', uuid.UUID('F7DB93E3-731E-48EF-80A2-CAC81E02F1AE')),
            ('f', b'binary data'),
            ('g', 1234),
            ('h', u'text data'),
        ]),
        collections.OrderedDict([
            ('a', fx_dog[1]),
            ('bb', {
                '_type': 'product',
                'name': 'Product.name',
                'price': None,
                'sale': False,
                'url': None,
            }),
            ('c', 'yeoseong'),
            ('dd', 'way/path/text'),
            ('e', 'f7db93e3-731e-48ef-80a2-cac81e02f1ae'),
            ('ff', u'YmluYXJ5IGRhdGE='),
            ('g', 1234),
            ('hh', 'text data'),
        ]),
    )
Ejemplo n.º 2
0
def test_service_client_payload_serialization():
    t = DumbTransport()
    c = SampleService_Client(t)
    c.sample_method(a=Dog(name=u'Dog.name', age=3),
                    b=Product(name=u'Product.name', sale=False),
                    c=Gender.female,
                    d=Way(u'way/path/text'),
                    e=uuid.UUID('F7DB93E3-731E-48EF-80A2-CAC81E02F1AE'),
                    f=b'binary data',
                    g=1234,
                    h=u'text data')
    assert t.latest_call[0] == 'sample_method'
    assert t.latest_call[1] == {
        'a': {
            '_type': 'animal',
            '_tag': 'dog',
            'name': 'Dog.name',
            'kind': None,
            'age': 3,
            'weight': None,
        },
        'bb': {
            '_type': 'product',
            'name': 'Product.name',
            'price': None,
            'sale': False,
            'url': None,
        },
        'c': 'yeoseong',
        'dd': 'way/path/text',
        'e': 'f7db93e3-731e-48ef-80a2-cac81e02f1ae',
        'ff': u'YmluYXJ5IGRhdGE=',
        'g': 1234,
        'hh': 'text data',
    }
Ejemplo n.º 3
0
def test_url_value_error():
    Product(name=u'', sale=True, url=None)  # url field is optional here
    Product(name=u'', sale=True, url='http://example.com/')
    with raises(ValueError):
        # URL cannot contain new lines
        Product(name=u'', sale=True, url='http://example.com/\n')
Ejemplo n.º 4
0
def test_record_optional_initializer():
    product = Product(name=u'coffee', sale=False)
    assert product.name == u'coffee'
    assert product.price is None
    assert not product.sale
    assert product.url is None