fix: Refactor

This commit is contained in:
2025-10-21 12:34:53 -05:00
parent 532dad0ce5
commit 5386355c7f
7 changed files with 21 additions and 16 deletions

View File

View File

@@ -1,9 +1,19 @@
#!/usr/bin/env python3
import sys
import tempfile
import pytz
from datetime import datetime
from .qr_generator import QRCodeGenerator
from .printer_factory import PrinterFactory
from qr_generator import QRCodeGenerator
from printer_factory import PrinterFactory
def get_current_time_america_bogota():
format_ = "%Y-%m-%d %H:%M:%S"
america_bogota_tz = pytz.timezone('America/Bogota')
format_date_time = datetime.now(america_bogota_tz)
return format_date_time.strftime(format_)
def print_bill_format(printer, d, waiter):
@@ -79,8 +89,7 @@ def print_bill_format(printer, d, waiter):
printer.text("Recuerde que la propina es voluntaria.\n")
printer.text("Gracias por visitarnos, vuelva pronto.\n")
printer.text("SOFTWARE POTENCIADO POR ONECLUSTER.ORG.\n")
format_date_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
printer.text(str(format_date_time)+'\n')
printer.text(str(get_current_time_america_bogota())+'\n')
if waiter:
printer.text("Atendido Por: \n")
printer.text(str(waiter)+'\n')
@@ -88,8 +97,7 @@ def print_bill_format(printer, d, waiter):
def print_customer_order_format(printer, d, waiter):
printer.set(align='center', bold=False, height=1, width=1)
format_date_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
printer.text(str(format_date_time)+'\n')
printer.text(str(get_current_time_america_bogota())+'\n')
if waiter:
printer.text("Pedido Por: \n")

View File

@@ -1,7 +1,7 @@
import json
from fastapi import FastAPI, Response
from pydantic import BaseModel
from .formats import print_bill, print_customer_order
from formats import print_bill, print_customer_order
app = FastAPI(
title="Print Server FastAPI",

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from ..qr_generator import QRCodeGenerator
from qr_generator import QRCodeGenerator
def test_generate_qr():

View File

@@ -1,17 +1,13 @@
#!/usr/bin/env python3
from fastapi.testclient import TestClient
from ..main import app
from main import app
from tools import load_json
import json
client = TestClient(app)
def load_json(file_path):
with open(file_path, 'r') as filejson:
return json.load(filejson)
def test_print_bill():
test_info = {
"content": str(

View File

@@ -1,7 +1,7 @@
import unittest
from unittest.mock import patch, MagicMock
from escpos.printer import Dummy
from ..printer_factory import PrinterFactory
from printer_factory import PrinterFactory
class TestPrinterFactory(unittest.TestCase):
@@ -17,7 +17,7 @@ class TestPrinterFactory(unittest.TestCase):
printer = self.factory_dummy._get_printer()
self.assertIsInstance(printer, Dummy)
@patch('Api.printer_factory.Network')
@patch('printer_factory.Network')
def test_create_network_printer(self, mock_network):
"""Test creación de impresora de red con mock"""

View File

@@ -5,3 +5,4 @@ pytest
escpos
qrcode
flake8
pytz