def test_create_different_created_updated_time(self): from billy.models import tables model = self.make_one(self.session) results = [ datetime.datetime(2013, 8, 16, 1), datetime.datetime(2013, 8, 16, 2), ] def mock_utcnow(): return results.pop(0) tables.set_now_func(mock_utcnow) with db_transaction.manager: guid = model.create( subscription_guid=self.subscription_guid, transaction_type=model.TYPE_CHARGE, amount=100, payment_uri='/v1/cards/tester', scheduled_at=datetime.datetime.utcnow(), ) transaction = model.get(guid) self.assertEqual(transaction.created_at, transaction.updated_at)
def test_create_different_created_updated_time(self): from billy.models import tables model = self.make_one(self.session) results = [ datetime.datetime(2013, 8, 16, 1), datetime.datetime(2013, 8, 16, 2), ] def mock_utcnow(): return results.pop(0) tables.set_now_func(mock_utcnow) with transaction.manager: guid = model.create('my_secret_key') company = model.get(guid) self.assertEqual(company.created_at, company.updated_at)
def test_create_different_created_updated_time(self): from billy.models import tables model = self.make_one(self.session) results = [ datetime.datetime(2013, 8, 16, 1), datetime.datetime(2013, 8, 16, 2), ] def mock_utcnow(): return results.pop(0) tables.set_now_func(mock_utcnow) with db_transaction.manager: guid = model.create( customer_guid=self.customer_tom_guid, plan_guid=self.monthly_plan_guid, ) subscription = model.get(guid) self.assertEqual(subscription.created_at, subscription.updated_at)
def test_create_different_created_updated_time(self): from billy.models import tables model = self.make_one(self.session) results = [ datetime.datetime(2013, 8, 16, 1), datetime.datetime(2013, 8, 16, 2), ] def mock_utcnow(): return results.pop(0) tables.set_now_func(mock_utcnow) with transaction.manager: guid = model.create( company_guid=self.company_guid, plan_type=model.TYPE_CHARGE, amount=999, frequency=model.FREQ_MONTHLY, ) plan = model.get(guid) self.assertEqual(plan.created_at, plan.updated_at)
def setUp(self): self.session = create_session() self._old_now_func = tables.set_now_func(datetime.datetime.utcnow) self.dummy_processor = DummyProcessor() self.model_factory = ModelFactory( session=self.session, processor_factory=lambda: self.dummy_processor, settings={}, ) self.company_model = self.model_factory.create_company_model() self.customer_model = self.model_factory.create_customer_model() self.plan_model = self.model_factory.create_plan_model() self.subscription_model = self.model_factory.create_subscription_model() self.invoice_model = self.model_factory.create_invoice_model() self.transaction_model = self.model_factory.create_transaction_model() self.transaction_failure_model = self.model_factory.create_transaction_failure_model()
def tearDown(self): self.session.close() self.session.remove() tables.DeclarativeBase.metadata.drop_all() self.session.bind.dispose() tables.set_now_func(self._old_now_func)
def tearDown(self): from billy.models import tables self.session.remove() tables.DeclarativeBase.metadata.drop_all() tables.set_now_func(self._old_now_func)
def setUp(self): from billy.models import tables self.session = create_session() self._old_now_func = tables.set_now_func(datetime.datetime.utcnow)