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()})
 def setUpClass(cls) -> None:
     sut.connect(client_class=MongoClient, serverSelectionTimeoutMS=1)
 def tearDownClass(cls) -> None:
     sut.disconnect()
示例#6
0
def shutdown():
    MongoHelper.disconnect()
示例#7
0
def startup():
    MongoHelper.connect(url=config("MONGO_URL"))
 def setUp(self) -> None:
     account_collection = MongoHelper.get_collection("accounts")
     account_collection.delete_many({})
 def tearDownClass(cls) -> None:
     MongoHelper.disconnect()
 def setUpClass(cls) -> None:
     MongoHelper.connect(client_class=MongoClient)
     cls.client = TestClient(make_app())
示例#11
0
 def setUpClass(cls) -> None:
     MongoHelper.connect(client_class=MongoClient)
示例#12
0
 def setUpClass(cls) -> None:
     MongoHelper.connect(client_class=MongoClient)
     cls.errors_collection = MongoHelper.get_collection("errors")