How to use segno - 10 common examples

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_cli.py View on Github external
def test_unit():
    args = cli.parse([''])
    assert args.unit is None
    assert cli.build_config(args)['unit'] is None
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
encoding=1)
    data = make_epc_qr_data(**kw)
    assert len(data) == 96  # See. EPC069-12 Version 2.1 dtd. 9 February 2012 example 1
    encoding = 'utf-8'
    d = [x.decode(encoding) for x in data.split(b'\n')]
    assert 10 == len(d)
    assert 'BCD' == d[0]
    assert '002' == d[1]
    assert '1' == d[2]
    assert 'SCT' == d[3]
    assert name == d[5]
    assert iban == d[6]
    assert 'EUR12.3' == d[7]
    assert purpose == d[8]
    assert reference == d[9]
    qr = make_epc_qr(**kw)
    assert qr
    assert not qr.is_micro
    assert qr.version <= 13
    assert 'M' == qr.error
github heuer / segno / tests / test_helpers_epcqr.py View on Github external
def test_valid_encoding(encoding):
    kw = _make_valid_kw()
    kw['name'] = 'Simple name'
    kw['encoding'] = encoding
    d = make_epc_qr_data(**kw).split(b'\n')
    assert str(encoding).encode() == d[2]
    qr = make_epc_qr(**kw)
    assert qr
github heuer / segno / tests / test_qrcode.py View on Github external
def test_save_eps_filename():
    qr = segno.make_qr('test')
    with tempfile.NamedTemporaryFile('w', suffix='.eps', delete=False) as f:
        fn = f.name
    qr.save(fn)
    expected = '%!PS-Adobe-3.0 EPSF-3.0'
    with open(fn, mode='r') as f:
        val = f.read(len(expected))
    os.unlink(fn)
    assert expected == val
github heuer / segno / tests / test_qrcode.py View on Github external
def test_save_png_filestream():
    qr = segno.make_qr('test')
    with tempfile.NamedTemporaryFile('wb', suffix='.png', delete=False) as f:
        fn = f.name
        qr.save(f)
    expected = b'\211PNG\r\n\032\n'  # PNG magic number
    with open(fn, mode='rb') as f:
        val = f.read(len(expected))
    os.unlink(fn)
    assert expected == val
github heuer / segno / tests / test_png.py View on Github external
def test_color_rgba2():
    qr = segno.make_qr('test')
    out = io.BytesIO()
    qr.save(out, kind='png', dark='#000', light='#0000ffcc')
    assert _has_palette(out.getvalue())
    assert _has_transparency(out.getvalue())
github heuer / segno / tests / test_pdf.py View on Github external
def test_illegal_color_float():
    color = (.1, 1.1, .1)
    qr = segno.make_qr('test')
    out = io.BytesIO()
    with pytest.raises(ValueError):
        qr.save(out, kind='pdf', dark=color)