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()
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)
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")
def refresh(self): librarian = Librarian(flask.current_app) librarian.rotate_buffers() return flask.redirect(flask.url_for('.latest_view'))