コード例 #1
0
    def test_reconnect_if_mongodb_is_down(self):
        """
        Should reconnect if mongodb is down
        """

        accounts_collection = sut.get_collection("accounts")
        self.assertTrue(bool(accounts_collection))
        sut.disconnect()

        accounts_collection = sut.get_collection("accounts")
        self.assertTrue(bool(accounts_collection))
コード例 #2
0
 def add(self, account_data: AddAccountModel) -> AccountModel:
     account_collection = MongoHelper.get_collection("accounts")
     result = account_collection.insert_one(account_data.dict())
     account = account_collection.find_one({"_id": result.inserted_id})
     return AccountModel(**MongoHelper.map(account))
コード例 #3
0
 def log_error(self, stack: str) -> None:
     error_collection = MongoHelper.get_collection("errors")
     error_collection.insert_one({"stack": stack, "date": datetime.now()})
コード例 #4
0
 def setUp(self) -> None:
     account_collection = MongoHelper.get_collection("accounts")
     account_collection.delete_many({})
コード例 #5
0
ファイル: test_log.py プロジェクト: rafaph/clean-python-api
 def setUpClass(cls) -> None:
     MongoHelper.connect(client_class=MongoClient)
     cls.errors_collection = MongoHelper.get_collection("errors")