Files
@ bc5447146f6c
Branch filter:
Location: rattail-project/rattail/tests/batch/test_product.py - annotation
bc5447146f6c
1.7 KiB
text/x-python
docs: refactor importer command docs, per typer
8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 8ae4de7d5939 | # -*- coding: utf-8; -*-
from __future__ import unicode_literals, absolute_import
from unittest import TestCase
import sqlalchemy as sa
from rattail.batch import product as mod
from rattail.config import make_config
from rattail.db import Session
class TestProductBatchHandler(TestCase):
def setUp(self):
self.config = self.make_config()
self.handler = self.make_handler()
def make_config(self):
return make_config([], extend=False)
def make_handler(self):
return mod.ProductBatchHandler(self.config)
def test_make_label_batch(self):
engine = sa.create_engine('sqlite://')
model = self.config.get_model()
model.Base.metadata.create_all(bind=engine)
session = Session(bind=engine)
# prep data
betty = model.User(username='betty')
prodbatch = model.ProductBatch(id=1, created_by=betty)
session.add(prodbatch)
session.commit()
# make basic label batch
lblbatch = self.handler.make_label_batch(prodbatch, betty, id=2)
self.assertIsNotNone(lblbatch)
self.assertEqual(lblbatch.id, 2)
def test_make_pricing_batch(self):
engine = sa.create_engine('sqlite://')
model = self.config.get_model()
model.Base.metadata.create_all(bind=engine)
session = Session(bind=engine)
# prep data
betty = model.User(username='betty')
prodbatch = model.ProductBatch(id=1, created_by=betty)
session.add(prodbatch)
session.commit()
# make basic pricing batch
prcbatch = self.handler.make_pricing_batch(prodbatch, betty, id=2)
self.assertIsNotNone(prcbatch)
self.assertEqual(prcbatch.id, 2)
|