def test(self):
        self.datastore.setup_connection()
        self.datastore.setup_tables()
        active_record_strategy = SQLAlchemyActiveRecordStrategy(
            active_record_class=IntegerSequencedItemRecord,
            session=self.datastore.session,
        )

        # Can't get the single instance before it has been constructed.
        with self.assertRaises(AssertionError):
            get_example_application()

        # Construct single instance.
        init_example_application(
            entity_active_record_strategy=active_record_strategy
        )

        # Can't construct single instance twice.
        with self.assertRaises(AssertionError):
            init_example_application(
                entity_active_record_strategy=active_record_strategy
            )

        # Get the single instance.
        app1 = get_example_application()
        app2 = get_example_application()
        self.assertEqual(id(app1), id(app2))

        # Close single instance.
        close_example_application()

        # Can't get the single instance before it has been constructed.
        with self.assertRaises(AssertionError):
            get_example_application()

        # Construct single instance.
        init_example_application(
            entity_active_record_strategy=active_record_strategy
        )

        # Can't construct single instance twice.
        with self.assertRaises(AssertionError):
            init_example_application(
                entity_active_record_strategy=active_record_strategy
            )

        # Get the single instance.
        app1 = get_example_application()
        app2 = get_example_application()
        self.assertEqual(id(app1), id(app2))
    def test(self):
        self.datastore.setup_connection()
        self.datastore.setup_tables()
        record_manager = SQLAlchemyRecordManager(
            record_class=IntegerSequencedNoIDRecord,
            session=self.datastore.session,
        )

        # Can't get the single instance before it has been constructed.
        with self.assertRaises(AssertionError):
            get_example_application()

        # Construct single instance.
        init_example_application(
            entity_record_manager=record_manager
        )

        # Can't construct single instance twice.
        with self.assertRaises(AssertionError):
            init_example_application(
                entity_record_manager=record_manager
            )

        # Get the single instance.
        app1 = get_example_application()
        app2 = get_example_application()
        self.assertEqual(id(app1), id(app2))

        # Close single instance.
        close_example_application()

        # Can't get the single instance before it has been constructed.
        with self.assertRaises(AssertionError):
            get_example_application()

        # Construct single instance.
        init_example_application(
            entity_record_manager=record_manager
        )

        # Can't construct single instance twice.
        with self.assertRaises(AssertionError):
            init_example_application(
                entity_record_manager=record_manager
            )

        # Get the single instance.
        app1 = get_example_application()
        app2 = get_example_application()
        self.assertEqual(id(app1), id(app2))
Esempio n. 3
0
def hello():
    app = get_example_application()
    entity_id = app.create_new_example(foo="Hello There!").id
    entity = app.example_repository[entity_id]
    return "<h1 style='color:blue'>{}</h1>".format(entity.foo)
Esempio n. 4
0
def hello():
    app = get_example_application()
    entity_id = app.create_new_example(foo='Hello There!').id
    entity = app.example_repository[entity_id]
    return "<h1 style='color:blue'>{}</h1>".format(entity.foo)