def test_is_synced(self): article = Article("Test", "lk", datetime.now(), uuid.uuid4()) article.save_to_db() article.set_title("TestUpdated") article.sync_to_db() self.assertTrue(article.is_synced(), "article marked un-synced when it is") article.remove_from_db()
def test_sync_to_db(self): article = Article("Test", "lk", datetime.now(), uuid.uuid4()) article.save_to_db() article.set_title("TestUpdated") article.sync_to_db() try: test_result = Article.get_by_id(article.get_id()) except NoSuchArticleExistException: self.fail() article.remove_from_db() self.assertEqual(test_result, article, "Sync event with database failed")
def article_edit_put(): try: article_date = datetime.strptime(request.form.get('date'), '%m/%d/%Y %I:%M %p') if request.form.get('publication') is "": new_article = Article(request.form.get('title'), request.form.get('summary'), article_date, uuid.UUID(request.form.get('page_id')), None, uuid.UUID(request.form.get('id'))) else: new_article = Article(request.form.get('title'), request.form.get('summary'), article_date, uuid.UUID(request.form.get('page_id')), request.form.get('publication'), uuid.UUID(request.form.get('id'))) if not new_article.is_valid_model(): abort(500) new_article.sync_to_db() return jsonify({"message": "Done"}), 200 except ValueError: abort(500)