Skip to content

Commit

Permalink
swap
Browse files Browse the repository at this point in the history
  • Loading branch information
John Major committed Oct 29, 2023
1 parent b17ea72 commit 8933aee
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 1,012 deletions.
52 changes: 52 additions & 0 deletions tests/test_creating_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os

def test_creating_zpl_from_template():

from zebra_day import print_mgr as zd
zd_pm = zd.zpl()
zd_pm.clear_printers_json()

zpl = zd_pm.formulate_zpl(uid_barcode='TESTBC', alt_a='A', alt_b='B', alt_c='C', alt_d='D', alt_e='E', alt_f='F', label_zpl_style='test_2inX1in')
assert zpl == """^XA\n^FO235,20\n^BY1\n^B3N,N,40,N,N\n^FDTESTBC^FS\n^FO235,70\n^ADN,30,20\n^FDTESTBC^FS\n^FO235,115\n^ADN,25,12\n^FDalt_a^FS\n^FO235,145\n^ADN,25,12\n^FDalt_b^FS\n^FO70,180\n^FO235,170\n^ADN,30,20\n^FDalt_c^FS\n^FO490,180\n^ADN,25,12\n^FDalt_d^FS\n^XZ"""


def test_creating_a_png_of_label_zpl():

import random
from zebra_day import print_mgr as zd
zd_pm = zd.zpl()
zd_pm.clear_printers_json()
zpl = zd_pm.formulate_zpl(uid_barcode='TESTBC', alt_a='A', alt_b='B', alt_c='C', alt_d='D', alt_e='E', alt_f='F', label_zpl_style='test_2inX1in')
tmp_png = f"{os.path.dirname(zd.__file__)}/files/test_png_{random.randint(0,101010)}.png"
tmp_full_png = zd_pm.generate_label_png(zpl_string=zpl, png_fn=tmp_png, relative=False)

assert os.path.abspath(tmp_png) == os.path.abspath(tmp_full_png)


def test_printing_label():
# Also prints a png, but uses the label printing path to do so.

from zebra_day import print_mgr as zd
zd_pm = zd.zpl()
zd_pm.clear_printers_json()

zd_pm.create_new_printers_json_with_single_test_printer()
tmp_png_2 = zd_pm.print_zpl(lab="scan-results", printer_name="Download-Label-png", uid_barcode='TESTBC', alt_a='A', alt_b='B', alt_c='C', alt_d='D', alt_e='E', alt_f='F', label_zpl_style="test_2inX1in", client_ip='pkg', print_n=1, zpl_content=None)

assert os.path.exists(tmp_png_2)


def test_probing_network_for_printers():
# Expected to fail, testing if the top level png printer is added


from zebra_day import print_mgr as zd
zd_pm = zd.zpl()
zd_pm.clear_printers_json()
zd_pm.create_new_printers_json_with_single_test_printer()

# Set the scan wait to FAR too short. Good values are like 0.5+
zd_pm.probe_zebra_printers_add_to_printers_json(ip_stub="192.168.1", scan_wait="0.01",lab="unit_test")

# this just sees if the mechanise work... can't scan the network.
assert 'unit_test' in zd_pm.printers['labs']
10 changes: 0 additions & 10 deletions tests/test_example.py

This file was deleted.

Loading

0 comments on commit 8933aee

Please sign in to comment.