Ejemplo n.º 1
0
def test_serialization_data():
    zdoc = ZPLDocument()
    zdoc.add_serialization_data(111, 1)
    assert(zdoc.zpl_bytes == b'^XA\n^SN111,1,N\n^XZ')
    zdoc = ZPLDocument()
    zdoc.add_serialization_data(999999999999, -99999999999, 'Y')
    assert(zdoc.zpl_bytes == b'^XA\n^SN999999999999,-99999999999,Y\n^XZ')
Ejemplo n.º 2
0
def test_serialization_data_starting_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_serialization_data(1000000000000, 1)
    with pytest.raises(Exception):
        zdoc.add_serialization_data(-1, 1)
    with pytest.raises(Exception):
        zdoc.add_serialization_data('A', 1)
Ejemplo n.º 3
0
def test_serialization_data_change_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_serialization_data(1, 1000000000000)
    with pytest.raises(Exception):
        zdoc.add_serialization_data(1, -100000000000)
    with pytest.raises(Exception):
        zdoc.add_serialization_data(1, 'A')
Ejemplo n.º 4
0
def test_print_quantity_replicates_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, -1)
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, 'A')
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, 100000000)
Ejemplo n.º 5
0
def test_field_origin():
    zdoc = ZPLDocument()
    zdoc.add_field_origin(1000, 999, 2)
    assert (zdoc.zpl_bytes == b'^XA\n^FO1000,999,2\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_origin()
    assert (zdoc.zpl_bytes == b'^XA\n^FO0,0\n^XZ')
Ejemplo n.º 6
0
def test_print_quantity_pause_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, -1)
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 'A')
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 100000000)
Ejemplo n.º 7
0
def test_print_quantity_range():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_print_quantity(0)
    with pytest.raises(Exception):
        zdoc.add_print_quantity('A')
    with pytest.raises(Exception):
        zdoc.add_print_quantity(100000000)
Ejemplo n.º 8
0
def test_graphic_field(image):
    zdoc = ZPLDocument()
    zdoc.add_graphic_field(image, 1)
    assert zdoc.zpl_bytes == b'^XA\n^GFA,2,1,1,00\n^XZ'

    zdoc = ZPLDocument()
    zdoc.add_graphic_field(image, 2, 2)
    expected = b'^XA\n^GFA,4,2,1,0000\n^XZ'
    assert zdoc.zpl_bytes == expected
Ejemplo n.º 9
0
def test_graphic_circle_errors():
    zdoc = ZPLDocument()
    with pytest.raises(ValueError):
        for val in ('A', 2, 4096, '', None):
            zdoc.add_graphic_circle(val)

    with pytest.raises(ValueError):
        for val in ('A', 0, 4096, '', None):
            zdoc.add_graphic_circle(100, val)

    with pytest.raises(ValueError):
        for val in ('A', 3, '', None):
            zdoc.add_graphic_circle(100, 2, val)
Ejemplo n.º 10
0
def test_printer_sleep_bad_shutdown_while_queued():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_printer_sleep(10, 'A')

    with pytest.raises(Exception):
        zdoc.add_printer_sleep(10, 12)
Ejemplo n.º 11
0
def test_printer_sleep_bad_sleep_seconds():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_printer_sleep('A', 'N')

    with pytest.raises(Exception):
        zdoc.add_printer_sleep(-1, 'N')
Ejemplo n.º 12
0
def test_text_blocks_bad_block_rotation():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_text_blocks('Z', 1000, 500)

    with pytest.raises(Exception):
        zdoc.add_text_blocks(2, 1000, 500)
Ejemplo n.º 13
0
def test_text_blocks_bad_block_width():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_text_blocks('N', 0, 500)

    with pytest.raises(Exception):
        zdoc.add_text_blocks('N', 'FC', 500)
Ejemplo n.º 14
0
def test_text_blocks_bad_block_height():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_text_blocks('N', 1000, 0)

    with pytest.raises(Exception):
        zdoc.add_text_blocks('N', 1000, 'ABC')
Ejemplo n.º 15
0
def test_start_print_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_start_print(-1)

    with pytest.raises(Exception):
        zdoc.add_start_print(32001)
Ejemplo n.º 16
0
def test_print_quantity():
    zdoc = ZPLDocument()
    zdoc.add_print_quantity(4)
    assert (zdoc.zpl_bytes == b'^XA\n^PQ4,0,0,N,Y\n^XZ')
Ejemplo n.º 17
0
def test_printer_sleep():
    zdoc = ZPLDocument()
    zdoc.add_printer_sleep(10, 'Y')
    assert (zdoc.zpl_bytes == b'^XA\n^ZZ10,Y\n^XZ')
Ejemplo n.º 18
0
def text_print_quantity_cut_on_error():
    zdoc = ZPLDocument()
    zdoc.add_print_quantity(1000, 22, 901, 'Y', 'N')
    assert (zdoc.zpl_bytes == b'^XA\n^PQ1000,22,901,Y,N\n^XZ')
Ejemplo n.º 19
0
def text_print_quantity_override():
    zdoc = ZPLDocument()
    zdoc.add_print_quantity(1000, 22, 901, 'Y')
    assert (zdoc.zpl_bytes == b'^XA\n^PQ1000,22,901,Y,Y\n^XZ')
Ejemplo n.º 20
0
def text_print_quantity_replicates():
    zdoc = ZPLDocument()
    zdoc.add_print_quantity(1000, 22, 901)
    assert (zdoc.zpl_bytes == b'^XA\n^PQ1000,22,901,N,Y\n^XZ')
Ejemplo n.º 21
0
def text_print_quantity_pause():
    zdoc = ZPLDocument()
    zdoc.add_print_quantity(4, 5)
    assert (zdoc.zpl_bytes == b'^XA\n^PQ4,5,0,N,Y\n^XZ')
Ejemplo n.º 22
0
def test_text_blocks():
    zdoc = ZPLDocument()
    zdoc.add_text_blocks('N', 1000, 500)
    assert (zdoc.zpl_bytes == b'^XA\n^TBN,1000,500\n^XZ')
Ejemplo n.º 23
0
from simple_zpl2 import ZPLDocument, QR_Barcode

zpl = ZPLDocument()

zpl.add_comment('Create a QR Code')
zpl.add_field_origin(20, 20)
qr_data = 'This is data inside a QR code.  This is a barcode often read by cell phones.'
qr = QR_Barcode(qr_data, 2, 2, zpl._QR_ERROR_CORRECTION_STANDARD)
zpl.add_barcode(qr)

zpl.add_comment('Now some text')
zpl.add_field_origin(200, 20)
zpl.add_font('C', zpl._ORIENTATION_NORMAL, 15)
zpl.add_field_data('Text on Label')

# Print generated text
print(zpl.zpl_text)
Ejemplo n.º 24
0
def test_print_quantity_override_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, 0, 'A')
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, 0, 10)
Ejemplo n.º 25
0
def test_field_data():
    zdoc = ZPLDocument()
    zdoc.add_field_data('data')
    assert (zdoc.zpl_bytes == b'^XA\n^FDdata^FS\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_data(['data', 'data2', 'data3'])
    assert (zdoc.zpl_bytes == b'^XA\n^FDdata^FSdata2^FSdata3^FS\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_data('data\ndata2')
    assert (zdoc.zpl_bytes == b'^XA\n^FDdata\ndata2^FS\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_data('data\ndata2', True)
    assert (zdoc.zpl_bytes == b'^XA\n^FDdata\\&data2^FS\n^XZ')
Ejemplo n.º 26
0
def test_comment():
    zdoc = ZPLDocument()
    zdoc.add_comment('Testing Comment')
    assert zdoc.zpl_bytes == b'^XA\n^FXTesting Comment^FS\n^XZ'
Ejemplo n.º 27
0
def test_field_block_error():
    for width in (-1, 'A', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_block(width=width)

    for lines in (0, 10000, 'A', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_block(max_lines=lines)

    for space in (-10000, 10000, 'A', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_block(dots_between_lines=space)

    for justify in (0, 'Q', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_block(text_justification=justify)

    for indent in (-1, 10000, 'B', '', None):
        with pytest.raises(Exception):
            zdoc = ZPLDocument()
            zdoc.add_field_block(hanging_indent=indent)
Ejemplo n.º 28
0
def test_serialization_data_add_leading_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_serialization_data(1, 1, 'A')
    with pytest.raises(Exception):
        zdoc.add_serialization_data(1, 1, 1)
Ejemplo n.º 29
0
def test_print_quantity_cut_on_error_error():
    zdoc = ZPLDocument()
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, 0, 'N', 1)
    with pytest.raises(Exception):
        zdoc.add_print_quantity(1, 0, 0, 'N', 'A')
Ejemplo n.º 30
0
def test_field_block():
    zdoc = ZPLDocument()
    zdoc.add_field_block()
    assert (zdoc.zpl_bytes == b'^XA\n^FB0,1,0,L,0\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_block(1000)
    assert (zdoc.zpl_bytes == b'^XA\n^FB1000,1,0,L,0\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_block(100, 99)
    assert (zdoc.zpl_bytes == b'^XA\n^FB100,99,0,L,0\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_block(99, 98, -78)
    assert (zdoc.zpl_bytes == b'^XA\n^FB99,98,-78,L,0\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_block(111, 9999, -9999, 'C')
    assert (zdoc.zpl_bytes == b'^XA\n^FB111,9999,-9999,C,0\n^XZ')

    zdoc = ZPLDocument()
    zdoc.add_field_block(222, 1, 9999, 'R', 9999)
    assert (zdoc.zpl_bytes == b'^XA\n^FB222,1,9999,R,9999\n^XZ')