Exemplo n.º 1
0
class ModelTestCase(unittest.TestCase):

    def setUp(self):
       
        self.session = create_session()
        self._old_now_func = tables.set_now_func(utc_now)

        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)
Exemplo n.º 2
0
class ModelTestCase(unittest.TestCase):
    def setUp(self):

        self.session = create_session()
        self._old_now_func = tables.set_now_func(utc_now)

        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)
Exemplo n.º 3
0
class ViewTestCase(unittest.TestCase):
    def setUp(self):
        self.dummy_processor = DummyProcessor()

        def model_factory_func():
            return self.model_factory

        if not hasattr(self, 'settings'):
            self.settings = {
                'billy.processor_factory': lambda: self.dummy_processor,
                'model_factory_func': model_factory_func,
                # do not remove when a request is processed, so that we don't
                # have to use session.add every time
                'db_session_cleanup': False,
            }

        # init database
        db_url = os.environ.get('BILLY_FUNC_TEST_DB', 'sqlite://')
        self.settings['sqlalchemy.url'] = db_url
        self.settings = setup_database({}, **self.settings)
        DeclarativeBase.metadata.bind = self.settings['engine']
        DeclarativeBase.metadata.create_all()

        app = main({}, **self.settings)
        self.testapp = TestApp(app)
        self.testapp.session = self.settings['session']

        self.dummy_request = DummyRequest()

        # create model factory
        self.model_factory = ModelFactory(
            session=self.testapp.session,
            processor_factory=lambda: self.dummy_processor,
            settings=self.settings,
        )

        # create all models
        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.testapp.session.close()
        self.testapp.session.remove()
        DeclarativeBase.metadata.drop_all()
        self.testapp.session.bind.dispose()
Exemplo n.º 4
0
class ViewTestCase(unittest.TestCase):
    def setUp(self):
        self.dummy_processor = DummyProcessor()

        def model_factory_func():
            return self.model_factory

        if not hasattr(self, "settings"):
            self.settings = {
                "billy.processor_factory": lambda: self.dummy_processor,
                "model_factory_func": model_factory_func,
                # do not remove when a request is processed, so that we don't
                # have to use session.add every time
                "db_session_cleanup": False,
            }

        # init database
        db_url = os.environ.get("BILLY_FUNC_TEST_DB", "sqlite://")
        self.settings["sqlalchemy.url"] = db_url
        self.settings = setup_database({}, **self.settings)
        DeclarativeBase.metadata.bind = self.settings["engine"]
        DeclarativeBase.metadata.create_all()

        app = main({}, **self.settings)
        self.testapp = TestApp(app)
        self.testapp.session = self.settings["session"]

        self.dummy_request = DummyRequest()

        # create model factory
        self.model_factory = ModelFactory(
            session=self.testapp.session, processor_factory=lambda: self.dummy_processor, settings=self.settings
        )

        # create all models
        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.testapp.session.close()
        self.testapp.session.remove()
        DeclarativeBase.metadata.drop_all()
        self.testapp.session.bind.dispose()
Exemplo n.º 5
0
class ViewTestCase(unittest.TestCase):
  
    def setUp(self):
        self.dummy_processor = DummyProcessor()

        def model_factory_func():
            return self.model_factory

        if not hasattr(self, 'settings'):
            self.settings = {
                'billy.processor_factory': lambda: self.dummy_processor,
                'model_factory_func': model_factory_func,
            }

        # init database
        db_url = os.environ.get('BILLY_FUNC_TEST_DB', 'sqlite://')
        self.settings['sqlalchemy.url'] = db_url
        self.settings = setup_database({}, **self.settings)
        DeclarativeBase.metadata.bind = self.settings['engine']
        DeclarativeBase.metadata.create_all()

        app = main({}, **self.settings)
        self.testapp = TestApp(app)
        self.testapp.session = self.settings['session']

        self.dummy_request = DummyRequest()

        # create model factory
        self.model_factory = ModelFactory(
            session=self.testapp.session,
            processor_factory=lambda: self.dummy_processor,
            settings=self.settings,
        )

        # create all models
        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.testapp.session.close()
        self.testapp.session.remove()
        DeclarativeBase.metadata.drop_all()
        self.testapp.session.bind.dispose()