Ejemplo n.º 1
0
def main():
    app = flask.Flask(__name__)
    app.config.from_envvar('SETTINGS')
    gthnk.db.init_app(app)
    with app.app_context():
        librarian = Librarian(app)
        librarian.rotate_buffers()
        # also export the journal for safe-keeping
        librarian.export_journal()
Ejemplo n.º 2
0
    def test_export(self):
        export_path = flask.current_app.config["EXPORT_PATH"]
        clean_tmp_export(export_path)

        librarian = Librarian(self.app)
        librarian.rotate_buffers()
        librarian.export_journal()

        self.assertEqual(len(glob.glob(os.path.join(export_path, "*"))), 6,
                         "correct number of directories created")
        self.assertEqual(
            len(glob.glob(os.path.join(export_path, "text", "*"))), 1,
            "correct number of text files created")
        self.assertEqual(
            len(glob.glob(os.path.join(export_path, "markdown", "*"))), 1,
            "correct number of markdown files created")

        clean_tmp_export(export_path)
Ejemplo n.º 3
0
 def test_rotate(self):
     librarian = Librarian(self.app)
     librarian.rotate_buffers()
     self.assertEqual(Day.query.count(), 1, "1 day has been created")
     self.assertEqual(Entry.query.count(), 4, "4 entries have been created")
Ejemplo n.º 4
0
def journal_export():
    from gthnk.librarian import Librarian
    with app.app_context():
        librarian = Librarian(app)
        librarian.export_journal()
Ejemplo n.º 5
0
 def refresh(self):
     librarian = Librarian(flask.current_app)
     librarian.rotate_buffers()
     return flask.redirect(flask.url_for('.latest_view'))