How to use the segno.helpers._make_epc_qr_data function in segno

To help you get started, we’ve selected a few segno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_remove_dot(amount):
    kw = _make_valid_kw()
    kw['amount'] = amount
    d = make_epc_qr_data(**kw).split(b'\n')
    assert b'EUR5' == d[7]
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_utf8_required():
    kw = _make_valid_kw()
    kw['name'] = 'Funny 😃 name'
    d = make_epc_qr_data(**kw).split(b'\n')
    assert b'1' == d[2]
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_trailing_zeros(expected_amount, amount):
    name = "François D'Alsace S.A."
    iban = 'FR1420041010050500013M02606'
    text = 'Client:Marie Louise La Lune'
    kw = dict(name=name, iban=iban, text=text, amount=amount)
    data = make_epc_qr_data(**kw)
    assert len(data) == 103  # See. EPC069-12 Version 2.1 dtd. 9 February 2012 example 2
    encoding = 'iso-8859-1'
    d = [x.decode(encoding) for x in data.split(b'\n')]
    assert expected_amount == d[7]
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_no_text_no_reference(text, reference):
    kw = _make_valid_kw()
    kw['text'] = text
    kw['reference'] = reference
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'reference' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        make_epc_qr(**kw)
    assert 'reference' in str(ex.value)
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_invalid_amount(amount):
    kw = _make_valid_kw()
    kw['amount'] = amount
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'amount' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        make_epc_qr(**kw)
    assert 'amount' in str(ex.value)
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_illegal_purpose(purpose):
    kw = _make_valid_kw()
    kw['purpose'] = purpose
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'purpose' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        make_epc_qr(**kw)
    assert 'purpose' in str(ex.value)
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_text_too_long():
    kw = _make_valid_kw()
    kw['text'] = 'a' * 141
    kw['reference'] = None
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'text' in str(ex.value)
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_illegal_encoding(encoding):
    kw = _make_valid_kw()
    kw['encoding'] = encoding
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'encoding' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        make_epc_qr(**kw)
    assert 'encoding' in str(ex.value)
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_reference_too_long():
    kw = _make_valid_kw()
    kw['text'] = None
    kw['reference'] = 'r' * 36
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'reference' in str(ex.value)
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_illegal_name(name):
    kw = _make_valid_kw()
    kw['name'] = name
    with pytest.raises(ValueError) as ex:
        make_epc_qr_data(**kw)
    assert 'name' in str(ex.value)
    with pytest.raises(ValueError) as ex:
        make_epc_qr(**kw)
    assert 'name' in str(ex.value)