Files
@ 93889b9694f4
Branch filter:
Location: rattail-project/rattail/tests/test_clientele.py - annotation
93889b9694f4
1.3 KiB
text/x-python
bump: version 0.18.12 → 0.19.0
ae517ada0970 ae517ada0970 ae517ada0970 ae517ada0970 ae517ada0970 1641e0ea14d6 ae517ada0970 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d ae517ada0970 9fcbdb023c5d ae517ada0970 9fcbdb023c5d 1641e0ea14d6 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d ae517ada0970 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d ae517ada0970 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d ae517ada0970 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d ae517ada0970 9fcbdb023c5d 9fcbdb023c5d 9fcbdb023c5d ae517ada0970 9fcbdb023c5d 9fcbdb023c5d | # -*- coding: utf-8; -*-
from unittest import TestCase
from rattail import clientele
from rattail.config import RattailConfig
try:
import sqlalchemy as sa
except ImportError:
pass
else:
class TestClienteleHandler(TestCase):
def setUp(self):
self.config = RattailConfig()
self.app = self.config.get_app()
self.handler = clientele.ClienteleHandler(self.config)
self.engine = sa.create_engine('sqlite://')
self.app.model.Base.metadata.create_all(bind=self.engine)
def test_get_all_customers(self):
model = self.app.model
session = self.app.make_session(bind=self.engine)
# add some customers
session.add(model.Customer(name='Fred Flintstone'))
session.add(model.Customer(name='Wilma Flintstone'))
session.add(model.Customer(name='Barney Rubble', active_in_pos=False))
# getting "all" will exclude inactive by default
customers = self.handler.get_all_customers(session)
self.assertEqual(len(customers), 2)
# but we can request them too
customers = self.handler.get_all_customers(session, include_inactive=True)
self.assertEqual(len(customers), 3)
session.commit()
session.close()
|